Re: [PATCH v3 10/10] cli: address: Add --filter-by option to configure address filtering
[notmuch-archives.git] / cf / 27e317c77818ad59edf225bc31544b80d426d8
1 Return-Path: <dme@dme.org>\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 1F02A431FD0\r
6         for <notmuch@notmuchmail.org>; Mon,  9 Jan 2012 00:50:09 -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 E5xuDGSkQFYc for <notmuch@notmuchmail.org>;\r
16         Mon,  9 Jan 2012 00:50:08 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  35DDE431FB6    for <notmuch@notmuchmail.org>; Mon,  9 Jan 2012 00:50:08 -0800\r
21  (PST)\r
22 Received: by wgbds11 with SMTP id ds11so1220104wgb.2\r
23         for <notmuch@notmuchmail.org>; Mon, 09 Jan 2012 00:50:07 -0800 (PST)\r
24 Received: by 10.180.96.7 with SMTP id do7mr3134120wib.16.1326099006980;\r
25         Mon, 09 Jan 2012 00:50:06 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id hv1sm5489465wib.1.2012.01.09.00.50.05\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Mon, 09 Jan 2012 00:50:05 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id CDEA1A346A; Mon,  9 Jan 2012 08:50:03 +0000 (GMT)\r
33 To: Adam Wolfe Gordon <awg+notmuch@xvx.ca>, notmuch@notmuchmail.org,\r
34  awg@xvx.ca\r
35 Subject: Re: [PATCH 4/4] emacs: Use the new JSON reply format.\r
36 In-Reply-To: <1326009162-19524-5-git-send-email-awg+notmuch@xvx.ca>\r
37 References: <1326009162-19524-1-git-send-email-awg+notmuch@xvx.ca>\r
38         <1326009162-19524-5-git-send-email-awg+notmuch@xvx.ca>\r
39 User-Agent: Notmuch/0.10.2+151~gbf1dc2b (http://notmuchmail.org)\r
40         Emacs/24.0.92.1 (x86_64-pc-linux-gnu)\r
41 From: David Edmondson <dme@dme.org>\r
42 Date: Mon, 09 Jan 2012 08:50:00 +0000\r
43 Message-ID: <cun62gl1cqv.fsf@hotblack-desiato.hh.sledj.net>\r
44 MIME-Version: 1.0\r
45 Content-Type: multipart/signed; boundary="=-=-=";\r
46         micalg=pgp-sha1; protocol="application/pgp-signature"\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Mon, 09 Jan 2012 08:50:09 -0000\r
60 \r
61 --=-=-=\r
62 Content-Type: text/plain\r
63 Content-Transfer-Encoding: quoted-printable\r
64 \r
65 On Sun,  8 Jan 2012 00:52:42 -0700, Adam Wolfe Gordon <awg+notmuch@xvx.ca> =\r
66 wrote:\r
67 > +(defun w3m-region (start end)) ;; From `w3m.el'.\r
68 > +(defun notmuch-mua-quote-part (part)\r
69 > +  (with-temp-buffer\r
70 > +    (insert part)\r
71 > +    (message-mode)\r
72 > +    (fill-region (point-min) (point-max))\r
73 > +    (goto-char (point-min))\r
74 > +    (perform-replace "^" "> " nil t nil)\r
75 > +    (set-buffer-modified-p nil)\r
76 > +    (buffer-substring (point-min) (point-max))))\r
77 \r
78 Couldn't all of this be done directly in the reply buffer?\r
79 \r
80 > +(defun notmuch-mua-parse-html-part (part)\r
81 > +  (with-temp-buffer\r
82 > +    (insert part)\r
83 > +    (w3m-region (point-min) (point-max))\r
84 > +    (set-buffer-modified-p nil)\r
85 > +    (buffer-substring (point-min) (point-max))))\r
86 \r
87 Blank lines between functions are the house style (as much as there is\r
88 such a thing).\r
89 \r
90 Using w3m means that you should `require' it. What happens when a user\r
91 doesn't have it? (Either the elisp or the command.)\r
92 \r
93 >  (defun notmuch-mua-reply (query-string &optional sender)\r
94 > -  (let (headers\r
95 > +  (let (reply\r
96 > +     original\r
97 > +     headers\r
98 >       body\r
99 > -     (args '("reply")))\r
100 > +     (args '("reply" "--format=3Djson")))\r
101 \r
102 Initialised variables are generally shown before uninitialised. I know\r
103 that you didn't do this 'wrong' and that it's an unrelated change, but\r
104 it should be fixed. (To the people who say that should be a separate\r
105 patch I say 'meh' - life is too short.)\r
106 \r
107 >      (if notmuch-show-process-crypto\r
108 >       (setq args (append args '("--decrypt"))))\r
109 >      (setq args (append args (list query-string)))\r
110 > -    ;; This make assumptions about the output of `notmuch reply', but\r
111 > -    ;; really only that the headers come first followed by a blank\r
112 > -    ;; line and then the body.\r
113 > +    ;; Get the reply object as JSON, and parse it into an elisp object.\r
114 >      (with-temp-buffer\r
115 >        (apply 'call-process (append (list notmuch-command nil (list t t) =\r
116 nil) args))\r
117 >        (goto-char (point-min))\r
118 > -      (if (re-search-forward "^$" nil t)\r
119 > -       (save-excursion\r
120 > -         (save-restriction\r
121 > -           (narrow-to-region (point-min) (point))\r
122 > -           (goto-char (point-min))\r
123 > -           (setq headers (mail-header-extract)))))\r
124 > -      (forward-line 1)\r
125 > -      (setq body (buffer-substring (point) (point-max))))\r
126 > +      (setq reply (aref (json-read) 0)))\r
127 > +\r
128 > +    ;; Get the list of headers\r
129 > +    (setq headers (cdr (assq 'headers (assq 'reply reply))))\r
130 > +    ;; Construct the body of the reply.\r
131 > +    (setq original (cdr (assq 'original reply)))\r
132 \r
133 The scope of (at least) `headers' and `original' could be tightened by\r
134 moving them down to the following `let' (and converting it to `let*').\r
135 \r
136 > +\r
137 > +    ;; Start with the prelude, based on the headers of the original mess=\r
138 age.\r
139 > +    (let ((original-headers (cdr (assq 'headers original))))\r
140 > +      (setq body (format "On %s, %s wrote:\n"\r
141 > +                      (cdr (assq 'date original-headers))\r
142 > +                      (cdr (assq 'from original-headers)))))\r
143 > +\r
144 > +    ;; Extract the body parts and construct a reasonable quoted body.\r
145 > +    (let* ((body-parts (cdr (assq 'body original)))\r
146 > +        (find-parts (lambda (type) (delq nil (mapcar (lambda (part)\r
147 > +                                                       (if (string=3D (cdr (assq 'content-type part)) type)\r
148 > +                                                           (cdr (assq 'content part))))\r
149 > +                                                     body-parts))))\r
150 \r
151 `find-parts' might be useful in other places. Maybe add it to notmuch-lib.e=\r
152 l?\r
153 \r
154 > +        (plain-parts (apply find-parts '("text/plain")))\r
155 > +        (html-parts (apply find-parts '("text/html"))))\r
156 > +=20=20=20=20=20=20\r
157 > +      (if (not (null plain-parts))\r
158 > +       (mapc (lambda (part) (setq body (concat body (notmuch-mua-quote-part =\r
159 part)))) plain-parts)\r
160 > +     (mapc (lambda (part) (setq body (concat body (notmuch-mua-quote-part (n=\r
161 otmuch-mua-parse-html-part part))))) html-parts)))\r
162 \r
163 If you have an 'else' clause, why test '(if (not ..' ?\r
164 \r
165 > +    (setq body (concat body "\n"))\r
166 > +=09\r
167 \r
168 If it already ends with a carriage return, why do this?\r
169 \r
170 --=-=-=\r
171 Content-Type: application/pgp-signature\r
172 \r
173 -----BEGIN PGP SIGNATURE-----\r
174 Version: GnuPG v1.4.11 (GNU/Linux)\r
175 \r
176 iEYEARECAAYFAk8KqjgACgkQaezQq/BJZRYKjgCdFRk68a66Bwlk5yRAfXGvAgtG\r
177 /akAn1yNHIX6CaeXPLKMRtwiSHBvYu8+\r
178 =/FA4\r
179 -----END PGP SIGNATURE-----\r
180 --=-=-=--\r