[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d932e256a4: Extract `gnus-collect-urls-from-article' from `gnus-s
From: |
Sam Steingold |
Subject: |
master d932e256a4: Extract `gnus-collect-urls-from-article' from `gnus-summary-browse-url' |
Date: |
Tue, 15 Mar 2022 12:23:02 -0400 (EDT) |
branch: master
commit d932e256a497d80de9dbcea6a8e019d2cb063429
Author: Sam Steingold <sds@gnu.org>
Commit: Sam Steingold <sds@gnu.org>
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.
---
lisp/gnus/gnus-sum.el | 46 +++++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 21 deletions(-)
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 1be5a48068..769ad6d9eb 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'."
(push primary urls))
(delete-dups urls)))
+(defun gnus-collect-urls-from-article ()
+ "Select the article and return the list of URLs in it.
+See 'gnus-collect-urls'."
+ (gnus-summary-select-article)
+ (gnus-with-article-buffer
+ (article-goto-body)
+ ;; Back up a char, in case body starts with a button.
+ (backward-char)
+ (gnus-collect-urls)))
+
(defun gnus-shorten-url (url max)
"Return an excerpt from URL not exceeding MAX characters."
(if (<= (length url) max)
@@ -9460,33 +9470,27 @@ The 1st element is the button named by
`gnus-collect-urls-primary-text'."
"Scan the current article body for links, and offer to browse them.
Links are opened using `browse-url' unless a prefix argument is
-given: Then `browse-url-secondary-browser-function' is used instead.
+given: then `browse-url-secondary-browser-function' is used instead.
If only one link is found, browse that directly, otherwise use
completion to select a link. The first link marked in the
article text with `gnus-collect-urls-primary-text' is the
default."
(interactive "P" gnus-summary-mode)
- (let (urls target)
- (gnus-summary-select-article)
- (gnus-with-article-buffer
- (article-goto-body)
- ;; Back up a char, in case body starts with a button.
- (backward-char)
- (setq urls (gnus-collect-urls))
- (setq target
- (cond ((= (length urls) 1)
- (car urls))
- ((> (length urls) 1)
- (completing-read
- (format-prompt "URL to browse"
- (gnus-shorten-url (car urls) 40))
- urls nil t nil nil (car urls)))))
- (if target
- (if external
- (funcall browse-url-secondary-browser-function target)
- (browse-url target))
- (message "No URLs found.")))))
+ (let* ((urls (gnus-collect-urls-from-article))
+ (target
+ (cond ((= (length urls) 1)
+ (car urls))
+ ((> (length urls) 1)
+ (completing-read
+ (format-prompt "URL to browse"
+ (gnus-shorten-url (car urls) 40))
+ urls nil t nil nil (car urls))))))
+ (if target
+ (if external
+ (funcall browse-url-secondary-browser-function target)
+ (browse-url target))
+ (message "No URLs found."))))
(defun gnus-summary-isearch-article (&optional regexp-p)
"Do incremental search forward on the current article.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master d932e256a4: Extract `gnus-collect-urls-from-article' from `gnus-summary-browse-url',
Sam Steingold <=