diff options
| author | Sam Steingold | 2022-03-11 13:59:46 -0500 |
|---|---|---|
| committer | Sam Steingold | 2022-03-14 11:28:02 -0400 |
| commit | f52dcfd03ad542704d9a43faab0c33be09ab442e (patch) | |
| tree | f0ab791085b58e7b8421151bdb27c77f4bc6bb3e | |
| parent | a359a9dfd4439f2d8bf8c2fe1b9862ab00d69b6c (diff) | |
| download | emacs-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/NEWS | 5 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 57 |
2 files changed, 40 insertions, 22 deletions
| @@ -699,6 +699,11 @@ displayed as emojis. Default nil. | |||
| 699 | This is bound to 'W D e' and will display symbols that have emoji | 699 | This is bound to 'W D e' and will display symbols that have emoji |
| 700 | representation as emojis. | 700 | representation as emojis. |
| 701 | 701 | ||
| 702 | +++ | ||
| 703 | *** New command 'gnus-summary-browse-all-urls'. | ||
| 704 | This is for the rare cases when you want to open _all_ the URLs in the | ||
| 705 | article, 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. | ||
| 9452 | See '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 | ||
| 9462 | Links are opened using `browse-url' unless a prefix argument is | 9474 | Links are opened using `browse-url' unless a prefix argument is |
| 9463 | given: Then `browse-url-secondary-browser-function' is used instead. | 9475 | given: then `browse-url-secondary-browser-function' is used instead. |
| 9464 | 9476 | ||
| 9465 | If only one link is found, browse that directly, otherwise use | 9477 | If only one link is found, browse that directly, otherwise use |
| 9466 | completion to select a link. The first link marked in the | 9478 | completion to select a link. The first link marked in the |
| 9467 | article text with `gnus-collect-urls-primary-text' is the | 9479 | article text with `gnus-collect-urls-primary-text' is the |
| 9468 | default." | 9480 | default." |
| 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 | 9498 | Links are opened using `browse-url' unless a prefix argument is |
| 9487 | (funcall browse-url-secondary-browser-function target) | 9499 | given: 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. |