Test your regular expressions online
June 17th, 2009Speaking of regular expressions, I found out you can test them online at regexpal.com. Neat.
Speaking of regular expressions, I found out you can test them online at regexpal.com. Neat.
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:
mutt-lauren-ad34AD- muttadR12 muttadrsd
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)
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:
T ~y . and hit “Enter”)to:this.address@blah.com OR cc:this.address@blah.com into the “Has the words” field.)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.
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
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):
#!/bin/bash ALIASFILE=$HOME/.mutt/.mutt.aliases WHITELISTMAN=$HOME/.mutt/my_manual_whitelist WHITELIST=$HOME/.mutt/my_whitelist grep @ $ALIASFILE | cut -d "<" -f 2 | cut -d ">" -f 1 | grep -v " " > $WHITELIST cat $WHITELISTMAN >> $WHITELIST ping -c1 colobus.isomerica.net > /dev/null 2>&1 if [ $? != 0 ] ; then exit 0 else rsync $WHITELIST isomerica:.procmail/my_whitelist fi
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:
:0fw * ! ? (echo "$FROM" | $FGREP -f $WHITELIST) | spamc :0: * ^X-spam-flag: yes $HOME/.maildir/inbox/.Junk/