Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 4b / 2be5b4537bf1d0751f311060509ab0f7525e7f
1 Return-Path: <cworth@cworth.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 E90D6429E20\r
6         for <notmuch@notmuchmail.org>; Thu, 10 Mar 2011 18:09:52 -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.99\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.99 tagged_above=-999 required=5\r
12         tests=[ALL_TRUSTED=-1, T_MIME_NO_TEXT=0.01] 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 S1BJqQ-rj18y; Thu, 10 Mar 2011 18:09:52 -0800 (PST)\r
16 Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
17         by olra.theworths.org (Postfix) with ESMTP id 4E490431FB5;\r
18         Thu, 10 Mar 2011 18:09:52 -0800 (PST)\r
19 Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
20         id DED5454C0C4; Thu, 10 Mar 2011 18:09:51 -0800 (PST)\r
21 From: Carl Worth <cworth@cworth.org>\r
22 To: Austin Clements <amdragon@mit.edu>, Thomas Schwinge <thomas@schwinge.name>\r
23 Subject: Re: [PATCH 2/2] notmuch.el:notmuch-search-process-filter: Rewritten.\r
24         Cope with incomplete lines.\r
25 In-Reply-To: <AANLkTi=_ZqOao8mMRRb=gLmX+MWchqZ0Af-VxJquwure@mail.gmail.com>\r
26 References: <87zkqeiffj.fsf@kepler.schwinge.homeip.net>\r
27         <1296690999-16542-3-git-send-email-thomas@schwinge.name>\r
28         <AANLkTi=_ZqOao8mMRRb=gLmX+MWchqZ0Af-VxJquwure@mail.gmail.com>\r
29 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.2.1\r
30         (i486-pc-linux-gnu)\r
31 Date: Thu, 10 Mar 2011 18:09:51 -0800\r
32 Message-ID: <87oc5i8l1s.fsf@yoom.home.cworth.org>\r
33 MIME-Version: 1.0\r
34 Content-Type: multipart/signed; boundary="=-=-=";\r
35         micalg=pgp-sha1; protocol="application/pgp-signature"\r
36 Cc: notmuch@notmuchmail.org\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Fri, 11 Mar 2011 02:09:53 -0000\r
50 \r
51 --=-=-=\r
52 Content-Transfer-Encoding: quoted-printable\r
53 \r
54 On Thu, 3 Feb 2011 12:06:20 -0500, Austin Clements <amdragon@mit.edu> wrote:\r
55 > Nice catch.\r
56 >=20\r
57 > Is there a reason you keep the remaining data in a string instead of\r
58 > taking the more idiomatic elisp approach of leaving it in the process\r
59 > buffer?\r
60 \r
61 Thomas is excused since he was just modifying my code originally.\r
62 \r
63 And now I've gone and made it even worse by adding a bunch of hideously\r
64 non-idiomatic expressions like:\r
65 \r
66         (while (and (< line (length string)) (=3D (elt string line) ?\n))\r
67           (setq line (1+ line)))\r
68 \r
69 The rough equivalent in C would be quite natural (where we actually have\r
70 pointers):\r
71 \r
72         while (*s && *s =3D=3D '\n')\r
73             s++;\r
74 \r
75 but the above elisp is quite nasty.\r
76 \r
77 > In fact, the code would probably be simpler if you\r
78 > immediately appended the string to the process buffer like a normal\r
79 > process-filter and then peeled things away using buffer-oriented\r
80 > regexp functions like looking-at.  Elisp is a lot better at\r
81 > manipulating buffers than it is at manipulating strings.\r
82 \r
83 I spent a bit of time trying this. Using looking-at is definitely better\r
84 than string-match since we can then use things like (match-string 1)\r
85 rather than (match-string 1 string). And getting rid of the "line"\r
86 variable means that all of the ugly expressions like the one I showed\r
87 above went away.\r
88 \r
89 The approach I tried was to use a temporary buffer for the unparsed data\r
90 and the process buffer for the resulting parsed data. The code got a bit\r
91 awkward as I kept having to jump back and for between (with-temp-buffer)\r
92 and (with-current-buffer buffer)---particularly due to the buffer-local\r
93 variable to hold the trailing data from the past run.\r
94 \r
95 A better approach might be to use a single buffer, leave the unparse\r
96 data at the end, and just make it hidden.\r
97 \r
98 But I'll leave this alone for now since fighting elisp has left me\r
99 annoyed. If anyone wants to clean up my hideous elisp here, then that\r
100 would be fine with me.\r
101 \r
102 =2DCarl\r
103 \r
104 =2D-=20\r
105 carl.d.worth@intel.com\r
106 \r
107 --=-=-=\r
108 Content-Type: application/pgp-signature\r
109 \r
110 -----BEGIN PGP SIGNATURE-----\r
111 Version: GnuPG v1.4.10 (GNU/Linux)\r
112 \r
113 iD8DBQFNeYRv6JDdNq8qSWgRAo6rAJkBq1/ECsairoUAV9ZiKzCzZbF25ACfTdaD\r
114 yuEIt9J/DdmcbfAVQJjVe0k=\r
115 =K5J8\r
116 -----END PGP SIGNATURE-----\r
117 --=-=-=--\r