mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 10:58:10 +01:00
notmuch.el: Fix notmuch-snow-next-message when on the last message.
Before this just brought the current line to the top of the window. Now it actually moves to the beginning of the current message. This is built on a much more solid foundation now with a function to move to the summary-line of the current message, and then moving from there.
This commit is contained in:
parent
fbf473220b
commit
253c11b675
1 changed files with 32 additions and 37 deletions
69
notmuch.el
69
notmuch.el
|
@ -114,52 +114,47 @@ buffer."
|
||||||
(if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
|
(if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
|
||||||
(goto-char (point-max))))))
|
(goto-char (point-max))))))
|
||||||
|
|
||||||
(defun notmuch-show-next-message ()
|
(defun notmuch-show-move-to-current-message-summary-line ()
|
||||||
"Advance point to the beginning of the next message in the buffer.
|
"Move to the beginning of the one-line summary of the current message.
|
||||||
|
|
||||||
Does nothing if already on the last message."
|
This gives us a stable place to move to and work from since the
|
||||||
(interactive)
|
summary line is always visible. This is important since moving to
|
||||||
; First, ensure we get off the current message marker
|
an invisible location is unreliable, (the main command loop moves
|
||||||
(if (not (eobp))
|
point either forward or backward to the next visible character
|
||||||
(forward-char))
|
when a command ends with point on an invisible character).
|
||||||
(re-search-forward notmuch-show-message-begin-regexp nil t)
|
|
||||||
; This dance might look pointless, but it's important. I originally
|
Emits an error if point is not within a valid message, (that is
|
||||||
; just had (beginning-of-line) here which looked right on the
|
not pattern of `notmuch-show-message-begin-regexp' could be found
|
||||||
; display but actually put point all the way back to the first
|
by searching backward)."
|
||||||
; 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)
|
(beginning-of-line)
|
||||||
|
(if (not (looking-at notmuch-show-message-begin-regexp))
|
||||||
|
(if (re-search-backward notmuch-show-message-begin-regexp nil t)
|
||||||
|
(forward-line 2)
|
||||||
|
(error "Not within a valid message."))
|
||||||
|
(forward-line 2)))
|
||||||
|
|
||||||
|
(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."
|
||||||
|
(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)
|
||||||
(recenter 0))
|
(recenter 0))
|
||||||
|
|
||||||
(defun notmuch-show-previous-message ()
|
(defun notmuch-show-previous-message ()
|
||||||
"Backup to the beginning of the previous message in the buffer.
|
"Backup to the beginning of the previous message in the buffer.
|
||||||
|
|
||||||
Does nothing if already on the first message in the buffer."
|
Moves to the beginning of the current message if already on the
|
||||||
|
first message in the buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
; First, ensure we get off the current message marker
|
(notmuch-show-move-to-current-message-summary-line)
|
||||||
(if (not (bobp))
|
; Go backward twice to skip the current message's marker
|
||||||
(previous-line))
|
|
||||||
(re-search-backward notmuch-show-message-begin-regexp nil t)
|
(re-search-backward notmuch-show-message-begin-regexp nil t)
|
||||||
; This dance might look pointless, but it's important. I originally
|
(re-search-backward notmuch-show-message-begin-regexp nil t)
|
||||||
; just had (beginning-of-line) here which looked right on the
|
(notmuch-show-move-to-current-message-summary-line)
|
||||||
; 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))
|
(recenter 0))
|
||||||
|
|
||||||
(defun notmuch-show-mark-read-then-next-message ()
|
(defun notmuch-show-mark-read-then-next-message ()
|
||||||
|
|
Loading…
Reference in a new issue