summaryrefslogtreecommitdiff
path: root/lisp/gnus/gnus-sum.el
diff options
context:
space:
mode:
authorSam Steingold <sds@gnu.org>2019-06-28 17:22:55 -0400
committerSam Steingold <sds@gnu.org>2019-07-01 09:15:38 -0400
commitdb83df1e29989928153ccd92222776d3362d6b26 (patch)
tree13ab11f7cfac7f4fd55b0eaaf3535910d55bd637 /lisp/gnus/gnus-sum.el
parent6cabb698f99a6b9e931cdac7347b18c44fde6041 (diff)
downloademacs-db83df1e29989928153ccd92222776d3362d6b26.tar.gz
emacs-db83df1e29989928153ccd92222776d3362d6b26.tar.bz2
emacs-db83df1e29989928153ccd92222776d3362d6b26.zip
Extract gnus-collect-urls from gnus-summary-browse-url
* lisp/gnus/gnus-sum.el (gnus-collect-urls): Extract from ... (gnus-summary-browse-url): Use it here. Extracting URLs from an article will be useful in BBDB interaction.
Diffstat (limited to 'lisp/gnus/gnus-sum.el')
-rw-r--r--lisp/gnus/gnus-sum.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 621ba3e90cc..acc4132c27b 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9434,6 +9434,19 @@ With optional ARG, move across that many fields."
(goto-char (point-max)))
(widget-backward arg)))
+(defun gnus-collect-urls ()
+ "Return the list of URLs in the buffer after (point)."
+ (let ((pt (point)) urls)
+ (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))))
+ (nreverse (delete-dups urls))))
+
(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.
@@ -9441,7 +9454,7 @@ 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)
+ (let (urls target)
(gnus-summary-select-article)
(gnus-configure-windows 'article)
(gnus-with-article-buffer
@@ -9450,24 +9463,12 @@ browse that directly, otherwise use completion to select a link."
(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 urls (gnus-collect-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))))
+ (completing-read "URL to browse: " urls nil t))))
(if target
(browse-url target)
(message "No URLs found.")))))