Is there any urlview (a la mutt) for gnus? Or just elisp to extract urls?

I switched from mutt to gnus and would like to extract the URLs from the email and be able to run a new buffer containing all the URLs in the given email. Urlview does this for mutt as a help system for what I'm looking for.

+4
source share
2 answers

I wrote the following and tested it to work on several articles. This may be a good starting point for you.

(defun gnus-article-extract-url-into-buffer () (interactive) (let ((simple-url-regexp "https?://") urls) (save-excursion ;; collect text URLs (while (search-forward-regexp simple-url-regexp nil t) (when-let (url (thing-at-point 'url)) (setq urls (cons url urls)))) (beginning-of-buffer) ;; collect widget URLs (while (not (eobp)) (goto-char (next-overlay-change (point))) (when-let (link (get-text-property (point) 'gnus-string)) (and (string-match simple-url-regexp link) (setq urls (cons link urls)))) (goto-char (next-overlay-change (point))))) (when urls (switch-to-buffer-other-window "*gnus-article-urls*") (dolist (url urls) (insert url)) (beginning-of-buffer)))) 

I must clarify that this is intended to be run from the article buffer. Also, I might have missed the point by taking what you said literally about starting a new buffer containing URLs, in which case you can change the last form to:

 (when urls (dolist (url urls) (browse-url url))) 

Or, Tyler's approach is simpler if you don't need to parse widget URLs.

+2
source

I do not think the function is built-in. The following code will do what you want. From the summary buffer, call Mx urlview or bind it to a convenient key. The save-crawl wrapper should drop you in the summary buffer, but for some reason, it leaves you in the article buffer. Just h key will return you, but you do not need to do this. Maybe someone else can clarify this part?

 (defun urlview () (interactive) (save-excursion (gnus-summary-select-article-buffer) (beginning-of-buffer) (while (re-search-forward "https?://" nil t) (browse-url-at-point)))) 

Edit: Joseph is responsible for the http and https that I forgot. So I spent this part of his code.

+1
source

Source: https://habr.com/ru/post/1339520/


All Articles