[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f52dcfd03a: New command `gnus-summary-browse-all-urls' bound to "
From: |
Sam Steingold |
Subject: |
master f52dcfd03a: New command `gnus-summary-browse-all-urls' bound to "v" |
Date: |
Mon, 14 Mar 2022 11:28:41 -0400 (EDT) |
branch: master
commit f52dcfd03ad542704d9a43faab0c33be09ab442e
Author: Sam Steingold <sds@gnu.org>
Commit: Sam Steingold <sds@gnu.org>
New command `gnus-summary-browse-all-urls' bound to "v"
* lisp/gnus-sum.el (gnus-collect-urls-from-article): New function,
extracted from `gnus-summary-browse-url'.
(gnus-summary-browse-url): Use it; also use `browse-url-button-open-url'
to handle the prefix argument.
(gnus-summary-browse-all-urls): New command.
(gnus-summary-mode-map): Bind `gnus-summary-browse-all-urls' to "v".
---
etc/NEWS | 5 +++++
lisp/gnus/gnus-sum.el | 57 +++++++++++++++++++++++++++++++--------------------
2 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index d6b5da3902..fc6c8b8254 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -699,6 +699,11 @@ displayed as emojis. Default nil.
This is bound to 'W D e' and will display symbols that have emoji
representation as emojis.
++++
+*** New command 'gnus-summary-browse-all-urls'.
+This is for the rare cases when you want to open _all_ the URLs in the
+article, and is bound to "v".
+
** EIEIO
+++
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 1be5a48068..098d3a067d 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -2010,6 +2010,7 @@ increase the score of each group you read."
"s" #'gnus-summary-isearch-article
"TAB" #'gnus-summary-button-forward
"<backtab>" #'gnus-summary-button-backward
+ "v" #'gnus-summary-browse-all-urls
"w" #'gnus-summary-browse-url
"t" #'gnus-summary-toggle-header
"g" #'gnus-summary-show-article
@@ -2196,6 +2197,7 @@ increase the score of each group you read."
"s" #'gnus-summary-isearch-article
"TAB" #'gnus-summary-button-forward
"<backtab>" #'gnus-summary-button-backward
+ "v" #'gnus-summary-browse-all-urls
"w" #'gnus-summary-browse-url
"P" #'gnus-summary-print-article
"S" #'gnus-sticky-article
@@ -9445,6 +9447,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)
@@ -9456,37 +9468,38 @@ The 1st element is the button named by
`gnus-collect-urls-primary-text'."
(concat "#" target)))))
(concat host (string-truncate-left rest (- max (length host)))))))
-(defun gnus-summary-browse-url (&optional external)
+(defun gnus-summary-browse-url (&optional _external)
"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
+ (browse-url-button-open-url target) ; this handles the prefix arg
+ (message "No URLs found."))))
+
+(defun gnus-summary-browse-all-urls (&optional _external)
+ "Scan the current article body for links, and browse them.
+
+Links are opened using `browse-url' unless a prefix argument is
+given: then `browse-url-secondary-browser-function' is used instead."
+ (interactive "P" gnus-summary-mode)
+ (dolist (url (gnus-collect-urls-from-article))
+ (browse-url-button-open-url url))) ; this handles the prefix arg
(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 f52dcfd03a: New command `gnus-summary-browse-all-urls' bound to "v",
Sam Steingold <=