aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2022-03-11 13:59:46 -0500
committerSam Steingold2022-03-14 11:28:02 -0400
commitf52dcfd03ad542704d9a43faab0c33be09ab442e (patch)
treef0ab791085b58e7b8421151bdb27c77f4bc6bb3e
parenta359a9dfd4439f2d8bf8c2fe1b9862ab00d69b6c (diff)
downloademacs-f52dcfd03ad542704d9a43faab0c33be09ab442e.tar.gz
emacs-f52dcfd03ad542704d9a43faab0c33be09ab442e.zip
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".
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/gnus/gnus-sum.el57
2 files changed, 40 insertions, 22 deletions
diff --git a/etc/NEWS b/etc/NEWS
index d6b5da3902e..fc6c8b82546 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -699,6 +699,11 @@ displayed as emojis. Default nil.
699This is bound to 'W D e' and will display symbols that have emoji 699This is bound to 'W D e' and will display symbols that have emoji
700representation as emojis. 700representation as emojis.
701 701
702+++
703*** New command 'gnus-summary-browse-all-urls'.
704This is for the rare cases when you want to open _all_ the URLs in the
705article, and is bound to "v".
706
702** EIEIO 707** EIEIO
703 708
704+++ 709+++
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 1be5a48068c..098d3a067d3 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."
2010 "s" #'gnus-summary-isearch-article 2010 "s" #'gnus-summary-isearch-article
2011 "TAB" #'gnus-summary-button-forward 2011 "TAB" #'gnus-summary-button-forward
2012 "<backtab>" #'gnus-summary-button-backward 2012 "<backtab>" #'gnus-summary-button-backward
2013 "v" #'gnus-summary-browse-all-urls
2013 "w" #'gnus-summary-browse-url 2014 "w" #'gnus-summary-browse-url
2014 "t" #'gnus-summary-toggle-header 2015 "t" #'gnus-summary-toggle-header
2015 "g" #'gnus-summary-show-article 2016 "g" #'gnus-summary-show-article
@@ -2196,6 +2197,7 @@ increase the score of each group you read."
2196 "s" #'gnus-summary-isearch-article 2197 "s" #'gnus-summary-isearch-article
2197 "TAB" #'gnus-summary-button-forward 2198 "TAB" #'gnus-summary-button-forward
2198 "<backtab>" #'gnus-summary-button-backward 2199 "<backtab>" #'gnus-summary-button-backward
2200 "v" #'gnus-summary-browse-all-urls
2199 "w" #'gnus-summary-browse-url 2201 "w" #'gnus-summary-browse-url
2200 "P" #'gnus-summary-print-article 2202 "P" #'gnus-summary-print-article
2201 "S" #'gnus-sticky-article 2203 "S" #'gnus-sticky-article
@@ -9445,6 +9447,16 @@ The 1st element is the button named by `gnus-collect-urls-primary-text'."
9445 (push primary urls)) 9447 (push primary urls))
9446 (delete-dups urls))) 9448 (delete-dups urls)))
9447 9449
9450(defun gnus-collect-urls-from-article ()
9451 "Select the article and return the list of URLs in it.
9452See 'gnus-collect-urls'."
9453 (gnus-summary-select-article)
9454 (gnus-with-article-buffer
9455 (article-goto-body)
9456 ;; Back up a char, in case body starts with a button.
9457 (backward-char)
9458 (gnus-collect-urls)))
9459
9448(defun gnus-shorten-url (url max) 9460(defun gnus-shorten-url (url max)
9449 "Return an excerpt from URL not exceeding MAX characters." 9461 "Return an excerpt from URL not exceeding MAX characters."
9450 (if (<= (length url) max) 9462 (if (<= (length url) max)
@@ -9456,37 +9468,38 @@ The 1st element is the button named by `gnus-collect-urls-primary-text'."
9456 (concat "#" target))))) 9468 (concat "#" target)))))
9457 (concat host (string-truncate-left rest (- max (length host))))))) 9469 (concat host (string-truncate-left rest (- max (length host)))))))
9458 9470
9459(defun gnus-summary-browse-url (&optional external) 9471(defun gnus-summary-browse-url (&optional _external)
9460 "Scan the current article body for links, and offer to browse them. 9472 "Scan the current article body for links, and offer to browse them.
9461 9473
9462Links are opened using `browse-url' unless a prefix argument is 9474Links are opened using `browse-url' unless a prefix argument is
9463given: Then `browse-url-secondary-browser-function' is used instead. 9475given: then `browse-url-secondary-browser-function' is used instead.
9464 9476
9465If only one link is found, browse that directly, otherwise use 9477If only one link is found, browse that directly, otherwise use
9466completion to select a link. The first link marked in the 9478completion to select a link. The first link marked in the
9467article text with `gnus-collect-urls-primary-text' is the 9479article text with `gnus-collect-urls-primary-text' is the
9468default." 9480default."
9469 (interactive "P" gnus-summary-mode) 9481 (interactive "P" gnus-summary-mode)
9470 (let (urls target) 9482 (let* ((urls (gnus-collect-urls-from-article))
9471 (gnus-summary-select-article) 9483 (target
9472 (gnus-with-article-buffer 9484 (cond ((= (length urls) 1)
9473 (article-goto-body) 9485 (car urls))
9474 ;; Back up a char, in case body starts with a button. 9486 ((> (length urls) 1)
9475 (backward-char) 9487 (completing-read
9476 (setq urls (gnus-collect-urls)) 9488 (format-prompt "URL to browse"
9477 (setq target 9489 (gnus-shorten-url (car urls) 40))
9478 (cond ((= (length urls) 1) 9490 urls nil t nil nil (car urls))))))
9479 (car urls)) 9491 (if target
9480 ((> (length urls) 1) 9492 (browse-url-button-open-url target) ; this handles the prefix arg
9481 (completing-read 9493 (message "No URLs found."))))
9482 (format-prompt "URL to browse" 9494
9483 (gnus-shorten-url (car urls) 40)) 9495(defun gnus-summary-browse-all-urls (&optional _external)
9484 urls nil t nil nil (car urls))))) 9496 "Scan the current article body for links, and browse them.
9485 (if target 9497
9486 (if external 9498Links are opened using `browse-url' unless a prefix argument is
9487 (funcall browse-url-secondary-browser-function target) 9499given: then `browse-url-secondary-browser-function' is used instead."
9488 (browse-url target)) 9500 (interactive "P" gnus-summary-mode)
9489 (message "No URLs found."))))) 9501 (dolist (url (gnus-collect-urls-from-article))
9502 (browse-url-button-open-url url))) ; this handles the prefix arg
9490 9503
9491(defun gnus-summary-isearch-article (&optional regexp-p) 9504(defun gnus-summary-isearch-article (&optional regexp-p)
9492 "Do incremental search forward on the current article. 9505 "Do incremental search forward on the current article.