Toke Høiland-Jørgensen <[email protected]> writes:

> Memnon Anon <[email protected]> writes:
>
>> Something like this?
>
> I modified that function a tiny bit to make sure it doesn't throw an
> error if an invalid buffer shows up in the list, and so it doesn't leave
> the article unformatted if it can't find the archive-at header. It now
> looks like this:

[…]

Note that gnus has this handy macro `gnus-with-article-buffer' that lets
you do away with the whole buffer-list loop:

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
  "Start a browser for current gwene article"
  (interactive)
  (gnus-summary-show-article '(4))
  (let ((url
         (gnus-with-article-buffer
           (goto-char (point-min))
           (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) 
'noerror)
             (match-string 1)))))
    (gnus-summary-show-article)
    (if url
        (browse-url url)
      (message "Couldn't find any likely url"))))
#+end_src


Of course, if gnus had an even handier macro like

#+begin_src emacs-lisp
(defmacro gnus-with-raw-article-buffer (&rest forms)
  `(progn
     (gnus-summary-show-article '(4))
     (prog1 (gnus-with-article-buffer ,@forms)
       (gnus-summary-show-article))))
#+end_src

then you could simplify that even further to 

#+begin_src emacs-lisp
(defun my-gnus-browse-gwene ()
  "Start a browser for current gwene article"
  (interactive)
  (let ((url
         (gnus-with-raw-article-buffer
           (goto-char (point-min))
           (when (re-search-forward "^Archived-at: <\\(.*\\)>$" (point-max) 
'noerror)
             (match-string 1)))))
    (if url
        (browse-url url)
      (message "Couldn't find any likely url"))))
#+end_src



-- 
Kevin Brubeck Unhammer

GPG: 0x766AC60C

Attachment: pgpdz6le1F5Pg.pgp
Description: PGP signature

_______________________________________________
info-gnus-english mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to