+(defun notmuch-show-find-next-message ()
+ "Returns the position of the next message in the buffer.
+
+Or the end of the buffer if already within the last message in
+the buffer."
+ ; save-excursion doesn't save our window position
+ ; save-window-excursion doesn't save point
+ ; Looks like we have to use both.
+ (save-excursion
+ (save-window-excursion
+ (notmuch-show-next-message)
+ (point))))
+
+(defun notmuch-show-next-unread-message ()
+ "Advance to the beginning of the next unread message in the buffer.
+
+Moves to the end of the buffer 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-find-next-unread-message ()
+ "Returns the position of the next message in the buffer.
+
+Or the end of the buffer if there are no more unread messages
+past the current point."
+ ; save-excursion doesn't save our window position
+ ; save-window-excursion doesn't save point
+ ; Looks like we have to use both.
+ (save-excursion
+ (save-window-excursion
+ (notmuch-show-next-unread-message)
+ (point))))
+