1 From: "Keith Packard" <keithp@keithp.com>
2 To: notmuch@notmuchmail.org
3 Date: Tue, 17 Nov 2009 13:32:45 -0800
4 Subject: [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove
5 inbox (and unread) tags
6 Message-ID: <1258493565-13508-1-git-send-email-keithp@keithp.com>
8 When closing a thread view, mark the thread as archived by removing
9 the "inbox" tag, and for the 'x' variant, the "unread" tag as well,
10 then kill the buffer and update the search window view as well.
12 This makes 'x' much the same as 'a', but instead of taking you to the
13 next message, it takes you back to the search window instead.
15 Signed-off-by: Keith Packard <keithp at keithp.com>
17 notmuch.el | 86 ++++++++++++++++++++++++++++++++++++++++++++++-------------
18 1 files changed, 67 insertions(+), 19 deletions(-)
20 diff --git a/notmuch.el b/notmuch.el
21 index 638d49d..7b0d72c 100644
25 ; Will be much preferable to switch to direct manipulation for
26 ; toggling visibility of these components. Probably using
27 ; overlays-at to query and manipulate the current overlay.
28 - (define-key map "a" 'notmuch-show-archive-thread)
29 - (define-key map "A" 'notmuch-show-mark-read-then-archive-thread)
30 + (define-key map "a" 'notmuch-show-mark-read-archive-thread-next-thread)
31 + (define-key map "A" 'notmuch-show-archive-thread-next-thread)
32 (define-key map "b" 'notmuch-show-toggle-body-read-visible)
33 (define-key map "c" 'notmuch-show-toggle-citations-visible)
34 (define-key map "h" 'notmuch-show-toggle-headers-visible)
36 (define-key map "s" 'notmuch-show-toggle-signatures-visible)
37 (define-key map "v" 'notmuch-show-view-all-mime-parts)
38 (define-key map "w" 'notmuch-show-view-raw-message)
39 - (define-key map "x" 'kill-this-buffer)
40 + (define-key map "x" 'notmuch-show-mark-read-archive-thread-kill-buffer)
41 + (define-key map "X" 'notmuch-show-archive-thread-kill-buffer)
42 (define-key map "+" 'notmuch-show-add-tag)
43 (define-key map "-" 'notmuch-show-remove-tag)
44 (define-key map (kbd "DEL") 'notmuch-show-rewind)
45 @@ -183,7 +184,33 @@ Unlike builtin `next-line' this version accepts no arguments."
46 (cons (notmuch-show-get-message-id) nil)))
47 (notmuch-show-set-tags (sort (set-difference tags toremove :test 'string=) 'string<))))))
49 -(defun notmuch-show-archive-thread-maybe-mark-read (markread)
50 +(defun notmuch-show-next-thread (markread)
51 + (let ((parent-buffer notmuch-show-parent-buffer))
55 + (switch-to-buffer parent-buffer)
57 + (notmuch-search-show-thread)))))
59 +(defun notmuch-delete-tags (to-remove from)
61 + (delete (car to-remove) (notmuch-delete-tags (cdr to-remove) from))
64 +(defun notmuch-kill-message-buffer (markread)
65 + (let ((parent-buffer notmuch-show-parent-buffer))
69 + (switch-to-buffer parent-buffer)
70 + (let ((tags (notmuch-search-get-tags)))
71 + (setq tags (delete "inbox" tags))
72 + (if markread (setq tags (delete "unread" tags)))
73 + (notmuch-search-set-tags tags))
76 +(defun notmuch-show-archive-thread-maybe-mark-read (markread shownext)
78 (goto-char (point-min))
80 @@ -194,15 +221,9 @@ Unlike builtin `next-line' this version accepts no arguments."
82 (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
83 (goto-char (point-max)))))
84 - (let ((parent-buffer notmuch-show-parent-buffer))
88 - (switch-to-buffer parent-buffer)
90 - (notmuch-search-show-thread)))))
91 + (if shownext (notmuch-show-next-thread markread) (notmuch-kill-message-buffer markread)))
93 -(defun notmuch-show-mark-read-then-archive-thread ()
94 +(defun notmuch-show-mark-read-archive-thread-next-thread ()
95 "Remove \"unread\" tag from each message, then archive and show next thread.
97 Archive each message currrently shown by removing the \"unread\"
98 @@ -215,9 +236,22 @@ being delivered to the same thread. It does not archive the
99 entire thread, but only the messages shown in the current
102 - (notmuch-show-archive-thread-maybe-mark-read t))
103 + (notmuch-show-archive-thread-maybe-mark-read t t))
105 +(defun notmuch-show-mark-read-archive-thread-kill-buffer ()
106 + "Remove \"unread\" tag from each message, then archive and kill the buffer.
108 +Archive each message currrently shown by removing the \"unread\"
109 +and \"inbox\" tag from each. Then kill this buffer.
111 +Note: This command is safe from any race condition of new messages
112 +being delivered to the same thread. It does not archive the
113 +entire thread, but only the messages shown in the current
116 + (notmuch-show-archive-thread-maybe-mark-read t nil))
118 -(defun notmuch-show-archive-thread ()
119 +(defun notmuch-show-archive-thread-next-thread ()
120 "Archive each message in thread, and show next thread from search.
122 Archive each message currrently shown by removing the \"inbox\"
123 @@ -229,7 +263,20 @@ being delivered to the same thread. It does not archive the
124 entire thread, but only the messages shown in the current
127 - (notmuch-show-archive-thread-maybe-mark-read nil))
128 + (notmuch-show-archive-thread-maybe-mark-read nil t))
130 +(defun notmuch-show-archive-thread-kill-buffer ()
131 + "Archive each message in thread, and kill the thread buffer.
133 +Archive each message currrently shown by removing the \"inbox\"
134 +tag from each. Then kill this buffer.
136 +Note: This command is safe from any race condition of new messages
137 +being delivered to the same thread. It does not archive the
138 +entire thread, but only the messages shown in the current
141 + (notmuch-show-archive-thread-maybe-mark-read nil t))
143 (defun notmuch-show-view-raw-message ()
144 "View the raw email of the current message."
145 @@ -297,7 +344,7 @@ by searching backward)."
146 (not (re-search-forward notmuch-show-message-begin-regexp nil t)))))
148 (defun notmuch-show-message-unread-p ()
149 - "Preficate testing whether current message is unread."
150 + "Predicate testing whether current message is unread."
151 (member "unread" (notmuch-show-get-tags)))
153 (defun notmuch-show-next-message ()
154 @@ -434,7 +481,7 @@ which this thread was originally shown."
155 (let ((last (notmuch-show-last-message-p)))
156 (notmuch-show-mark-read-then-next-open-message)
158 - (notmuch-show-archive-thread))))))
159 + (notmuch-show-archive-thread-next-thread))))))
161 (defun notmuch-show-markup-citations-region (beg end depth)
163 @@ -618,8 +665,9 @@ messages. Each time you navigate away from a message with
165 You can add or remove tags from the current message with '+' and
166 '-'. You can also archive all messages in the current
167 -view, (remove the \"inbox\" tag from each), with
168 -`notmuch-show-archive-thread' (bound to 'a' by default).
169 +view, (remove the \"inbox\" tag from each), with either
170 +`notmuch-show-archive-thread-next-thread' (bound to 'a' by default) or
171 +`notmuch-show-archive-thread-kill-buffer' (bound to 'x' by default).
173 \\{notmuch-show-mode-map}"