]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: A prefix argument kills rather than browsing URLs
authorDavid Edmondson <dme@dme.org>
Mon, 2 Dec 2019 10:48:05 +0000 (10:48 +0000)
committerDavid Bremner <david@tethera.net>
Tue, 3 Dec 2019 11:41:38 +0000 (07:41 -0400)
In `notmuch-show', the "B" key (notmuch-show-browse-urls) will kill
the URL if called with a prefix argument rather than browsing
directly.

emacs/notmuch-show.el

index e13ca3d76c50c8c2e73012c835ea2014cb81fb55..ef2bf1e0f44bd25ee41e95b39993aca61078359e 100644 (file)
@@ -2540,12 +2540,16 @@ message."
        (push (match-string-no-properties 0) urls))
      (reverse urls))))
 
        (push (match-string-no-properties 0) urls))
      (reverse urls))))
 
-(defun notmuch-show-browse-urls ()
-  "Offer to browse any URLs in the current message."
-  (interactive)
-  (let ((urls (notmuch-show--gather-urls)))
+(defun notmuch-show-browse-urls (&optional kill)
+  "Offer to browse any URLs in the current message.
+With a prefix argument, copy the URL to the kill ring rather than
+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."))))
 
 (provide 'notmuch-show)
       (message "No URLs found."))))
 
 (provide 'notmuch-show)