1 Return-Path: <aaronecay@gmail.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 10073421197
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 12:44:17 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,
\r
13 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 ACppF3OvEfIP for <notmuch@notmuchmail.org>;
\r
17 Tue, 17 Jan 2012 12:44:16 -0800 (PST)
\r
18 Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com
\r
19 [209.85.216.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 5EECA421192
\r
22 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 12:44:16 -0800 (PST)
\r
23 Received: by qadc16 with SMTP id c16so2557844qad.5
\r
24 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 12:44:15 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=sender:from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type;
\r
28 bh=XeK97bVWtYNFhI5nLUzEF3sAlq8sSi+R91ZqX8GMG/g=;
\r
29 b=gZiCh/Tsz3/dojLLvhMPPIOz4NYIVMekwIkbNKZCRJ9tY4NcsA7104kvxA4v8d/MLO
\r
30 DHUfB1X4ZWQvpLTRQr7930+BXgmJdOLjpOZCahd5FnkjJ1pbDePeRwAi5YW65n5PgAy8
\r
31 E66AizhJO7C27RXxY/8T30MntUl1JpAUjpm/U=
\r
32 Received: by 10.229.78.160 with SMTP id l32mr6890288qck.88.1326833055655;
\r
33 Tue, 17 Jan 2012 12:44:15 -0800 (PST)
\r
34 Received: from localhost (luw017.wlan.gapsa.upenn.edu. [128.91.230.146])
\r
35 by mx.google.com with ESMTPS id o8sm45794500qaj.0.2012.01.17.12.44.13
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Tue, 17 Jan 2012 12:44:14 -0800 (PST)
\r
38 Sender: Aaron Ecay <aaronecay@gmail.com>
\r
39 From: Aaron Ecay <ecay@sas.upenn.edu>
\r
40 To: Austin Clements <amdragon@MIT.EDU>,
\r
41 Mark Walters <markwalters1009@gmail.com>
\r
42 Subject: Re: [PATCH 1/1] Make buttons for attachments allow viewing as well as
\r
44 In-Reply-To: <20120117202603.GP16740@mit.edu>
\r
45 References: <1326629796-11436-1-git-send-email-markwalters1009@gmail.com>
\r
46 <1326629796-11436-2-git-send-email-markwalters1009@gmail.com>
\r
47 <87wr8r5trv.fsf@servo.finestructure.net>
\r
48 <87lip7fhkc.fsf@qmul.ac.uk> <20120117022330.GE16740@mit.edu>
\r
49 <8739beitq4.fsf@qmul.ac.uk> <20120117202603.GP16740@mit.edu>
\r
50 User-Agent: Notmuch/0.11+62~ge41b0d3 (http://notmuchmail.org) Emacs/24.0.92.1
\r
51 (i386-apple-darwin10.8.0)
\r
52 Date: Tue, 17 Jan 2012 15:44:12 -0500
\r
53 Message-ID: <m2y5t69i03.fsf@gmail.com>
\r
55 Content-Type: text/plain
\r
56 Cc: notmuch@notmuchmail.org
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Tue, 17 Jan 2012 20:44:17 -0000
\r
71 On Tue, 17 Jan 2012 15:26:03 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
\r
72 > Quoth Mark Walters on Jan 17 at 9:06 am:
\r
74 > > > > I wonder if the "problem" comes from me doing things in a non-lispy
\r
75 > > > > fashion (I am completely new to lisp). Thus
\r
76 > > > > notmuch-show-part-button-default-action is a variable that gets passed
\r
77 > > > > around rather than a function.
\r
79 > > > Sorry, I should have looked at the bigger context in this patch. I
\r
80 > > > think Jameson was implying that notmuch-show-part-button-default
\r
81 > > > should change to
\r
83 > > > (defun notmuch-show-part-button-default (&optional button)
\r
85 > > > (funcall notmuch-show-part-button-default-action button))
\r
87 > > > I would go one step further and say that each action should probably
\r
88 > > > be a separate function. That is, break notmuch-show-part-action into
\r
89 > > > separate functions and simply invoke the appropriate function, rather
\r
90 > > > than performing a fixed data dispatch. This would be more flexible
\r
91 > > > and Lispy. It may be that your approach works out better, but I'd at
\r
92 > > > least give this a shot.
\r
94 > > I am happy to make that change. My original patch in the summer was more
\r
96 > > id:"CALUdzSWAto+4mCUOOMk+8vFs+Pog-xUma6u-Aqx2M6-sbyQROg@mail.gmail.com"
\r
98 > Is this the right id? I couldn't find it in the list archive.
\r
100 > > Is that more what you had in mind? (Only in broad terms: Obviously I
\r
101 > > would need to add in the customization and default function etc). I
\r
102 > > decided that I didn't like the code duplication (but I am completely new
\r
103 > > to lisp) which is why I changed it for this submission.
\r
105 > Yes, I wondered about this, too. It seems like at worst the
\r
106 > notmuch-show-process-crypto stuff would be duplicated. This might be
\r
107 > little enough that it's not worth worrying about, or it might be worth
\r
108 > introducing something like
\r
110 > (defun notmuch-with-temp-part-buffer (message-id nth action)
\r
111 > (let ((process-crypto notmuch-show-process-crypto))
\r
112 > (with-temp-buffer
\r
113 > (setq notmuch-show-process-crypto process-crypto)
\r
114 > ;; Always acquires the part via `notmuch part', even if it is
\r
115 > ;; available in the JSON output.
\r
116 > (insert (notmuch-show-get-bodypart-internal message-id nth))
\r
117 > (funcall action))))
\r
119 > You could also do this as a macro, but that definitely seems like
\r
122 It seems to me that a macro is in fact the best solution. If you do it
\r
123 with a function, you need two defuns per action: one to do the actual
\r
125 (defun notmuch-show-part-button-whatever-worker ()
\r
129 (defun notmuch-show-part-button-whatever ()
\r
130 (notmuch-with-temp-part-buffer
\r
131 id part-number #'notmuch-show-part-button-whatever-worker))
\r
133 It would be the latter function that the key would be bound to. If a
\r
134 macro is used, the split between the worker and glue fns can be
\r
135 abandoned, and only one function is needed:
\r
136 (defun notmuch-show-part-button-whatever ()
\r
137 (notmuch-with-temp-part-buffer
\r
141 A further advantage is if interactive arguments (e.g. C-u prefix) are
\r
142 needed for the function, there is no need to thread them through as
\r
143 arguments of notmuch-with-temp-part-buffer.
\r