1 Return-Path: <m.walters@qmul.ac.uk>
\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 630D3431FD0
\r
6 for <notmuch@notmuchmail.org>; Tue, 6 Sep 2011 19:23:23 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 ucCi4K6jyL54 for <notmuch@notmuchmail.org>;
\r
17 Tue, 6 Sep 2011 19:23:22 -0700 (PDT)
\r
18 X-Greylist: delayed 3774 seconds by postgrey-1.32 at olra;
\r
19 Tue, 06 Sep 2011 19:23:22 PDT
\r
20 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
21 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
22 (No client certificate requested)
\r
23 by olra.theworths.org (Postfix) with ESMTPS id 8FC38431FB6
\r
24 for <notmuch@notmuchmail.org>; Tue, 6 Sep 2011 19:23:22 -0700 (PDT)
\r
25 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
26 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
27 (envelope-from <m.walters@qmul.ac.uk>)
\r
28 id 1R16oS-0001Cm-Oo; Wed, 07 Sep 2011 02:20:24 +0100
\r
29 Received: from [82.153.7.131] (helo=localhost)
\r
30 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
31 (envelope-from <m.walters@qmul.ac.uk>)
\r
32 id 1R16oE-0000WM-16; Wed, 07 Sep 2011 02:20:24 +0100
\r
33 From: Mark Walters <markwalters1009@gmail.com>
\r
34 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
35 Subject: RFC/PATCH emacs attachment handling
\r
36 User-Agent: Notmuch/0.7-37-g89c28de (http://notmuchmail.org) Emacs/23.2.1
\r
38 Date: Wed, 07 Sep 2011 02:20:14 +0100
\r
39 Message-ID: <87mxehqhbl.fsf@r102.config>
\r
41 Content-Type: text/plain; charset=us-ascii
\r
42 X-Sender-Host-Address: 82.153.7.131
\r
43 X-QM-SPAM-Info: Sender has good ham record. :)
\r
44 X-QM-Body-MD5: b05c930e36bafba0c01871cef296cb2c (of first 20000 bytes)
\r
45 X-QM-Scan-Virus: ClamAV says the message is clean
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Wed, 07 Sep 2011 02:23:23 -0000
\r
63 I have modified the emacs interface for handling attachments by adding
\r
64 a keymap to the attachment button. For example pressing v when on an
\r
65 attachment button views the attachment (using the mailcap method) and
\r
66 pressing s saves the attachment. I find this makes it a lot easier
\r
67 when dealing with message with lots of attachments.
\r
71 "Viewing" a text/html button opens the part in the mailcap defined html viewer.
\r
73 "Viewing" a part with no mailcap entry just offers to save it.
\r
75 In this version I make the button default to viewing: this is obviously
\r
76 trivial to change but I am not sure what the right way to make that
\r
77 user-configurable is.
\r
79 Finally, I have also mapped the key "o" (other/open with) on a button to
\r
80 open with user chosen program. This could be split out into a separate
\r
88 emacs/notmuch-show.el | 76 +++++++++++++++++++++++++++++++++++++++++++-----
\r
89 1 files changed, 68 insertions(+), 8 deletions(-)
\r
91 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
92 index 90f9af7..3a025c5 100644
\r
93 --- a/emacs/notmuch-show.el
\r
94 +++ b/emacs/notmuch-show.el
\r
95 @@ -267,10 +267,21 @@ message at DEPTH in the current thread."
\r
96 (run-hooks 'notmuch-show-markup-headers-hook)))))
\r
98 (define-button-type 'notmuch-show-part-button-type
\r
99 - 'action 'notmuch-show-part-button-action
\r
100 + 'action 'notmuch-show-part-button-view-action
\r
101 + 'keymap 'notmuch-show-part-button-map
\r
103 'face 'message-mml)
\r
105 +(defvar notmuch-show-part-button-map
\r
106 + (let ((map (make-sparse-keymap)))
\r
107 + (set-keymap-parent map button-map)
\r
108 + (define-key map "s" 'notmuch-show-part-button-save-action)
\r
109 + (define-key map "v" 'notmuch-show-part-button-view-action)
\r
110 + (define-key map "o" 'notmuch-show-part-button-interactively-view-action)
\r
112 + "Submap for button commands")
\r
113 +(fset 'notmuch-show-part-button-map notmuch-show-part-button-map)
\r
115 (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)
\r
118 @@ -285,7 +296,8 @@ message at DEPTH in the current thread."
\r
120 :type 'notmuch-show-part-button-type
\r
122 - :notmuch-filename name))
\r
123 + :notmuch-filename name
\r
124 + :notmuch-content-type content-type))
\r
128 @@ -309,6 +321,28 @@ message at DEPTH in the current thread."
\r
129 ;; ange-ftp, which is reasonable to use here.
\r
130 (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t)))))
\r
132 +(defun notmuch-show-view-part (message-id nth content-type)
\r
133 + (let ((process-crypto notmuch-show-process-crypto))
\r
134 + (with-temp-buffer
\r
135 + (setq notmuch-show-process-crypto process-crypto)
\r
136 + ;; Always acquires the part via `notmuch part', even if it is
\r
137 + ;; available in the JSON output.
\r
138 + (insert (notmuch-show-get-bodypart-internal message-id nth))
\r
139 + ;; set mm-inlined-types to nil to force an external viewer
\r
140 + (let ((handle (mm-make-handle (current-buffer) (list content-type)))
\r
141 + (mm-inlined-types nil))
\r
142 + (mm-display-part handle)))))
\r
144 +(defun notmuch-show-interactively-view-part (message-id nth content-type)
\r
145 + (let ((process-crypto notmuch-show-process-crypto))
\r
146 + (with-temp-buffer
\r
147 + (setq notmuch-show-process-crypto process-crypto)
\r
148 + ;; Always acquires the part via `notmuch part', even if it is
\r
149 + ;; available in the JSON output.
\r
150 + (insert (notmuch-show-get-bodypart-internal message-id nth))
\r
151 + (let ((handle (mm-make-handle (current-buffer) (list content-type))))
\r
152 + (mm-interactively-view-part handle)))))
\r
154 (defun notmuch-show-mm-display-part-inline (msg part content-type content)
\r
155 "Use the mm-decode/mm-view functions to display a part in the
\r
156 current buffer, if possible."
\r
157 @@ -1418,12 +1452,38 @@ buffer."
\r
159 ;; Commands typically bound to buttons.
\r
161 -(defun notmuch-show-part-button-action (button)
\r
162 - (let ((nth (button-get button :notmuch-part)))
\r
164 - (notmuch-show-save-part (notmuch-show-get-message-id) nth
\r
165 - (button-get button :notmuch-filename))
\r
166 - (message "Not a valid part (is it a fake part?)."))))
\r
167 +(defun notmuch-show-part-button-save-action (&optional button)
\r
169 + (let ((button (or button (button-at (point)))))
\r
172 + (let ((nth (button-get button :notmuch-part)))
\r
174 + (notmuch-show-save-part (notmuch-show-get-message-id) nth
\r
175 + (button-get button :notmuch-filename))
\r
176 + (message "Not a valid part (is it a fake part?)."))))))
\r
178 +(defun notmuch-show-part-button-view-action (&optional button)
\r
180 + (let ((button (or button (button-at (point)))))
\r
183 + (let ((nth (button-get button :notmuch-part)))
\r
185 + (notmuch-show-view-part (notmuch-show-get-message-id) nth
\r
186 + (button-get button :notmuch-content-type))
\r
187 + (message "Not a valid part (is it a fake part?)."))))))
\r
189 +(defun notmuch-show-part-button-interactively-view-action (&optional button)
\r
191 + (let ((button (or button (button-at (point)))))
\r
194 + (let ((nth (button-get button :notmuch-part)))
\r
196 + (notmuch-show-interactively-view-part (notmuch-show-get-message-id) nth
\r
197 + (button-get button :notmuch-content-type))
\r
198 + (message "Not a valid part (is it a fake part?)."))))))
\r