]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.el
notmuch.el: Move "show next thread" from magic-space-bar to archive-thread
[notmuch] / notmuch.el
index c59b40db76d034887f8710922d3e459647e9c971..e15921bca1a4274302aad0962f773decb1726d77 100644 (file)
          (notmuch-show-set-tags (delete tag tags))))))
 
 (defun notmuch-show-archive-thread ()
-  "Archive each message currrently shown by removing the \"inbox\" tag from each.
+  "Archive each message in thread, and show next thread from search.
 
-This command is safe from any race condition of new messages
+Archive each message currrently shown by removing the \"inbox\"
+tag from each. Then kill this buffer and show the next thread
+from the search from which this thread was originally shown.
+
+Note: This command is safe from any race condition of new messages
 being delivered to the same thread. It does not archive the
 entire thread, but only the messages shown in the current
 buffer."
@@ -116,7 +120,13 @@ buffer."
       (if (not (eobp))
          (forward-char))
       (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
-         (goto-char (point-max))))))
+         (goto-char (point-max)))))
+  (let ((parent-buffer notmuch-show-parent-buffer))
+    (kill-this-buffer)
+    (if parent-buffer
+       (progn
+         (switch-to-buffer parent-buffer)
+         (notmuch-search-show-thread)))))
 
 (defun notmuch-show-move-to-current-message-summary-line ()
   "Move to the beginning of the one-line summary of the current message.
@@ -199,7 +209,9 @@ message and advance to the next message.
 
 Finally, if there is no further message to advance to, and this
 last message is already read, then archive the entire current
-thread, (remove the \"inbox\" tag from each message)."
+thread, (remove the \"inbox\" tag from each message). Also kill
+this buffer, and display the next thread from the search from
+which this thread was originally shown."
   (interactive)
   (let ((next (notmuch-show-find-next-message))
        (unread (member "unread" (notmuch-show-get-tags))))
@@ -364,12 +376,17 @@ view, (remove the \"inbox\" tag from each), with
        mode-name "notmuch-show")
   (setq buffer-read-only t))
 
-(defun notmuch-show (thread-id)
-  "Run \"notmuch show\" with the given thread ID and display results."
+(defun notmuch-show (thread-id &optional parent-buffer)
+  "Run \"notmuch show\" with the given thread ID and display results.
+
+The optional PARENT-BUFFER is the notmuch-search buffer from
+which this notmuch-show command was executed, (so that the next
+thread from that buffer can be show when done with this one)."
   (interactive "sNotmuch show: ")
   (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))
     (switch-to-buffer buffer)
     (notmuch-show-mode)
+    (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
     (let ((proc (get-buffer-process (current-buffer)))
          (inhibit-read-only t))
       (if proc
@@ -480,7 +497,7 @@ global search.
   (interactive)
   (let ((thread-id (notmuch-search-find-thread-id)))
     (forward-line)
-    (notmuch-show thread-id)))
+    (notmuch-show thread-id (current-buffer))))
 
 (defun notmuch-call-notmuch-process (&rest args)
   (let ((error-buffer (get-buffer-create "*Notmuch errors*")))