I’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 '("email@example.com" "firstname.lastname@example.org" "email@example.com")))
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.