]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.el
notmuch.el: Leave a blank line after last thread in search.
[notmuch] / notmuch.el
index 747f60c4dad7c0cddce7bd2ff33801eefa527e49..16ca037ed5573757280116f82e04b72503c856ed 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.
@@ -207,14 +217,7 @@ which this thread was originally shown."
        (unread (member "unread" (notmuch-show-get-tags))))
     (if (and (not unread)
             (equal next (point)))
-       (progn
-         (notmuch-show-archive-thread)
-         (let ((parent-buffer notmuch-show-parent-buffer))
-           (kill-this-buffer)
-           (if parent-buffer
-               (progn
-                 (switch-to-buffer parent-buffer)
-                 (notmuch-search-show-thread)))))
+       (notmuch-show-archive-thread)
       (if (< (notmuch-show-find-next-message) (window-end))
          (notmuch-show-mark-read-then-next-message)
        (scroll-up nil)))))
@@ -425,7 +428,7 @@ thread from that buffer can be show when done with this one)."
   "Move point to the last thread in the buffer."
   (interactive "^P")
   (end-of-buffer arg)
-  (beginning-of-line))
+  (forward-line -1))
 
 ;;;###autoload
 (defun notmuch-search-mode ()
@@ -494,7 +497,9 @@ global search.
   (interactive)
   (let ((thread-id (notmuch-search-find-thread-id)))
     (forward-line)
-    (notmuch-show thread-id (current-buffer))))
+    (if (> (length thread-id) 0)
+       (notmuch-show thread-id (current-buffer))
+      (error "End of search results"))))
 
 (defun notmuch-call-notmuch-process (&rest args)
   (let ((error-buffer (get-buffer-create "*Notmuch errors*")))
@@ -566,12 +571,6 @@ This function advances point to the next line when finished."
       (save-excursion
        (call-process "notmuch" nil t nil "search" query)
        (notmuch-search-markup-thread-ids)
-        ; A well-behaved program ends its output with a newline, but we
-        ; don't actually want the blank line at the end of the file.
-       (goto-char (point-max))
-       (if (looking-at "^$")
-           (delete-backward-char 1)
-         )
        ))))
 
 (defun notmuch-search-refresh-view ()