]> git.notmuchmail.org Git - notmuch/blobdiff - emacs/notmuch-show.el
Add a U binding to switch to unthreaded from other views
[notmuch] / emacs / notmuch-show.el
index e13ca3d76c50c8c2e73012c835ea2014cb81fb55..214e279fde2af643762f26b39138088e5e3217d6 100644 (file)
 (declare-function notmuch-count-attachments "notmuch" (mm-handle))
 (declare-function notmuch-save-attachments "notmuch" (mm-handle &optional queryp))
 (declare-function notmuch-tree "notmuch-tree"
-                 (&optional query query-context target buffer-name open-target))
+                 (&optional query query-context target buffer-name open-target unthreaded))
 (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
+(declare-function notmuch-unthreaded
+                 (&optional query query-context target buffer-name open-target))
 (declare-function notmuch-read-query "notmuch" (prompt))
 (declare-function notmuch-draft-resume "notmuch-draft" (id))
 
@@ -1471,6 +1473,7 @@ reset based on the original query."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-common-keymap)
     (define-key map "Z" 'notmuch-tree-from-show-current-query)
+    (define-key map "U" 'notmuch-unthreaded-from-show-current-query)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
     (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
@@ -1559,6 +1562,13 @@ All currently available key bindings:
                notmuch-show-query-context
                (notmuch-show-get-message-id)))
 
+(defun notmuch-unthreaded-from-show-current-query ()
+  "Call notmuch unthreaded with the current query"
+  (interactive)
+  (notmuch-unthreaded notmuch-show-thread-id
+                     notmuch-show-query-context
+                     (notmuch-show-get-message-id)))
+
 (defun notmuch-show-move-to-message-top ()
   (goto-char (notmuch-show-message-top)))
 
@@ -2540,12 +2550,16 @@ message."
        (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
-       (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)