Re: [PATCH v3] nmbug: Translate to Python
[notmuch-archives.git] / 79 / c69da9f9cb937de40b49aae879741a5c7bd8b9
1 Return-Path: <amdragon@mit.edu>\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 B213C431FC7\r
6         for <notmuch@notmuchmail.org>; Mon, 19 Nov 2012 21:32:12 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id AVBPvZ9CxFML for <notmuch@notmuchmail.org>;\r
16         Mon, 19 Nov 2012 21:32:11 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU\r
18         [18.7.68.37])\r
19         by olra.theworths.org (Postfix) with ESMTP id D407C431FBC\r
20         for <notmuch@notmuchmail.org>; Mon, 19 Nov 2012 21:32:10 -0800 (PST)\r
21 X-AuditID: 12074425-b7fcc6d00000091f-04-50ab15d9b496\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 2B.17.02335.9D51BA05; Tue, 20 Nov 2012 00:32:09 -0500 (EST)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qAK5W9np007400; \r
27         Tue, 20 Nov 2012 00:32:09 -0500\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qAK5W7hg001257\r
32         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
33         Tue, 20 Nov 2012 00:32:08 -0500 (EST)\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
35         (envelope-from <amdragon@MIT.EDU>)\r
36         id 1TagRL-0000Kd-34; Tue, 20 Nov 2012 00:32:07 -0500\r
37 Date: Tue, 20 Nov 2012 00:32:07 -0500\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Damien Cassou <damien.cassou@gmail.com>\r
40 Subject: Re: [PATCH 1/4] Add a thread's tags to emacs header-line\r
41 Message-ID: <20121120053207.GB32514@mit.edu>\r
42 References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com>\r
43         <1353266322-20318-2-git-send-email-damien.cassou@gmail.com>\r
44         <20121120051320.GA32514@mit.edu>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=iso-8859-1\r
47 Content-Disposition: inline\r
48 Content-Transfer-Encoding: 8bit\r
49 In-Reply-To: <20121120051320.GA32514@mit.edu>\r
50 User-Agent: Mutt/1.5.21 (2010-09-15)\r
51 X-Brightmail-Tracker:\r
52  H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsUixCmqrHtTdHWAwe9uG4tdd7cyWVy/OZPZ\r
53         gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4Mp4vX8+W8E3lYqDtx6wNTA+keli5OSQEDCR\r
54         2PfuPiuELSZx4d56ti5GLg4hgX2MEtuetTJDOBsYJZ6f/coI4Zxkkth/pIMdpEVIYAmjxPwl\r
55         XCA2i4CqxNVXt5lBbDYBDYlt+5czgtgiAtoSb5Z2gK1gFjCSuL9jOliNsICjROuUlWA2r4CO\r
56         xLqdp6BWr2CU+LHuAVRCUOLkzCcsEM06Eju33gEq4gCypSWW/+OACMtLNG+dDVbOKaArcfLd\r
57         aTYQW1RARWLKyW1sExiFZyGZNAvJpFkIk2YhmbSAkWUVo2xKbpVubmJmTnFqsm5xcmJeXmqR\r
58         roVebmaJXmpK6SZGUCSwu6juYJxwSOkQowAHoxIP74OEVQFCrIllxZW5hxglOZiURHk3CK8O\r
59         EOJLyk+pzEgszogvKs1JLT7EKMHBrCTC21QOVM6bklhZlVqUD5OS5mBREue9kXLTX0ggPbEk\r
60         NTs1tSC1CCYrw8GhJMHrJQI0VLAoNT21Ii0zpwQhzcTBCTKcB2i4P0gNb3FBYm5xZjpE/hSj\r
61         LsfCNe1PGIVY8vLzUqXEeXNAigRAijJK8+DmwBLYK0ZxoLeEeatAqniAyQ9u0iugJUxAS64F\r
62         LAdZUpKIkJJqYAw1fVQ/c1frZfPVW9uvvX+w6f8sGydPY73Di35qzF7nHMYZesY6qu3/nxuP\r
63         zsik/wt3M1qz6iT/o3iPqI4ZzVeffyvrL/tl6FwdtXDhj46Flpu2bZe/bmrQG/RKsMPkj+fa\r
64         bdeK3zFODhFdWKEy/ZKbjlrhAaVkK9GdN//m9qz1edByzoTLMECJpTgj0VCLuag4EQDN79UG\r
65         OwMAAA==\r
66 Cc: notmuch mailing list <notmuch@notmuchmail.org>\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.13\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71         <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
78         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Tue, 20 Nov 2012 05:32:12 -0000\r
80 \r
81 Sorry, I was a little trigger-happy on the send.  A few more comments\r
82 below.\r
83 \r
84 Quoth myself on Nov 20 at 12:13 am:\r
85 > Quoth Damien Cassou on Nov 18 at  8:18 pm:\r
86 > > Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
87 > > ---\r
88 > >  emacs/notmuch-show.el   |   24 +++++++++++++++++++++---\r
89 > >  emacs/notmuch-tagger.el |   44 ++++++++++++++++++++++++++++++++++++++++++++\r
90 > >  2 files changed, 65 insertions(+), 3 deletions(-)\r
91 > >  create mode 100644 emacs/notmuch-tagger.el\r
92 > > \r
93 > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
94 > > index 5b3e70e..988e27c 100644\r
95 > > --- a/emacs/notmuch-show.el\r
96 > > +++ b/emacs/notmuch-show.el\r
97 > > @@ -36,6 +36,7 @@\r
98 > >  (require 'notmuch-mua)\r
99 > >  (require 'notmuch-crypto)\r
100 > >  (require 'notmuch-print)\r
101 > > +(require 'notmuch-tagger)\r
102 > >  \r
103 > >  (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))\r
104 > >  (declare-function notmuch-fontify-headers "notmuch" nil)\r
105 > > @@ -1121,11 +1122,28 @@ function is used."\r
106 > >  \r
107 > >        (jit-lock-register #'notmuch-show-buttonise-links)\r
108 > >  \r
109 > > -      ;; Set the header line to the subject of the first message.\r
110 > > -      (setq header-line-format (notmuch-show-strip-re (notmuch-show-get-subject)))\r
111 > > -\r
112 > > +      (notmuch-show-update-header-line)\r
113 > >        (run-hooks 'notmuch-show-hook))))\r
114 > >  \r
115 > > +(defun notmuch-show-thread-tags ()\r
116 > > +  "Return the list of tags for the current thread."\r
117 > > +  (let ((tags (list)))\r
118 > > +    (notmuch-show-mapc (lambda ()\r
119 > > +                    (mapcar (lambda (elt)\r
120 > > +                              ;; Avoid adding duplicate tags\r
121 > > +                              (add-to-list 'tags elt))\r
122 > > +                            (notmuch-show-get-tags))))\r
123 > > +    tags))\r
124 > > +\r
125 > > +(defun notmuch-show-update-header-line ()\r
126 > > +  "Make the header-line show the thread's subject and tags."\r
127 > > +  (let ((thread-subject (notmuch-show-strip-re (notmuch-show-get-subject))))\r
128 > > +    (setq header-line-format\r
129 > > +     (list\r
130 > > +      thread-subject\r
131 > > +      " "\r
132 > > +      (notmuch-tagger-present-tags-header-line (notmuch-show-thread-tags))))))\r
133 > > +\r
134 > >  (defun notmuch-show-capture-state ()\r
135 > >    "Capture the state of the current buffer.\r
136 > >  \r
137 > > diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el\r
138 > > new file mode 100644\r
139 > > index 0000000..5ca190e\r
140 > > --- /dev/null\r
141 > > +++ b/emacs/notmuch-tagger.el\r
142 > > @@ -0,0 +1,44 @@\r
143 > > +;; notmuch-tagger.el --- Library to improve the way tags are displayed\r
144 > > +;;\r
145 > > +;; Copyright © Damien Cassou\r
146 > > +;;\r
147 > > +;; This file is part of Notmuch.\r
148 > > +;;\r
149 > > +;; Notmuch is free software: you can redistribute it and/or modify it\r
150 > > +;; under the terms of the GNU General Public License as published by\r
151 > > +;; the Free Software Foundation, either version 3 of the License, or\r
152 > > +;; (at your option) any later version.\r
153 > > +;;\r
154 > > +;; Notmuch is distributed in the hope that it will be useful, but\r
155 > > +;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
156 > > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
157 > > +;; General Public License for more details.\r
158 > > +;;\r
159 > > +;; You should have received a copy of the GNU General Public License\r
160 > > +;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
161 > > +;;\r
162 > > +;; Authors: Damien Cassou <damien.cassou@gmail.com>\r
163 > > +;;; Commentary:\r
164 > > +;;\r
165 > > +;;; Code:\r
166 > > +;;\r
167 > > +(defun notmuch-tagger-separate-elems (list sep)\r
168\r
169 > notmuch-tagger-intersperse?\r
170\r
171 > This could also reasonably go in notmuch-lib.el as a general utility.\r
172\r
173 > (How do neither Elisp nor 'cl have an intersperse?)\r
174\r
175 > > +  "Return a list with all elements of LIST separated by SEP."\r
176 > > +  (let ((first t)\r
177 > > +        (res nil))\r
178 > > +    (dolist (elt (reverse list) res)\r
179\r
180 > (dolist (elt list (nreverse res)) ...) to save a list copy?\r
181\r
182 > > +      (unless first\r
183 > > +        (push sep res))\r
184 > > +      (setq first nil)\r
185 > > +      (push elt res))))\r
186 > > +\r
187 > > +(defun notmuch-tagger-present-tags-header-line (tags)\r
188 \r
189 notmuch-tagger-format-tags-header-line?  It doesn't actually present\r
190 them (though "format" isn't great either.)\r
191 \r
192 > > +  "Return a property list to present TAGS in emacs header-line."\r
193 \r
194 This doesn't return a property list, it returns a mode-line-format\r
195 template.  Maybe something like,\r
196 \r
197   "Format TAGS as a mode-line-format template.\r
198 The result is suitable for inclusion in `header-line-format' or\r
199 `mode-line-format'."\r
200 \r
201 (Is it actually suitable for mode-line-format or do header-line\r
202 buttons really only work in the header line?)\r
203 \r
204 > > +  (list\r
205 > > +   "("\r
206 > > +   (notmuch-tagger-separate-elems tags " ")\r
207 > > +   ")"))\r
208 > > +\r
209 > > +\r
210 > > +(provide 'notmuch-tagger)\r
211 > > +;;; notmuch-tagger.el ends here\r