Skip to navigation

Test your regular expressions online

June 17th, 2009

Speaking of regular expressions, I found out you can test them online at Neat.

Emacs regular expressions: match at least n occurrences of character class

June 16th, 2009

Aside: I just discovered the very useful Emacs regex builder tool. Type M-x regexp-builder.

I wanted a regular expression to match the pattern of mutt mail edit buffers, to apply mail-mode, but I did not want to match the muttrc and mutt.hooks files I have.

Mail edit buffers get a pattern that starts with “mutt”, followed by a combination of dashes, letters and numbers. Examples:


The pattern mutt[-0-9a-zA-Z]+$ matches these just fine, but it would also match muttrc. So I want a regex that looks for at least three occurrences from the character class described in the brackets. Generally, this is done using {3,} (using the {m,n} pattern to match at least m and at most n occurrences). (You can match exactly n occurrences, by using {3}).

In Emacs, this didn’t work, and it turns out I had to escape the curly brackets twice: mutt[-0-9a-zA-Z]\\{3,\\}$.

Here’s the full section in my .emacs file:

(defun mutt-edit-hook ()
  (setq fill-column 70)
  (setq make-backup-files nil)

(add-to-list 'auto-mode-alist '("mutt[-0-9a-zA-Z]\\{3,\\}$" . mail-mode))
(add-hook 'mail-mode-hook 'turn-on-auto-fill)
(add-hook 'mail-mode-hook 'mutt-edit-hook)

Why Gmail sucks

June 11th, 2009

Not that anyone cares, but it helps to vent. This post is continually updated whenever I feel like it.

Why do I use Gmail if it sucks? I use it only as a storage container for mailing lists that I don’t read daily, and I read that mail using mutt via IMAP (more precisely, I read responsive local maildirs that get synchronized by the wonderful OfflineIMAP). Unfortunately, some people see my Gmail account and use it to send me mail directly, so I have to deal with these mails somehow.

Gmail is also great for IM‘ing with people using the open standard XMPP protocol, which is what Gmail uses for its chat feature. People won’t understand they can add my other XMPP account to their Gmail chat, but they understand how to add a Gmail address, even though it’s no different. In their favor, I’ve also found Gmail’s XMPP server to be very reliable, and it doesn’t kick you off for being logged on from multiple locations.

So here’s the list:

  1. No wildcard search. Try searching without wildcards in a language like German, which uses inflection much more than English and infamously contains many compound nouns. This alone makes Gmail unusable for me.
  2. Cannot apply filters in a certain order. So it isn’t possible to apply one rule to all mails that didn’t match any of the previous filters. Sure, procmail is unintuitive like hell, but at least you can read up on it and then it really does what you want it to do.
  3. Cannot display individual messages on their own or sort mail, e.g. by sender.
  4. I regularly have lots of false positives in the spam folder. Most of them are from mailing lists that also match a rule that labels them and moves them out of the inbox. When I manually click “Not spam” in the spam folder, they get labeled correctly, but then moved to the inbox. So I have to manually remove them from the inbox. And in the inbox, there isn’t even a way to quickly mark all messages that have any label, no matter which one! (In mutt, I would just have to type T ~y . and hit “Enter”)
  5. Did I mention I have lots of false positives in spam, and no way to set the threshold?
  6. Filter rules are really limited in what you can do with them, and the standard filter setup form doesn’t even have the option to filter by “cc”, or to choose between Boolean operators. (you can do this by putting something like OR into the “Has the words” field.)
  7. Aug 16 edit: Recently, Gmail automatically added some labels like “Travel”, “Personal”, “Receipts” for users who had no labels. Maybe those users wanted no labels? Maybe some of them are like my parents, for whom I’ve set up Gmail accounts, but who normally access them using Thunderbird, and who might be confused by things suddenly appearing when they do use the webmail interface, like when they’re traveling? Even worse when these extra labels bump the not-so-unimportant labels of “All Mail”, “Trash”, and “Spam” out of view.

Gmail is probably pretty cool if all you were using before was a very limited webmail interface. Do yourself a favor and try a decent desktop mail client, like Thunderbird. If you want your mail to be available online, you can still use that client to read Gmail via IMAP.

Disable pop-up system notification messages in Ubuntu

June 11th, 2009

I found the little pop-ups really annoying that show up when I get an icon in the system tray anyway, such as for available software updates.

sudo chmod -x /usr/lib/notification-daemon/notification-daemon

Maintaining a whitelist of e-mail senders with local mutt and procmail on a server

June 8th, 2009

I run mutt locally on several different computers. OfflineIMAP automatically synchronizes the mailboxes, and that is a huge benefit. But I still had to set up a system that synchronizes my address books and mail settings. I’ve forgotten what exactly I am doing to accomplish this, and I now think there’s a small mistake somewhere that sometimes causes me to lose e-mail addresses from my address book. So I’ll write a little series in the category mail setup to document this on this blog, step by step, as I have time. This is the first instalment.

I maintain a whitelist of e-mail addresses to save spamassassin some work and myself some false positives.
To do this, I have a script that I run periodically (using crontab). The relevant lines of this script are (there’s some more stuff, since I also use it to blacklist things):

grep @ $ALIASFILE | cut -d "<" -f 2  | cut -d ">" -f 1 | grep -v " " > $WHITELIST
ping -c1 > /dev/null 2>&1
if [ $? != 0 ] ; then
  exit 0
  rsync $WHITELIST isomerica:.procmail/my_whitelist

The script just gets the e-mail addresses from my mutt alias file, combines this with any addresses from a manually maintained alias file, then uploads that to the server. On the server, the spam handling recipe in ~/.procmailrc does not pipe mail from these addresses to spamassassin, but everything else:

* ! ? (echo "$FROM" | $FGREP -f $WHITELIST)
| spamc
* ^X-spam-flag: yes