Gnus: Combining RSS feeds into a single webcomic group

Posted on February 21, 2013 by Jack Kelly
Tags: coding, emacs

In an earlier post, I set up gnus to read some RSS feeds. I wasn’t happy with the dependency on a web service, and I didn’t like having the comics in separate groups. So I wrote Ms. RSS, a tool to Merge &; Scrub RSS feeds. To pull down my favourite comic feeds into something that doesn’t make gnus barf, I use something like this:

$ msrss -o webcomics.xml -t Webcomics -k '' \
    -l 'Darths & Droids' http://www.darthsanddroids.net/rss.xml \
    -l 'Irregular Webcomic!' http://irregularwebcomic.net/rss4.xml \
    -l 'xkcd' http://xkcd.com/rss.xml \
    -l 'Dr. McNinja' http://drmcninja.com/feed/

Simple enough. Now, let’s wire it into gnus. First, we define a function that calls msrss and checks that everything went okay:

(defun jdk-rss-update-webcomics ()
  "Update my favourite webcomics into a cached local file."
  (when gnus-plugged
    (message "Updating webcomics.xml...")
    (call-process "msrss" nil "*msrss*" nil
                  "-o" (concat (file-name-as-directory (getenv "HOME"))
                               ".msrss/webcomics.xml")
                  "-t" "Webcomics"
                  "-k" ""
                  "-l" "Darths & Droids" "http://www.darthsanddroids.net/rss.xml"
                  "-l" "Irregular Webcomic!" "http://irregularwebcomic.net/rss4.xml"
                  "-l" "xkcd" "http://xkcd.com/rss.xml"
                  "-l" "Dr. McNinja" "http://drmcninja.com/feed/")
    (message "Updating webcomics.xml... done")

    ;; Check if msrss complained about anything.
    (save-current-buffer
      (set-buffer "*msrss*")
      (let ((contents (buffer-string)))
        (if (string= contents "")
            (kill-buffer "*msrss*")
          (message "msrss issued warnings. See *msrss*."))))))

Next, we hook it into gnus so it’s run at startup and whenever we check for new news:

(add-hook 'gnus-startup-hook 'jdk-rss-update-webcomics)
(add-hook 'gnus-get-new-news-hook 'jdk-rss-update-webcomics)

Most of the feeds don’t have author information, and the group’s summary buffer looks ugly as a result. Clean that up, and while we’re setting parameters we may as well sort the entries by date:

(setq gnus-parameters
      '(("^nnrss:Webcomics$"
         (gnus-article-sort-functions '(gnus-article-sort-by-subject
                                        gnus-article-sort-by-date))
         (gnus-summary-line-format "%U%R%z (%d) %s\n")
         (gnus-show-threads nil))))

Then I made a new RSS group (G R file:///home/username/.msrss/webcomics.xml RET ...) and called it “Webcomics”. Success.

Previous Post
All Posts | RSS | Atom
Next Post
Copyright © 2024 Jack Kelly
Site generated by Hakyll (source)