Two Gnus tricks
April 21, 2008 by jaoI’ve added a couple of tweaks to my Gnus config lately. Nothing earth-shattering, but in both cases i was writing my own elisp for something that was already in there. So, i’ve thought i’d share them and, maybe, save you the trouble.
The first one is a quickie, and you probably know about it; but for some reason it took me ages to discover the correct configuration knob. When you reply a mail, emacs will use the value of user-mail-address to compose the From: header. One can also tweak gnus-posting-styles to change the address on a per group basis. But what i really wanted was to use the address in the mail i was replying to. I was writing a hook to that effect when i found the variable to set to accomplish it: message-alternative-mails. Here’s how i set it up:
(setq message-alternative-emails
(regexp-opt '("jao@gnu.org" "jaortega@goodmail.com" "jao@member.fsf.org")))
Worked like a charm. Now for the second one.
As i’ve mentioned in some post before, Gnus let’s you customise the summary line to your heart’s content by tweaking the variable gnus-summary-line-format. I normally use emacs in a maximized urxvt terminal, so i’ve got plenty of room in my summary lines. One thing i wanted to add is the message’s date in a) my time zone and b) human readable form (you know, something like ‘Today, 22:33′ or ‘Yesterday, 02:44′). I only knew two format directives showing a date (%d and %D), but neither fulfilled my wishes. So i started coding my own, but halfway discovered that Gnus already comes with a custom one, called user-date. You use it by inserting %&user-date; in the line format string. It works in conjunction with a configuration stored in gnus-user-date-format-alist, which contains a lists of pairs. The first member of the pair is the age of the message, the second a time format string for displaying the date of messages that old. You’ll understand it better with an example, taken from my current configuration:
(setq gnus-user-date-format-alist
'(((gnus-seconds-today) . "Today, %H:%M")
((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
(604800 . "%A %H:%M") ;;that's one week
((gnus-seconds-month) . "%A %d")
((gnus-seconds-year) . "%B %d")
(t . "%B %d '%y"))) ;;this one is used when no other does match
(setq gnus-summary-line-format
(concat "%U%R %~(pad-right 2)t%* %uj %B%~(max-right 30)~(pad-right 30)n "
"%~(max-right 90)~(pad-right 90)s %-135=%&user-date;\n"))
I’ve copied my whole line format so that you can see, in addition, how i manage to keep things aligned in a frame around 180 columns wide. For details on the %uj directive, see this previous post.
Although Gnus is my primary mail reader, there’s lots of things i like about Gmail (actually, Gmail is my primary inbox: Gnus reads mail from there). For instance, a little feature i love in Gmail is those markers that tell you whether you’re one of the direct recipients of a mail. When seeing a long list of mails in a mail list, i can quickly identify those with me explicitly in the To: or Cc: headers: chances are i’m slightly more interested in them.
Notice the
Let me tell you how Emacs is more and more taking the center stage in my MacBook. In a previous post i explained how i set up Gnus as my mail (and of course, news) reader: i like Gnus so much that it quickly became my default. And, just in case you didn’t know, Emacs can be OS X’s default mail handler too: just go to Mail’s general preferences pane and set it–it’s that easy. (In the image, i’m setting fink’s carbon emacs package, but you’ll see there too CarbonEmacs or Aquamacs if you have them installed.) With that setting in place, OS X will dutifully use Gnus whenever a mail handler is requested (e.g., when following
Unlike Gnus, Emacs is not my default web browser, although i use w3m-el quite a bit (specially for technical manuals). So, every now and then i find myself seeing a page in Safari than i want to open in Emacs. Applescript to the rescue: fire up that ugly Script Editor and type this simple program:

