Hi there!

First of all, sorry about the lack of posts of late. Imagine a standard explanation here, including all the normal bits about work, holidays, and social lives.

Now, on to the good stuff. I read lots of mailing lists via Gmane. Gmane includes an Archived-At header which points to Gmane's permalink for the article. I prefer Gmane's Gnus-like web interface to its blog-like one; here's how I automatically change the link to the one I prefer. Note that the link needs to be changed in two places: in the header text, and in the gnus-data text property of the header text.

(defun ted-mangle-gmane-archival-gnus-data (link)
  "Mangle the `gnus-data' property value LINK.
Specifically, change the archival URL from permalink.gmane.org (Gmane's
blog-like interface) to article.gmane.org (Gmane's newslike interface)."
  (let ((original-date (get-text-property 5 'original-date link))
        (face (get-text-property 5 'face link)))
    (propertize (replace-regexp-in-string "permalink" "article"
                                          (substring-no-properties link))
                'face face 'original-date original-date)))

(defun ted-mangle-gmane-archival-header ()
  "Mangle Gmane's Archived-At header to be more useful.
Specifically, change the archival URL from permalink.gmane.org (Gmane's
blog-like interface) to article.gmane.org (Gmane's newslike interface)."
  (gnus-with-article-headers
   (when (gnus-article-goto-header "Archived-At")
     (save-excursion
       (alter-text-property (+ 2 (point)) (1- (line-end-position)) 'gnus-data
                            'ted-mangle-gmane-archival-gnus-data))
     (when (re-search-forward "permalink" (line-end-position) t)
       (replace-match (propertize "article" 'face 'gnus-header-content))))))

(add-hook 'gnus-article-prepare-hook 'ted-mangle-gmane-archival-header)

I think this is a good illustration of how to use gnus-article-prepare-hook to munge articles.

Add a comment

Posting...