diff options
| author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-06-23 08:09:23 -0700 |
|---|---|---|
| committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-06-23 10:05:39 -0700 |
| commit | 55cb14bfa036991183a3895506a87536befbb9ca (patch) | |
| tree | 9b62a60f4002c4ee68aa08527dee4d66c25dea59 | |
| parent | 383a557b537562ceed38da3c9a07790c2f6b67f6 (diff) | |
| download | emacs-55cb14bfa036991183a3895506a87536befbb9ca.tar.gz | |
New command gnus-summary-browse-url
* lisp/gnus/gnus-sum.el (gnus-summary-browse-url): New command for
browsing URLs from the article buffer from the summary buffer.
(gnus-summary-mode-map): Bind to "w".
(gnus-summary-article-map): And to "A w".
* doc/misc/gnus.texi (Article Commands): Document.
| -rw-r--r-- | doc/misc/gnus.texi | 11 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 40 |
2 files changed, 51 insertions, 0 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index ba3a0e9b2e8..28f000c4898 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -10154,6 +10154,17 @@ partial article, and want to see the complete article instead, then the @kbd{A C} command (@code{gnus-summary-show-complete-article}) will do so. +@item w +@itemx A w +@kindex w @r{(Summary)} +@kindex A w @r{(Summary)} +@cindex web +@cindex url +@findex gnus-summary-browse-url +Scan the article buffer for links, and offer them to the user for +browsing with @code{browse-url}. By default, only scan the article +body; with a prefix arg, also scan the article headers. + @end table diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 8fdb766584b..621ba3e90cc 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el @@ -1983,6 +1983,7 @@ increase the score of each group you read." "s" gnus-summary-isearch-article "\t" gnus-summary-widget-forward [backtab] gnus-summary-widget-backward + "w" gnus-summary-browse-url "t" gnus-summary-toggle-header "g" gnus-summary-show-article "l" gnus-summary-goto-last-article @@ -2149,6 +2150,7 @@ increase the score of each group you read." "s" gnus-summary-isearch-article "\t" gnus-summary-widget-forward [backtab] gnus-summary-widget-backward + "w" gnus-summary-browse-url "P" gnus-summary-print-article "S" gnus-sticky-article "M" gnus-mailing-list-insinuate @@ -9432,6 +9434,44 @@ With optional ARG, move across that many fields." (goto-char (point-max))) (widget-backward arg))) +(defun gnus-summary-browse-url (arg) + "Scan the current article body for links, and offer to browse them. +With prefix ARG, also collect links from message headers. + +Links are opened using `browse-url'. If only one link is found, +browse that directly, otherwise use completion to select a link." + (interactive "P") + (let (pt urls target) + (gnus-summary-select-article) + (gnus-configure-windows 'article) + (gnus-with-article-buffer + (if arg + (goto-char (point-min)) + (article-goto-body) + ;; Back up a char, in case body starts with a widget. + (backward-char)) + (setq pt (point)) + (while (progn (widget-forward 1) + ;; `widget-forward' wraps around to top of + ;; buffer. + (> (point) pt)) + (setq pt (point)) + (when-let ((u (or (get-text-property (point) 'shr-url) + (get-text-property (point) 'gnus-string)))) + (when (string-match-p "\\`[[:alpha:]]+://" u) + (push u urls)))) + (setq target + (cond ((= (length urls) 1) + (car urls)) + ((> (length urls) 1) + (completing-read + "URL to browse: " + (setq urls (nreverse (delete-dups urls))) + nil t)))) + (if target + (browse-url target) + (message "No URLs found."))))) + (defun gnus-summary-isearch-article (&optional regexp-p) "Do incremental search forward on the current article. If REGEXP-P (the prefix) is non-nil, do regexp isearch." |
