1 Return-Path: <markwalters1009@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 arlo.cworth.org (Postfix) with ESMTP id 82B946DE02AC
\r
6 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2016 00:49:37 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.155 tagged_above=-999 required=5 tests=[AWL=-0.275,
\r
12 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1,
\r
14 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,
\r
15 SPF_PASS=-0.001] autolearn=disabled
\r
16 Received: from arlo.cworth.org ([127.0.0.1])
\r
17 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
18 with ESMTP id kCP5OyYF-XIc for <notmuch@notmuchmail.org>;
\r
19 Mon, 11 Jul 2016 00:49:29 -0700 (PDT)
\r
20 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com
\r
21 [74.125.82.67]) by arlo.cworth.org (Postfix) with ESMTPS id DE3C36DE014D for
\r
22 <notmuch@notmuchmail.org>; Mon, 11 Jul 2016 00:49:28 -0700 (PDT)
\r
23 Received: by mail-wm0-f67.google.com with SMTP id o80so3337933wme.0
\r
24 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2016 00:49:28 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id;
\r
27 bh=TJTAoj7fv9RZunm5kRybJ2cb/1jKMhHsqDPtuatqut8=;
\r
28 b=QTnothJM04P8Gikvna77kl9NqpcfhDifPrUhmFDFoNRF9oJz/ZyUIBNYcMjwO7zKoy
\r
29 JxQZfclilj8BahN2OBhCSlCVGs5BiHTE353LUbrtTx2bOqH9CQnbi2jdZeSmgKkSj0nn
\r
30 /n9QSMOEb5F7bStIk7GCarQDk/cSSWn2vLNcY55MxBKviRbMHhnJCYGqJ8Zo2DqqxH0M
\r
31 iQyLDejKDyRLq5piCiGbSsfL5vL5JJj28VB7pgzpQD4MuunvcJ2Nz2ICVZOCMVef/lFz
\r
32 2tJQ5mjPr7VnBiEFyitn0Ry4ZJ14k2E3FSp3qHlmmO3N7k78S/hgTrR8uQ33SfZPOLhS
\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
35 d=1e100.net; s=20130820;
\r
36 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
37 bh=TJTAoj7fv9RZunm5kRybJ2cb/1jKMhHsqDPtuatqut8=;
\r
38 b=U79rJI4jsrBwK4A1ei/aD2xIAEn6T7PzVyD3wvJNoEANmgdTs1JwE7IYhgSWYx78We
\r
39 +pOG0sGd9f4uTRGsqygEn0pLwKOhwJXPF0lzS/h+r3cW8ucOtuqqLhct4db8n5qW5x+i
\r
40 AVdc35xb8iBXIYnoeE2aYpC30HdAYROCCadevyhQbHPFXX5gqhREmlVuJxwUrA2uzc9g
\r
41 IEJgcwVzbVOLqdLE4EAFd95EsjEtMJ6gQuTIFtI5YCTwx0DUuV4TS+/8RqXEFB6ZKjEy
\r
42 Ag0pcakiWcGtK1bSIO/say7Sn3mOc1j6Ye6llPZRc5uHWWiPfQP3oAfY1aZvhFkf38/Y
\r
45 ALyK8tIJbzKc5KsBDu+QPxzZpaL6d61xqSPG//sWdNQX8YUCXGzSActE5EWAJHNl1HloHw==
\r
46 X-Received: by 10.28.142.194 with SMTP id q185mr12554670wmd.6.1468223363883;
\r
47 Mon, 11 Jul 2016 00:49:23 -0700 (PDT)
\r
48 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
49 by smtp.gmail.com with ESMTPSA id 12sm14352548wmj.19.2016.07.11.00.49.22
\r
50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
51 Mon, 11 Jul 2016 00:49:23 -0700 (PDT)
\r
52 From: Mark Walters <markwalters1009@gmail.com>
\r
53 To: notmuch@notmuchmail.org
\r
54 Subject: [PATCH v2] emacs: show: let the user override the mime-type of an
\r
56 Date: Mon, 11 Jul 2016 08:49:19 +0100
\r
57 Message-Id: <1468223359-16736-1-git-send-email-markwalters1009@gmail.com>
\r
58 X-Mailer: git-send-email 2.1.4
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.20
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Mon, 11 Jul 2016 07:49:37 -0000
\r
73 This allows the user to override the mime-type of a part in the show
\r
74 buffer. This takes the simple option of displaying the part with the
\r
75 specified mime-type in its own buffer (in view mode). This avoids
\r
76 further complicating the part handling code.
\r
78 Bound to ". m" (i.e., m in the part map). Then the user can either
\r
79 enter a mime-type (with completion to all mime types that mailcap (and
\r
80 thus notmuch) knows about, or press return for the default choice of
\r
86 This is (a rather delayed) version 2 of the patch
\r
87 id:1435702585-27363-1-git-send-email-markwalters1009@gmail.com
\r
89 I have fixed bremner's review comment on the naming of the function,
\r
90 and since it was easy I have added completion for mime-types.
\r
92 It is not heavily tested but seems to work.
\r
98 emacs/notmuch-show.el | 36 ++++++++++++++++++++++++++++++------
\r
99 1 file changed, 30 insertions(+), 6 deletions(-)
\r
101 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
102 index 6d3149b..06ba549 100644
\r
103 --- a/emacs/notmuch-show.el
\r
104 +++ b/emacs/notmuch-show.el
\r
105 @@ -1403,6 +1403,7 @@ reset based on the original query."
\r
106 (define-key map "v" 'notmuch-show-view-part)
\r
107 (define-key map "o" 'notmuch-show-interactively-view-part)
\r
108 (define-key map "|" 'notmuch-show-pipe-part)
\r
109 + (define-key map "m" 'notmuch-show-choose-mime-of-part)
\r
110 (define-key map "?" 'notmuch-subkeymap-help)
\r
112 "Submap for part commands")
\r
113 @@ -2337,25 +2338,27 @@ omit --in-reply-to=<Message-Id>."
\r
114 (insert (notmuch-get-bodypart-binary msg part process-crypto)))
\r
117 -(defun notmuch-show-current-part-handle ()
\r
118 +(defun notmuch-show-current-part-handle (&optional mime-type)
\r
119 "Return an mm-handle for the part containing point.
\r
121 This creates a temporary buffer for the part's content; the
\r
122 -caller is responsible for killing this buffer as appropriate."
\r
123 +caller is responsible for killing this buffer as appropriate. If
\r
124 +MIME-TYPE is given then set the handle's mime-type to MIME-TYPE."
\r
125 (let* ((msg (notmuch-show-get-message-properties))
\r
126 (part (notmuch-show-get-part-properties))
\r
127 (buf (notmuch-show-generate-part-buffer msg part))
\r
128 - (computed-type (plist-get part :computed-type))
\r
129 + (computed-type (or mime-type (plist-get part :computed-type)))
\r
130 (filename (plist-get part :filename))
\r
131 (disposition (if filename `(attachment (filename . ,filename)))))
\r
132 (mm-make-handle buf (list computed-type) nil nil disposition)))
\r
134 -(defun notmuch-show-apply-to-current-part-handle (fn)
\r
135 +(defun notmuch-show-apply-to-current-part-handle (fn &optional mime-type)
\r
136 "Apply FN to an mm-handle for the part containing point.
\r
138 This ensures that the temporary buffer created for the mm-handle
\r
139 -is destroyed when FN returns."
\r
140 - (let ((handle (notmuch-show-current-part-handle)))
\r
141 +is destroyed when FN returns. If MIME-TYPE is given then force
\r
142 +part to be treated as if it had that mime-type."
\r
143 + (let ((handle (notmuch-show-current-part-handle mime-type)))
\r
144 ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we
\r
145 ;; call it from a temp-buffer, unless
\r
146 ;; notmuch-show-attachment-debug is non-nil in which case we put
\r
147 @@ -2400,6 +2403,27 @@ is destroyed when FN returns."
\r
148 (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))
\r
151 +(defun notmuch-show--mm-display-part (handle)
\r
152 + "Use mm-display-part to display HANDLE in a new buffer.
\r
154 +If the part is displayed in an external application then close
\r
156 + (let ((buf (get-buffer-create (generate-new-buffer-name
\r
157 + (concat " *notmuch-internal-part*")))))
\r
158 + (switch-to-buffer buf)
\r
159 + (if (eq (mm-display-part handle) 'external)
\r
160 + (kill-buffer buf)
\r
161 + (goto-char (point-min))
\r
162 + (set-buffer-modified-p nil)
\r
163 + (view-buffer buf 'kill-buffer-if-not-modified))))
\r
165 +(defun notmuch-show-choose-mime-of-part (mime-type)
\r
166 + "Choose the mime type to use for displaying part"
\r
168 + (list (completing-read "Mime type to use (default text/plain): "
\r
169 + (mailcap-mime-types) nil nil nil nil "text/plain")))
\r
170 + (notmuch-show-apply-to-current-part-handle #'notmuch-show--mm-display-part mime-type))
\r
172 (provide 'notmuch-show)
\r
174 ;;; notmuch-show.el ends here
\r