Gwene

GmaneGmane is by now a very important piece of my Emacs life. It allows me to get postings to lots of mailing lists using NNTP, i.e., using Gnus, i.e., in a way fully integrated with the “information retrieval and massaging” engine i’ve built around a handful of Emacs packages and elisp snippets (one central actor among them being org-mode).

Another important (if only due to its volume) source of incoming information are RSS subscriptions, to which i have a mild addiction. After trying several options, i had settled on rss2email to read my feeds and channel them to Gnus, with the help of some filtering rules. Although it works pretty well, i wasn’t totally satisfied with this arrangement because it depends on an external program over which (as i don’t like hacking in Python) have less control than i’d wish.

But now, thanks to Gmane’s creator,Lars Magne Ingebrigtsen, i’m nearing the RSS nirvana: he’s created a new service, Gwene, which works like Gmane, but for RSS feeds instead of mailing lists. The interface is damn simple: you just enter the URL of the feed you wanna read, give it a name, and its contents is available over NNTP and updated every thirty minutes. All that is left is to add news.gwene.org to your list of NNTP servers in Gnus (or, in my case, leafnode) and subscribe to the corresponding group.

Any group you add will be available to everyone (for instance, i found this blog already there as gwene.com.wordpress.emacs.feed), and i’d bet Lars will keep adding features in the future. To me, it’s already extremely useful as it stands today!

Posted in Gnus, TEOS. 10 Comments »

Two Gnus tricks

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 '("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.

Posted in Gnus. 2 Comments »

Gmail envy

Gmail markers 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.

In Gnus, one can customize the information shown in the message list by tweaking the variable gnus-summary-line-format. If you press C-h v gnus-summary-line-format to see all the formatting options, you’ll see there’s a lot of information to be shown, but not the one we want. But, as is always the case, we have a hook to extend the format to our hearts content: the %uX directive, where X is any letter you want. When Gnus sees that directive, it calls gnus-user-format-function-X, a function you must write returning a string that gets inserted in the summary line. So here we go: first i define a string with a regexp of my email addresses:

(defvar *jao-mails* 
        "jao@foo\\.org\\|jao@baz\\.com\\|jao@grogle\\.com")

and then i function which returns a “»” if i’m the only recipient of the message, or a “~” if i’m in the To:, Cc: or BCc: headers among others:

(defun gnus-user-format-function-j (headers)
  (let ((to (gnus-extra-header 'To headers)))
    (if (string-match *jao-mails* to)
        (if (string-match "," to) "~" "»")
        (if (or (string-match *jao-mails* 
                              (gnus-extra-header 'Cc headers))
                (string-match *jao-mails* 
                              (gnus-extra-header 'BCc headers)))
            "~"
            " "))))

Then all that is left is using it in my gnus-summary-line-format:

(setq
 gnus-summary-line-format
 "%U%R %~(pad-right 2)t%* %uj %B%~(max-right 20)~(pad-right 20)n %s\n")

Picture 2.pngNotice the %uj doing the trick here. I’m sure you’ll come up with other uses to this extension mechanism, which, by the way, is also available for gnus-group-line-format, the variable governing how lines in the *Group* buffer are displayed.

Posted in Gnus. 6 Comments »

Gnus and Google Groups

Eternal September notwithstanding, i have great daily fun reading a bunch of usenet groups, and their articles are sometimes a source of ideas for blogging. Of course, my usenet client is Gnus; but in a blog post one needs the Google Groups URL when mentioning and article. So, i just spent five minutes writing a snippet to go from Gnus to GG in a keystroke:

(defun jao-gnus-goto-google ()
  (interactive)
  (when (memq major-mode '(gnus-summary-mode gnus-article-mode))
    (when (eq major-mode 'gnus-article-mode) 
      (gnus-article-show-summary))
    (let* ((article (gnus-summary-article-number))
           (header (gnus-summary-article-header article))
           (id (substring (mail-header-id header) 1 -1)))
      (browse-url 
       (format "http://groups.google.com/groups?selm=%s" id)))))

As you see, i just check that i’m viewing a post, obtain the message identifier (trimming surrounding markup) and construct a query that looks up the corresponding GG article.

Talk about extensibility.

Follow

Get every new post delivered to your Inbox.