aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2019-07-24 16:44:03 -0400
committerSam Steingold2019-07-24 16:44:21 -0400
commite089c3141a51bf70b91da21a01cdb4be0b63c08d (patch)
tree95660f73135f8de637592c662ef1207e76750440
parent50126f2049a03d2910412572c98bafbc26f3db31 (diff)
downloademacs-e089c3141a51bf70b91da21a01cdb4be0b63c08d.tar.gz
emacs-e089c3141a51bf70b91da21a01cdb4be0b63c08d.zip
Add `gnus-collect-urls-primary-text'
* lisp/gnus/gnus-sum.el (gnus-collect-urls-primary-text): Add defcustom. (gnus-collect-urls): Use it. (gnus-summary-browse-url): Mention it in the docstring.
-rw-r--r--lisp/gnus/gnus-sum.el23
1 files changed, 16 insertions, 7 deletions
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index fdecad4e424..06d3db81257 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9434,10 +9434,16 @@ With optional ARG, move across that many fields."
9434 (goto-char (point-max))) 9434 (goto-char (point-max)))
9435 (widget-backward arg))) 9435 (widget-backward arg)))
9436 9436
9437(defcustom gnus-collect-urls-primary-text "Link"
9438 "The widget text for the default link in `gnus-summary-browse-url'."
9439 :version "27.1"
9440 :type 'string
9441 :group 'gnus-article-various)
9442
9437(defun gnus-collect-urls () 9443(defun gnus-collect-urls ()
9438 "Return the list of URLs in the buffer after (point). 9444 "Return the list of URLs in the buffer after (point).
9439The 1st element is the one named 'Link', if any." 9445The 1st element is the widget named by `gnus-collect-urls-primary-text'."
9440 (let ((pt (point)) urls link) 9446 (let ((pt (point)) urls primary)
9441 (while (progn (widget-move 1 t) ; no echo 9447 (while (progn (widget-move 1 t) ; no echo
9442 ;; `widget-move' wraps around to top of buffer. 9448 ;; `widget-move' wraps around to top of buffer.
9443 (> (point) pt)) 9449 (> (point) pt))
@@ -9446,12 +9452,13 @@ The 1st element is the one named 'Link', if any."
9446 (u (or (widget-value w) 9452 (u (or (widget-value w)
9447 (get-text-property pt 'gnus-string)))) 9453 (get-text-property pt 'gnus-string))))
9448 (when (string-match-p "\\`[[:alpha:]]+://" u) 9454 (when (string-match-p "\\`[[:alpha:]]+://" u)
9449 (if (and (null link) (string= "Link" (widget-text w))) 9455 (if (and gnus-collect-urls-primary-text (null primary)
9450 (setq link u) 9456 (string= gnus-collect-urls-primary-text (widget-text w)))
9457 (setq primary u)
9451 (push u urls))))) 9458 (push u urls)))))
9452 (setq urls (nreverse urls)) 9459 (setq urls (nreverse urls))
9453 (when link 9460 (when primary
9454 (push link urls)) 9461 (push primary urls))
9455 (delete-dups urls))) 9462 (delete-dups urls)))
9456 9463
9457(defun gnus-summary-browse-url (arg) 9464(defun gnus-summary-browse-url (arg)
@@ -9459,7 +9466,9 @@ The 1st element is the one named 'Link', if any."
9459With prefix ARG, also collect links from message headers. 9466With prefix ARG, also collect links from message headers.
9460 9467
9461Links are opened using `browse-url'. If only one link is found, 9468Links are opened using `browse-url'. If only one link is found,
9462browse that directly, otherwise use completion to select a link." 9469browse that directly, otherwise use completion to select a link.
9470The first link marked in the article text with
9471`gnus-collect-urls-primary-text' is the default."
9463 (interactive "P") 9472 (interactive "P")
9464 (let (urls target) 9473 (let (urls target)
9465 (gnus-summary-select-article) 9474 (gnus-summary-select-article)