Prosthetic Conscience

Jason McBrayer's weblog; occasional personal notes and commentary

Thu, 02 Jul 2009

Getting html articles in Gnus to obey browse-url-browser-function

I use Gnus for email, and frequently get emails with an html part. In some cases, I even want to receive emails with an html part, as with RSS feeds that have been translated to Gnus groups via rss2email, in which I sometimes want to see images inline so I don’t have to click through to the original article. Like most people viewing html emails in Gnus, I let emacs-w3m handle the translation of html to text. The problem with this is that then hitting return on a link will use w3m to follow the link, not the browser you have specified in browse-url-browser-function.

This little code snippet fixes that. I’m not sure it’s ideal in all ways. But it works for me currently.

(eval-after-load “w3m”
  ‘(progn
     (defun jfm/open-url-dwim (&optional url)
       (interactive)
       (if (equal browse-url-browser-function ‘w3m-browse-url)
           (w3m-browse-url url)
         (if (equal (face-at-point) ‘w3m-anchor-face)
             (w3m-view-url-with-external-browser url)
           (browse-url url))))
     (define-key gnus-article-mode-map (kbd “<return>”) ‘jfm/open-url-dwim)))

[ Posted: 07:30] | [ Category: ] | Permalink | Comments: 2 ]

 


Powered by PyBlosxom