aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Abrahamsen2019-06-23 08:09:23 -0700
committerEric Abrahamsen2019-06-23 10:05:39 -0700
commit55cb14bfa036991183a3895506a87536befbb9ca (patch)
tree9b62a60f4002c4ee68aa08527dee4d66c25dea59
parent383a557b537562ceed38da3c9a07790c2f6b67f6 (diff)
downloademacs-55cb14bfa036991183a3895506a87536befbb9ca.tar.gz
emacs-55cb14bfa036991183a3895506a87536befbb9ca.zip
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.texi11
-rw-r--r--lisp/gnus/gnus-sum.el40
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
10154the @kbd{A C} command (@code{gnus-summary-show-complete-article}) will 10154the @kbd{A C} command (@code{gnus-summary-show-complete-article}) will
10155do so. 10155do so.
10156 10156
10157@item w
10158@itemx A w
10159@kindex w @r{(Summary)}
10160@kindex A w @r{(Summary)}
10161@cindex web
10162@cindex url
10163@findex gnus-summary-browse-url
10164Scan the article buffer for links, and offer them to the user for
10165browsing with @code{browse-url}. By default, only scan the article
10166body; with a prefix arg, also scan the article headers.
10167
10157@end table 10168@end table
10158 10169
10159 10170
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."
1983 "s" gnus-summary-isearch-article 1983 "s" gnus-summary-isearch-article
1984 "\t" gnus-summary-widget-forward 1984 "\t" gnus-summary-widget-forward
1985 [backtab] gnus-summary-widget-backward 1985 [backtab] gnus-summary-widget-backward
1986 "w" gnus-summary-browse-url
1986 "t" gnus-summary-toggle-header 1987 "t" gnus-summary-toggle-header
1987 "g" gnus-summary-show-article 1988 "g" gnus-summary-show-article
1988 "l" gnus-summary-goto-last-article 1989 "l" gnus-summary-goto-last-article
@@ -2149,6 +2150,7 @@ increase the score of each group you read."
2149 "s" gnus-summary-isearch-article 2150 "s" gnus-summary-isearch-article
2150 "\t" gnus-summary-widget-forward 2151 "\t" gnus-summary-widget-forward
2151 [backtab] gnus-summary-widget-backward 2152 [backtab] gnus-summary-widget-backward
2153 "w" gnus-summary-browse-url
2152 "P" gnus-summary-print-article 2154 "P" gnus-summary-print-article
2153 "S" gnus-sticky-article 2155 "S" gnus-sticky-article
2154 "M" gnus-mailing-list-insinuate 2156 "M" gnus-mailing-list-insinuate
@@ -9432,6 +9434,44 @@ With optional ARG, move across that many fields."
9432 (goto-char (point-max))) 9434 (goto-char (point-max)))
9433 (widget-backward arg))) 9435 (widget-backward arg)))
9434 9436
9437(defun gnus-summary-browse-url (arg)
9438 "Scan the current article body for links, and offer to browse them.
9439With prefix ARG, also collect links from message headers.
9440
9441Links are opened using `browse-url'. If only one link is found,
9442browse that directly, otherwise use completion to select a link."
9443 (interactive "P")
9444 (let (pt urls target)
9445 (gnus-summary-select-article)
9446 (gnus-configure-windows 'article)
9447 (gnus-with-article-buffer
9448 (if arg
9449 (goto-char (point-min))
9450 (article-goto-body)
9451 ;; Back up a char, in case body starts with a widget.
9452 (backward-char))
9453 (setq pt (point))
9454 (while (progn (widget-forward 1)
9455 ;; `widget-forward' wraps around to top of
9456 ;; buffer.
9457 (> (point) pt))
9458 (setq pt (point))
9459 (when-let ((u (or (get-text-property (point) 'shr-url)
9460 (get-text-property (point) 'gnus-string))))
9461 (when (string-match-p "\\`[[:alpha:]]+://" u)
9462 (push u urls))))
9463 (setq target
9464 (cond ((= (length urls) 1)
9465 (car urls))
9466 ((> (length urls) 1)
9467 (completing-read
9468 "URL to browse: "
9469 (setq urls (nreverse (delete-dups urls)))
9470 nil t))))
9471 (if target
9472 (browse-url target)
9473 (message "No URLs found.")))))
9474
9435(defun gnus-summary-isearch-article (&optional regexp-p) 9475(defun gnus-summary-isearch-article (&optional regexp-p)
9436 "Do incremental search forward on the current article. 9476 "Do incremental search forward on the current article.
9437If REGEXP-P (the prefix) is non-nil, do regexp isearch." 9477If REGEXP-P (the prefix) is non-nil, do regexp isearch."