X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch.el;h=9bf272bed473fed9bec6c52ff404da42fa8b259d;hb=88810b999a478b6af796eb98b0cf35020ee50901;hp=e15921bca1a4274302aad0962f773decb1726d77;hpb=3effd82ace9bfb2fa1aa32bfcd054abf849a63c4;p=notmuch diff --git a/notmuch.el b/notmuch.el index e15921bc..9bf272be 100644 --- a/notmuch.el +++ b/notmuch.el @@ -150,12 +150,13 @@ by searching backward)." (defun notmuch-show-next-message () "Advance to the beginning of the next message in the buffer. -Moves to the beginning of the current message if already on the -last message in the buffer." +Moves to the end of the buffer if already on the last message in +the buffer." (interactive) (notmuch-show-move-to-current-message-summary-line) - (re-search-forward notmuch-show-message-begin-regexp nil t) - (notmuch-show-move-to-current-message-summary-line) + (if (re-search-forward notmuch-show-message-begin-regexp nil t) + (notmuch-show-move-to-current-message-summary-line) + (goto-char (point-max))) (recenter 0)) (defun notmuch-show-find-next-message () @@ -171,6 +172,15 @@ message in the buffer." (notmuch-show-next-message) (point)))) +(defun notmuch-show-next-unread-message () + "Advance to the beginning of the next unread message in the buffer. + +Does nothing if there are no more unread messages past the +current point." + (while (and (not (eobp)) + (not (member "unread" (notmuch-show-get-tags)))) + (notmuch-show-next-message))) + (defun notmuch-show-previous-message () "Backup to the beginning of the previous message in the buffer. @@ -218,9 +228,10 @@ which this thread was originally shown." (if (and (not unread) (equal next (point))) (notmuch-show-archive-thread) - (if (< (notmuch-show-find-next-message) (window-end)) - (notmuch-show-mark-read-then-next-message) - (scroll-up nil))))) + (if (and (> next (window-end)) + (< next (point-max))) + (scroll-up nil) + (notmuch-show-mark-read-then-next-message))))) (defun notmuch-show-markup-citations-region (beg end) (goto-char beg) @@ -398,6 +409,7 @@ thread from that buffer can be show when done with this one)." (call-process "notmuch" nil t nil "show" thread-id) (notmuch-show-markup-messages) ) + (notmuch-show-next-unread-message) ))) (defvar notmuch-search-mode-map @@ -428,7 +440,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 () @@ -497,7 +509,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*"))) @@ -569,12 +583,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 ()