From: Carl Worth Date: Thu, 3 Dec 2009 15:37:40 +0000 (-0800) Subject: emacs: Fix notmuch-show-next-open-message. X-Git-Tag: 0.1~243 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=e1f05f1c20b1ff582cbe150cefe39fd9aea64907;hp=48a1b8b0060c02d0ba111e3fc8a953bdc088cb88 emacs: Fix notmuch-show-next-open-message. This function was still implemented in terms of the old, global toggle for visibility of unread messages, (which no longer exists). Fix it to use the local 'invisibility-spec property on the button controlling message visibility. --- diff --git a/notmuch.el b/notmuch.el index 7bbaaefa..744f4d3c 100644 --- a/notmuch.el +++ b/notmuch.el @@ -411,19 +411,32 @@ by searching backward)." "Predicate testing whether current message is unread." (member "unread" (notmuch-show-get-tags))) +(defun notmuch-show-message-open-p () + "Predicate testing whether current message is open (body is visible)." + (let ((btn (previous-button (point) t))) + (while (not (button-has-type-p btn 'notmuch-button-body-toggle-type)) + (setq btn (previous-button (button-start btn)))) + (not (invisible-p (button-get btn 'invisibility-spec))))) + (defun notmuch-show-next-message () "Advance to the beginning of the next message in the buffer. Moves to the last visible character of the current message if -already on the last message in the buffer." +already on the last message in the buffer. + +Returns nil if already on the last message in the buffer." (interactive) (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) + (progn + (notmuch-show-move-to-current-message-summary-line) + (recenter 0) + t) (goto-char (- (point-max) 1)) (while (point-invisible-p) - (backward-char))) - (recenter 0)) + (backward-char)) + (recenter 0) + nil)) (defun notmuch-show-find-next-message () "Returns the position of the next message in the buffer. @@ -451,14 +464,9 @@ there are no more unread messages past the current point." (notmuch-show-next-message))) (defun notmuch-show-next-open-message () - "Advance to the next message which is not hidden. - -If read messages are currently hidden, advance to the next unread -message. Otherwise, advance to the next message." - (if (or (memq 'notmuch-show-body-read buffer-invisibility-spec) - (assq 'notmuch-show-body-read buffer-invisibility-spec)) - (notmuch-show-next-unread-message) - (notmuch-show-next-message))) + "Advance to the next open message (that is, body is not invisible)." + (while (and (notmuch-show-next-message) + (not (notmuch-show-message-open-p))))) (defun notmuch-show-previous-message () "Backup to the beginning of the previous message in the buffer.