]> git.notmuchmail.org Git - notmuch/blob - test/corpus/cur/13:2,
03cb3744e5f9f77b3f82918ef47924b2fb6446be
[notmuch] / test / corpus / cur / 13:2,
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>
7
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.
11
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.
14
15 Signed-off-by: Keith Packard <keithp at keithp.com>
16 ---
17  notmuch.el |   86 ++++++++++++++++++++++++++++++++++++++++++++++-------------
18  1 files changed, 67 insertions(+), 19 deletions(-)
19
20 diff --git a/notmuch.el b/notmuch.el
21 index 638d49d..7b0d72c 100644
22 --- a/notmuch.el
23 +++ b/notmuch.el
24 @@ -31,8 +31,8 @@
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)
35 @@ -47,7 +47,8 @@
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<))))))
48  
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))
52 +    (kill-this-buffer)
53 +    (if parent-buffer
54 +       (progn
55 +         (switch-to-buffer parent-buffer)
56 +         (forward-line)
57 +         (notmuch-search-show-thread)))))
58 +  
59 +(defun notmuch-delete-tags (to-remove from)
60 +  (if to-remove
61 +      (delete (car to-remove) (notmuch-delete-tags (cdr to-remove) from))
62 +    from))
63 +
64 +(defun notmuch-kill-message-buffer (markread)
65 +  (let ((parent-buffer notmuch-show-parent-buffer))
66 +    (kill-this-buffer)
67 +    (if parent-buffer
68 +       (progn
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))
74 +         (forward-line)))))
75 +
76 +(defun notmuch-show-archive-thread-maybe-mark-read (markread shownext)
77    (save-excursion
78      (goto-char (point-min))
79      (while (not (eobp))
80 @@ -194,15 +221,9 @@ Unlike builtin `next-line' this version accepts no arguments."
81           (forward-char))
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))
85 -    (kill-this-buffer)
86 -    (if parent-buffer
87 -       (progn
88 -         (switch-to-buffer parent-buffer)
89 -         (forward-line)
90 -         (notmuch-search-show-thread)))))
91 +  (if shownext (notmuch-show-next-thread markread) (notmuch-kill-message-buffer markread)))
92  
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.
96  
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
100  buffer."
101    (interactive)
102 -  (notmuch-show-archive-thread-maybe-mark-read t))
103 +  (notmuch-show-archive-thread-maybe-mark-read t t))
104 +
105 +(defun notmuch-show-mark-read-archive-thread-kill-buffer ()
106 +  "Remove \"unread\" tag from each message, then archive and kill the buffer.
107 +
108 +Archive each message currrently shown by removing the \"unread\"
109 +and \"inbox\" tag from each. Then kill this buffer.
110 +
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
114 +buffer."
115 +  (interactive)
116 +  (notmuch-show-archive-thread-maybe-mark-read t nil))
117  
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.
121  
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
125  buffer."
126    (interactive)
127 -  (notmuch-show-archive-thread-maybe-mark-read nil))
128 +  (notmuch-show-archive-thread-maybe-mark-read nil t))
129 +
130 +(defun notmuch-show-archive-thread-kill-buffer ()
131 +  "Archive each message in thread, and kill the thread buffer.
132 +
133 +Archive each message currrently shown by removing the \"inbox\"
134 +tag from each. Then kill this buffer.
135 +
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
139 +buffer."
140 +  (interactive)
141 +  (notmuch-show-archive-thread-maybe-mark-read nil t))
142  
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)))))
147  
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)))
152  
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)
157         (if last
158 -           (notmuch-show-archive-thread))))))
159 +           (notmuch-show-archive-thread-next-thread))))))
160  
161  (defun notmuch-show-markup-citations-region (beg end depth)
162    (goto-char beg)
163 @@ -618,8 +665,9 @@ messages. Each time you navigate away from a message with
164  
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).
172  
173  \\{notmuch-show-mode-map}"
174    (interactive)
175 -- 
176 1.6.5.2
177
178