database error
[notmuch-archives.git] / 05 / 61aba47e46303f7991e3c363250cf9e3dfbf32
1 Return-Path: <daniel.schoepe@googlemail.com>\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 AB331431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 16 May 2011 13:48:39 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 dXqnXphCwEBM for <notmuch@notmuchmail.org>;\r
17         Mon, 16 May 2011 13:48:38 -0700 (PDT)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 82E33431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 16 May 2011 13:48:38 -0700 (PDT)\r
23 Received: by fxm8 with SMTP id 8so3633955fxm.26\r
24         for <notmuch@notmuchmail.org>; Mon, 16 May 2011 13:48:37 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=googlemail.com; s=gamma;\r
27         h=domainkey-signature:from:to:subject:user-agent:date:message-id\r
28         :mime-version:content-type;\r
29         bh=dQUatwj5VDymTesho25Nt0rBXN/S3kVoMSPiQYUfV6s=;\r
30         b=dkcgNlup1dRvlHnfq0ygszMxFB5vjL3HWgsbuuLScTVDrzP1vMQhQc1P19Atz1EdCU\r
31         Jlzqytx8dVBT7hKP5DsTKUVaksJIGq7IhL4bTA4BrJDclq+yyHRHM+ibUu2LupeQoc4/\r
32         G1EsAPTVCTwx/docNCl4zphTGgq7UR7SpuQw4=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma;\r
34         h=from:to:subject:user-agent:date:message-id:mime-version\r
35         :content-type;\r
36         b=oSOXpSSK1sizbIkCEnhoGficGtfa259my4yiTCKNY4qwr4htjTMK61rs/0GmJNzFib\r
37         OvTGSyyveILrNorUx8Eoy+tHj9VUEpJhs4N6m1BjlKPAHw6Ud9EQLqxTvpqVZl2zghKn\r
38         4dd0CI3kD+WRqp8lgh56kZ5ccAIGEESfeNZSo=\r
39 Received: by 10.223.44.86 with SMTP id z22mr6051078fae.3.1305578917016;\r
40         Mon, 16 May 2011 13:48:37 -0700 (PDT)\r
41 Received: from localhost (dslb-088-069-136-251.pools.arcor-ip.net\r
42         [88.69.136.251])\r
43         by mx.google.com with ESMTPS id 22sm185741fay.45.2011.05.16.13.48.35\r
44         (version=TLSv1/SSLv3 cipher=OTHER);\r
45         Mon, 16 May 2011 13:48:35 -0700 (PDT)\r
46 From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
47 To: notmuch@notmuchmail.org\r
48 Subject: [PATCH] emacs: Add notmuch-before/after-tag-hook\r
49 User-Agent: Notmuch/0.5-209-gc8b5718 (http://notmuchmail.org) Emacs/23.3.1\r
50         (x86_64-pc-linux-gnu)\r
51 Date: Mon, 16 May 2011 22:48:24 +0200\r
52 Message-ID: <87pqnis76v.fsf@gilead.home.box>\r
53 MIME-Version: 1.0\r
54 Content-Type: multipart/signed; boundary="==-=-=";\r
55         micalg=pgp-sha1; protocol="application/pgp-signature"\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Mon, 16 May 2011 20:48:39 -0000\r
69 \r
70 --==-=-=\r
71 Content-Type: multipart/mixed; boundary="=-=-="\r
72 \r
73 --=-=-=\r
74 Content-Type: text/plain\r
75 Content-Transfer-Encoding: quoted-printable\r
76 \r
77 From=20the commit message:\r
78 \r
79     emacs: add notmuch-before- and notmuch-after-tag-hook\r
80 =20=20=20=20\r
81     This patch adds hooks that are run before/after messages are tagged\r
82     from the emacs interface.  In order to implement this and to avoid\r
83     having hooks parse all the arguments to the notmuch binary again, I\r
84     created a `notmuch-tag' function that other modules should use instead\r
85     of running (notmuch-call-notmuch-process "tag" ...) directly.\r
86 \r
87 I wasn't sure about adding the notmuch-tag function, but I think it is a\r
88 bit cleaner than calling notmuch-call-notmuch-process directly in so\r
89 many places anyway.\r
90 \r
91 Of course, any comments or criticism is appreciated.\r
92 \r
93 =2D- Daniel\r
94 \r
95 --=-=-=\r
96 Content-Type: text/x-diff\r
97 Content-Disposition: inline;\r
98  filename=0001-emacs-add-notmuch-before-and-notmuch-after-tag-hook.patch\r
99 Content-Transfer-Encoding: quoted-printable\r
100 \r
101 From=201acc99736a84e5294ba44368690dd79001e2e347 Mon Sep 17 00:00:00 2001\r
102 From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
103 Date: Sun, 15 May 2011 17:48:58 +0200\r
104 Subject: [PATCH] emacs: add notmuch-before- and notmuch-after-tag-hook\r
105 \r
106 This patch adds hooks that are run before/after messages are tagged\r
107 From=20the emacs interface.  In order to implement this and to avoid\r
108 having hooks parse all the arguments to the notmuch binary again, I\r
109 created a `notmuch-tag' function that other modules should use instead\r
110 of running (notmuch-call-notmuch-process "tag" ...) directly.\r
111 =2D--\r
112  emacs/notmuch-message.el |    3 +--\r
113  emacs/notmuch-show.el    |   12 ++++--------\r
114  emacs/notmuch.el         |   45 +++++++++++++++++++++++++++++++++++++++++-=\r
115 ---\r
116  3 files changed, 46 insertions(+), 14 deletions(-)\r
117 \r
118 diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el\r
119 index d5c96c2..aefd3fb 100644\r
120 =2D-- a/emacs/notmuch-message.el\r
121 +++ b/emacs/notmuch-message.el\r
122 @@ -44,8 +44,7 @@ the \"inbox\" and \"todo\", you would set\r
123                                  (concat "+" str)\r
124                                str))\r
125                           notmuch-message-replied-tags)))\r
126 =2D     (apply 'notmuch-call-notmuch-process "tag"\r
127 =2D            (append tags (list (concat "id:" (car (car rep)))) nil))))))\r
128 +       (apply 'notmuch-tag (concat "id:" (car (car rep))) tags)))))\r
129 =20\r
130  (add-hook 'message-send-hook 'notmuch-message-mark-replied)\r
131 =20\r
132 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
133 index 825988c..2b905c8 100644\r
134 =2D-- a/emacs/notmuch-show.el\r
135 +++ b/emacs/notmuch-show.el\r
136 @@ -1273,10 +1273,8 @@ the result."\r
137          (new-tags (notmuch-show-add-tags-worker current-tags toadd)))\r
138 =20\r
139      (unless (equal current-tags new-tags)\r
140 =2D      (apply 'notmuch-call-notmuch-process\r
141 =2D          (append (cons "tag"\r
142 =2D                        (mapcar (lambda (s) (concat "+" s)) toadd))\r
143 =2D                  (cons (notmuch-show-get-message-id) nil)))\r
144 +      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
145 +            (mapcar (lambda (s) (concat "+" s)) toadd))\r
146        (notmuch-show-set-tags new-tags))))\r
147 =20\r
148  (defun notmuch-show-remove-tag (&rest toremove)\r
149 @@ -1289,10 +1287,8 @@ the result."\r
150          (new-tags (notmuch-show-del-tags-worker current-tags toremove)))\r
151 =20\r
152      (unless (equal current-tags new-tags)\r
153 =2D      (apply 'notmuch-call-notmuch-process\r
154 =2D          (append (cons "tag"\r
155 =2D                        (mapcar (lambda (s) (concat "-" s)) toremove))\r
156 =2D                  (cons (notmuch-show-get-message-id) nil)))\r
157 +      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
158 +            (mapcar (lambda (s) (concat "-" s)) toremove))\r
159        (notmuch-show-set-tags new-tags))))\r
160 =20\r
161  (defun notmuch-show-toggle-headers ()\r
162 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
163 index 1d683f8..837136d 100644\r
164 =2D-- a/emacs/notmuch.el\r
165 +++ b/emacs/notmuch.el\r
166 @@ -465,6 +465,44 @@ and will also appear in a buffer named \"*Notmuch erro=\r
167 rs*\"."\r
168             (error (buffer-substring beg end))\r
169             ))))))\r
170 =20\r
171 +(defun notmuch-tag (query &rest tags)\r
172 +  "Add/remove tags in TAGS to messages matching QUERY.\r
173 +\r
174 +TAGS should be a list of strings of the form \"+TAG\" or \"-TAG\" and\r
175 +QUERY should be a string containing the search-query.\r
176 +\r
177 +Note: Other code should always use this function alter tags of\r
178 +messages instead of running (notmuch-call-notmuch-process \"tag\" ..)\r
179 +directly, so that hooks specified in notmuch-before-tag-hook and\r
180 +notmuch-after-tag-hook will be run."\r
181 +  (run-hooks 'notmuch-before-tag-hook)\r
182 +  (apply 'notmuch-call-notmuch-process\r
183 +        (append (list "tag") tags (list "--" query)))\r
184 +  (run-hooks 'notmuch-after-tag-hook))\r
185 +\r
186 +(defcustom notmuch-before-tag-hook nil\r
187 +  "Hooks that are run before tags of a message are modified.\r
188 +\r
189 +'tags' will contain the tags that are about to be added or removed as\r
190 +a list of strings of the form \"+TAG\" or \"-TAG\".\r
191 +'query' will be a string containing the search query that determines\r
192 +the messages that are about to be tagged"\r
193 +\r
194 +  :type 'hook\r
195 +  :options '(hl-line-mode)\r
196 +  :group 'notmuch)\r
197 +\r
198 +(defcustom notmuch-after-tag-hook nil\r
199 +  "Hooks that are run before tags of a message are modified.\r
200 +\r
201 +'tags' will contain the tags that were added or removed as\r
202 +a list of strings of the form \"+TAG\" or \"-TAG\".\r
203 +'query' will be a string containing the search query that determines\r
204 +the messages that were tagged"\r
205 +  :type 'hook\r
206 +  :options '(hl-line-mode)\r
207 +  :group 'notmuch)\r
208 +\r
209  (defun notmuch-search-set-tags (tags)\r
210    (save-excursion\r
211      (end-of-line)\r
212 @@ -504,7 +542,7 @@ and will also appear in a buffer named \"*Notmuch error=\r
213 s*\"."\r
214 =20\r
215  (defun notmuch-search-add-tag-region (tag beg end)\r
216    (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread=\r
217 -id-region beg end) " or ")))\r
218 =2D    (notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-strin=\r
219 g)\r
220 +    (notmuch-tag search-id-string (concat "+" tag))\r
221      (save-excursion\r
222        (let ((last-line (line-number-at-pos end))\r
223             (max-line (- (line-number-at-pos (point-max)) 2)))\r
224 @@ -518,7 +556,7 @@ and will also appear in a buffer named \"*Notmuch error=\r
225 s*\"."\r
226 =20\r
227  (defun notmuch-search-remove-tag-region (tag beg end)\r
228    (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread=\r
229 -id-region beg end) " or ")))\r
230 =2D    (notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-strin=\r
231 g)\r
232 +    (notmuch-tag search-id-string (concat "-" tag))\r
233      (save-excursion\r
234        (let ((last-line (line-number-at-pos end))\r
235             (max-line (- (line-number-at-pos (point-max)) 2)))\r
236 @@ -815,8 +853,7 @@ characters as well as `_.+-'.\r
237         (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
238           (error "Action must be of the form `+thistag -that_tag'"))\r
239         (setq words (cdr words))))\r
240 =2D    (apply 'notmuch-call-notmuch-process "tag"\r
241 =2D        (append action-split (list notmuch-search-query-string) nil))))\r
242 +    (apply 'notmuch-tag notmuch-search-query-string action-split)))\r
243 =20\r
244  (defun notmuch-search-buffer-title (query)\r
245    "Returns the title for a buffer with notmuch search results."\r
246 =2D-=20\r
247 1.7.5.1\r
248 \r
249 \r
250 --=-=-=--\r
251 \r
252 --==-=-=\r
253 Content-Type: application/pgp-signature\r
254 \r
255 -----BEGIN PGP SIGNATURE-----\r
256 Version: GnuPG v1.4.11 (GNU/Linux)\r
257 \r
258 iQIcBAEBAgAGBQJN0Y2ZAAoJEIaTAtce+Z+JAO8P/32zq9QfBtgD4yaGm5bpttMo\r
259 W5dwt4J+pUOhW5lRpEh4cAJXhLFpLL5ZO45fGcdhJyVuwsgbxfiCg9op833Noqad\r
260 4ATPKbsiyXOOM4ihfjlZlJjPm/23Rmtk7JinAoN76ltGp+J5sZdmVdan8A9uzreX\r
261 5wLtFiRCNAL/J60/ZlTNr3aXvNr2vlXfLKyGuVAarpiP0xhhjaCGk3GhTTfT/beb\r
262 w3sS/ZPM91II0Dm4u+M5nA1RVeesg04G8tS81mqrnnxIrB05Yun8riAUg/6sKMxD\r
263 lrCtOqf9Bs11P9IpFdHb446ATwS7etBKuErlSG2e+Q+cPHSKkkmGkSAogznMMpEY\r
264 sk2x7maauUlxw4/hb3vHWgE//uoHEVQgQd0+gmSwCsipM10Wn79kfVXNjxKcFrT1\r
265 v8u/iTQ/gsJ52bnbDORJJ/qlmigED+nsHPGTLekx/m9465G6+pw6jrRbgFrawAuU\r
266 EZImqHp47gIcK9wtQl38aNJYFpekm3zK1SQPjZw4dbTaWSryVvLXk1co9W9W+qvh\r
267 GWInRH37UE2CjKzCWmDAzrFKTq2Q7o2i2qWmTC+sWfbC349vmu2YxEpswy5sYbeA\r
268 24wBy7MUR8pYUIJta2o2pY15VSZh36eWORq31UzUX8ON2b8W8jyNpkGqQXj06bYc\r
269 VSIo06Kbe9/OgVOERHk+\r
270 =Z8Ko\r
271 -----END PGP SIGNATURE-----\r
272 --==-=-=--\r