[PATCH] This patch is a little finger excercise for working with git. I found a piece...
[notmuch-archives.git] / 15 / 76de60eadc2af7b3d032d7b8a5d2cfb7c3939c
1 Return-Path: <racin@free.fr>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 75E0D40DDD9\r
6         for <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 07:12:06 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.899\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001]\r
13         autolearn=ham\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 3rnnmz0L52A1 for <notmuch@notmuchmail.org>;\r
17         Fri, 12 Nov 2010 07:11:55 -0800 (PST)\r
18 Received: from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3])\r
19         by olra.theworths.org (Postfix) with ESMTP id C8EAA40DDCD\r
20         for <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 07:11:53 -0800 (PST)\r
21 Received: from racin (unknown [82.239.207.166])\r
22         by smtp3-g21.free.fr (Postfix) with ESMTP id 601F1A6210\r
23         for <notmuch@notmuchmail.org>; Fri, 12 Nov 2010 16:11:47 +0100 (CET)\r
24 From: Matthieu Lemerre <racin@free.fr>\r
25 To: notmuch@notmuchmail.org\r
26 Subject: [PATCH] How to improve the mail handling workflow?\r
27 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.2.1\r
28         (i486-pc-linux-gnu)\r
29 Date: Fri, 12 Nov 2010 16:23:58 +0100\r
30 Message-ID: <87fwv65zw1.fsf@free.fr>\r
31 MIME-Version: 1.0\r
32 Content-Type: multipart/mixed; boundary="=-=-="\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.13\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37         <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
39         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Fri, 12 Nov 2010 15:12:06 -0000\r
46 \r
47 --=-=-=\r
48 \r
49 \r
50 Hi,\r
51 \r
52 I think that there are several irritating nitpicks when using notmuch in\r
53 a typical mail workflow.\r
54 \r
55 I don't know how other people process their email. I for myself use the\r
56 following method:\r
57 \r
58 1. The script I use to fetch new mails tries to add tags if it can. For\r
59    instance, all new mails from the notmuch mailing lists appears with\r
60    tags "(inbox,unread,notmuch)".\r
61 \r
62 2. When processing mails, I manually add some tag to the mails for which\r
63    no tags were added automatically. Then I archive the mail (remove its\r
64    inbox tag).\r
65 \r
66 3. Sometimes I keep mails in my inbox, for instance if I am expecting a\r
67    specific mail and do not want to take the time to process the others.\r
68 \r
69 The emacs interface to notmuch gets in my way in at least several\r
70 manners:\r
71 \r
72  - I often find myself hitting the spacebar too much, which ends up with\r
73    some of my new messages being removed from all of their tags, which\r
74    make them very difficult to find. I don't think the spacebar should\r
75    remove the inbox tag at all. It should only change the unread tag.\r
76 \r
77  - It does not provide a command for deleting mails. We were several\r
78    people who provided patches to add a 'd' keybinding to support\r
79    deletion. I provided a complex patch for that (that added "and not\r
80    tag:deleted" to all requests", but I now think that just adding a\r
81    "deleted" tag and removing the "inbox" tag would be sufficient).\r
82 \r
83  - Processing mails which do not have any automatically added tag is\r
84    boring, because I need to press several keys to archive them: "+" to\r
85    add a tag, and then "a". If I forget about +, then my mail is\r
86    impossible to find.\r
87 \r
88 Here is first a patch that copes with this last point. Whenever you want\r
89 to archive a thread, it finds whether you forgot to add a custom "user"\r
90 tag to a message, and if so asks you for a tag to add before\r
91 archiving. That way, I no longer have messages without any tags.\r
92 \r
93 I probably will send patches to handle the other bullet points to, but\r
94 first I would be happy to hear your comments about this, or learn about\r
95 how you process your mail using the current interface.\r
96 \r
97 Thanks,\r
98 Matthieu Lemerre\r
99 \r
100 \r
101 --=-=-=\r
102 Content-Type: text/x-diff\r
103 Content-Disposition: inline; filename=out.patch\r
104 \r
105 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
106 index d8773e6..57ff72e 100644\r
107 --- a/emacs/notmuch-show.el\r
108 +++ b/emacs/notmuch-show.el\r
109 @@ -1054,11 +1054,35 @@ argument, hide all of the messages."\r
110    (interactive)\r
111    (backward-button 1))\r
112  \r
113 +(defun notmuch-is-user-tag (tag)\r
114 +  ;; Returns true if tag is not one of \r
115 +  ;; inbox, deleted, replied, draft, \r
116 +  (not (member tag '("inbox" "replied" "draft" "deleted" \r
117 +                   "attachment" "unread"))))\r
118 +\r
119  (defun notmuch-show-archive-thread-internal (show-next)\r
120    ;; Remove the tag from the current set of messages.\r
121    (goto-char (point-min))\r
122 -  (loop do (notmuch-show-remove-tag "inbox")\r
123 -       until (not (notmuch-show-goto-message-next)))\r
124 +  (let ((has-empty-tags))\r
125 +    ;; 1st pass: try to see if adding a tag is necessary.\r
126 +    (loop do (let ((user-tags (remove-if-not #'notmuch-is-user-tag \r
127 +                                            (notmuch-show-get-tags))))\r
128 +              (setq has-empty-tags \r
129 +                    (or has-empty-tags (eq user-tags nil))))\r
130 +         until (not (notmuch-show-goto-message-next)))\r
131 +    ;; Only ask for a tag to add if has-empty-tags is non-nil. Use\r
132 +    ;; tags-to-apply to propose a default value.\r
133 +    (let ((tags-to-add '()))\r
134 +      (if has-empty-tags\r
135 +         (setq tags-to-add (list (notmuch-select-tag-with-completion \r
136 +                                  "Some messages in the thread have no user tags. Add: "))))\r
137 +      ;; 2nd pass: tag all the messages with the user-selected tag,\r
138 +      ;; and remove the "inbox" tag\r
139 +      (goto-char (point-min))\r
140 +      (loop do (progn \r
141 +                (apply #'notmuch-show-add-tag tags-to-add)\r
142 +                (notmuch-show-remove-tag "inbox"))\r
143 +         until (not (notmuch-show-goto-message-next)))))\r
144    ;; Move to the next item in the search results, if any.\r
145    (let ((parent-buffer notmuch-show-parent-buffer))\r
146      (notmuch-kill-this-buffer)\r
147 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
148 index 5933747..eeff18c 100644\r
149 --- a/emacs/notmuch.el\r
150 +++ b/emacs/notmuch.el\r
151 @@ -560,7 +560,9 @@ thread or threads in the current region."\r
152  \r
153  This function advances the next thread when finished."\r
154    (interactive)\r
155 -  (notmuch-search-remove-tag-thread "inbox")\r
156 +  (save-excursion\r
157 +    (notmuch-search-show-thread)\r
158 +    (notmuch-show-archive-thread-internal nil))\r
159    (forward-line))\r
160  \r
161  (defun notmuch-search-process-sentinel (proc msg)\r
162 \r
163 --=-=-=--\r