- ; First, ensure we get off the current message marker
- (if (not (bobp))
- (previous-line))
- (re-search-backward notmuch-show-message-begin-regexp nil t)
- ; This dance might look pointless, but it's important. I originally
- ; just had (beginning-of-line) here which looked right on the
- ; display but actually put point all the way back to the first
- ; character of the first invisible line. That is, it put point into
- ; the closing markers of the previous message rather than at the
- ; beginning of the current message. And that in turn meant that
- ; looking up the current message-ID would actually return the
- ; previous message ID.
- ;
- ; So this dance ensures that we're actually on the current message
- ; when it looks like we are.
- (end-of-visible-line)
- (beginning-of-line)
- (recenter 0))
+ (let ((start (point)))
+ (notmuch-show-move-to-current-message-summary-line)
+ (if (not (< (point) start))
+ ; Go backward twice to skip the current message's marker
+ (progn
+ (re-search-backward notmuch-show-message-begin-regexp nil t)
+ (re-search-backward notmuch-show-message-begin-regexp nil t)
+ (notmuch-show-move-to-current-message-summary-line)
+ ))
+ (recenter 0)))
+
+(defun notmuch-show-mark-read-then-next-unread-message ()
+ "Remove unread tag from current message, then advance to next unread message."
+ (interactive)
+ (notmuch-show-remove-tag "unread")
+ (notmuch-show-next-unread-message))
+
+(defun notmuch-show-advance-marking-read-and-archiving ()
+ "Advance through buffer, marking read and archiving.
+
+This command is intended to be one of the simplest ways to
+process a thread of email. It does the following:
+
+If the current message in the thread is not yet fully visible,
+scroll by a near screenful to read more of the message.
+
+Otherwise, (the end of the current message is already within the
+current window), remove the \"unread\" tag from the current
+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). 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-unread-message))
+ (unread (member "unread" (notmuch-show-get-tags))))
+ (if (and (not unread)
+ (equal next (point)))
+ (notmuch-show-archive-thread)
+ (if (and (> next (window-end))
+ (< next (point-max)))
+ (scroll-up nil)
+ (notmuch-show-mark-read-then-next-unread-message)))))