[PATCH WIP v2 3/6] emacs: show: sync seen to read on quit and refresh

Mark Walters markwalters1009 at gmail.com
Sun Dec 1 02:02:24 PST 2013


This makes notmuch show buffers mark all seen messages as read when
quitting or refreshing the show buffer, accept in the case these are
called with a prefix argument.

This slightly overloads the prefix-argument to refresh: as it tells
refresh not to save state either. This is probably OK as it says "make
the buffer look like the database".

Note, at this point the seen functionality is not yet used: that is
nothing yet marks a message seen.
---
 emacs/notmuch-show.el |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index c63d295..05f649b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1213,6 +1213,11 @@ preferences. If invoked with a prefix argument (or RESET-STATE is
 non-nil) then the state of the buffer (open/closed messages) is
 reset based on the original query."
   (interactive "P")
+  ;; Do not mark seen messages read if we are resetting state. The
+  ;; idea is that resetting state is asking for the view to be reset
+  ;; to the current state of the database.
+  (notmuch-show-mark-all-seen-read reset-state)
+
   (let ((inhibit-read-only t)
 	(state (unless reset-state
 		 (notmuch-show-capture-state))))
@@ -1258,6 +1263,8 @@ reset based on the original query."
 (defvar notmuch-show-mode-map
       (let ((map (make-sparse-keymap)))
 	(set-keymap-parent map notmuch-common-keymap)
+	;; the following overrides the common-keymap quit
+	(define-key map [remap notmuch-kill-this-buffer] 'notmuch-show-quit-and-mark-read)
 	(define-key map "Z" 'notmuch-tree-from-show-current-query)
 	(define-key map (kbd "<C-tab>") 'widget-backward)
 	(define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
@@ -1570,6 +1577,14 @@ we are not marking them."
 	      ((= count 0)
 	       (message "No messages marked read")))))))
 
+(put 'notmuch-show-quit-and-mark-read 'notmuch-prefix-doc
+     "... without marking seen messages read.")
+(defun notmuch-show-quit-and-mark-read (&optional not-mark)
+  "Kill the current buffer marking seen messages read."
+  (interactive "P")
+  (notmuch-show-mark-all-seen-read not-mark)
+  (notmuch-kill-this-buffer))
+
 ;; Functions for getting attributes of several messages in the current
 ;; thread.
 
-- 
1.7.9.1



More information about the notmuch mailing list