emacs: A prefix argument kills rather than browsing URLs

In `notmuch-show', the "B" key (notmuch-show-browse-urls) will kill
the URL if called with a prefix argument rather than browsing
directly.
This commit is contained in:
David Edmondson 2019-12-02 10:48:05 +00:00 committed by David Bremner
parent dc2b5a031b
commit a1139fb5ec

View file

@ -2540,12 +2540,16 @@ message."
(push (match-string-no-properties 0) urls)) (push (match-string-no-properties 0) urls))
(reverse urls)))) (reverse urls))))
(defun notmuch-show-browse-urls () (defun notmuch-show-browse-urls (&optional kill)
"Offer to browse any URLs in the current message." "Offer to browse any URLs in the current message.
(interactive) With a prefix argument, copy the URL to the kill ring rather than
(let ((urls (notmuch-show--gather-urls))) browsing."
(interactive "P")
(let ((urls (notmuch-show--gather-urls))
(prompt (if kill "Copy URL to kill ring: " "Browse URL: "))
(fn (if kill #'kill-new #'browse-url)))
(if urls (if urls
(browse-url (completing-read "Browse URL: " (cdr urls) nil nil (car urls))) (funcall fn (completing-read prompt (cdr urls) nil nil (car urls)))
(message "No URLs found.")))) (message "No URLs found."))))
(provide 'notmuch-show) (provide 'notmuch-show)