aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2022-03-15 12:22:48 -0400
committerSam Steingold2022-03-15 12:22:48 -0400
commitd932e256a497d80de9dbcea6a8e019d2cb063429 (patch)
treeae5d87d90cdb84c170de00883eb4209f13021dd4
parentb63f325e2eff03a0b5c288d5930322442a87b72f (diff)
downloademacs-d932e256a497d80de9dbcea6a8e019d2cb063429.tar.gz
emacs-d932e256a497d80de9dbcea6a8e019d2cb063429.zip
Extract `gnus-collect-urls-from-article' from `gnus-summary-browse-url'
* lisp/gnus-sum.el (gnus-collect-urls-from-article): New function, extracted from `gnus-summary-browse-url'. (gnus-summary-browse-url): Use it.
-rw-r--r--lisp/gnus/gnus-sum.el46
1 files changed, 25 insertions, 21 deletions
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 1be5a48068c..769ad6d9eb1 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9445,6 +9445,16 @@ The 1st element is the button named by `gnus-collect-urls-primary-text'."
9445 (push primary urls)) 9445 (push primary urls))
9446 (delete-dups urls))) 9446 (delete-dups urls)))
9447 9447
9448(defun gnus-collect-urls-from-article ()
9449 "Select the article and return the list of URLs in it.
9450See 'gnus-collect-urls'."
9451 (gnus-summary-select-article)
9452 (gnus-with-article-buffer
9453 (article-goto-body)
9454 ;; Back up a char, in case body starts with a button.
9455 (backward-char)
9456 (gnus-collect-urls)))
9457
9448(defun gnus-shorten-url (url max) 9458(defun gnus-shorten-url (url max)
9449 "Return an excerpt from URL not exceeding MAX characters." 9459 "Return an excerpt from URL not exceeding MAX characters."
9450 (if (<= (length url) max) 9460 (if (<= (length url) max)
@@ -9460,33 +9470,27 @@ The 1st element is the button named by `gnus-collect-urls-primary-text'."
9460 "Scan the current article body for links, and offer to browse them. 9470 "Scan the current article body for links, and offer to browse them.
9461 9471
9462Links are opened using `browse-url' unless a prefix argument is 9472Links are opened using `browse-url' unless a prefix argument is
9463given: Then `browse-url-secondary-browser-function' is used instead. 9473given: then `browse-url-secondary-browser-function' is used instead.
9464 9474
9465If only one link is found, browse that directly, otherwise use 9475If only one link is found, browse that directly, otherwise use
9466completion to select a link. The first link marked in the 9476completion to select a link. The first link marked in the
9467article text with `gnus-collect-urls-primary-text' is the 9477article text with `gnus-collect-urls-primary-text' is the
9468default." 9478default."
9469 (interactive "P" gnus-summary-mode) 9479 (interactive "P" gnus-summary-mode)
9470 (let (urls target) 9480 (let* ((urls (gnus-collect-urls-from-article))
9471 (gnus-summary-select-article) 9481 (target
9472 (gnus-with-article-buffer 9482 (cond ((= (length urls) 1)
9473 (article-goto-body) 9483 (car urls))
9474 ;; Back up a char, in case body starts with a button. 9484 ((> (length urls) 1)
9475 (backward-char) 9485 (completing-read
9476 (setq urls (gnus-collect-urls)) 9486 (format-prompt "URL to browse"
9477 (setq target 9487 (gnus-shorten-url (car urls) 40))
9478 (cond ((= (length urls) 1) 9488 urls nil t nil nil (car urls))))))
9479 (car urls)) 9489 (if target
9480 ((> (length urls) 1) 9490 (if external
9481 (completing-read 9491 (funcall browse-url-secondary-browser-function target)
9482 (format-prompt "URL to browse" 9492 (browse-url target))
9483 (gnus-shorten-url (car urls) 40)) 9493 (message "No URLs found."))))
9484 urls nil t nil nil (car urls)))))
9485 (if target
9486 (if external
9487 (funcall browse-url-secondary-browser-function target)
9488 (browse-url target))
9489 (message "No URLs found.")))))
9490 9494
9491(defun gnus-summary-isearch-article (&optional regexp-p) 9495(defun gnus-summary-isearch-article (&optional regexp-p)
9492 "Do incremental search forward on the current article. 9496 "Do incremental search forward on the current article.