Re: [PATCH] create .mailmap file (for git shortlog/blame)
[notmuch-archives.git] / 74 / feeeaa69358c48e9c252a706c21b355a702063
1 Return-Path: <awg@lagos.xvx.ca>\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 00D48431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  5 May 2012 12:24:37 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 NQ+2nBSBqjPm for <notmuch@notmuchmail.org>;\r
16         Sat,  5 May 2012 12:24:37 -0700 (PDT)\r
17 Received: from idcmail-mo2no.shaw.ca (idcmail-mo2no.shaw.ca [64.59.134.9])\r
18         by olra.theworths.org (Postfix) with ESMTP id B4D64431FB6\r
19         for <notmuch@notmuchmail.org>; Sat,  5 May 2012 12:24:36 -0700 (PDT)\r
20 Received: from lb7f8hsrpno-svcs.dcs.int.inet (HELO pd5ml1no-ssvc.prod.shaw.ca)\r
21         ([10.0.144.222])\r
22         by pd7mo1no-svcs.prod.shaw.ca with ESMTP; 05 May 2012 13:24:34 -0600\r
23 X-Cloudmark-SP-Filtered: true\r
24 X-Cloudmark-SP-Result: v=1.1 cv=bD0CuDYpMgGTku+nVSbZuKP/9fNjspX1F8zuwcoBWhM=\r
25         c=1 sm=1\r
26         a=0FXa78-lThQA:10 a=BLceEmwcHowA:10 a=yQp6g8lIsgqumF79BAsFDg==:17\r
27         a=H2UTGGZU_1RtzGQqgokA:9 a=JivfGXD8Il3uE6aJGmwA:7\r
28         a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
29 Received: from unknown (HELO lagos.xvx.ca) ([96.52.216.56])\r
30         by pd5ml1no-dmz.prod.shaw.ca with ESMTP; 05 May 2012 13:24:34 -0600\r
31 Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
32         id 15BD38004809; Sat,  5 May 2012 13:24:34 -0600 (MDT)\r
33 From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH v2 2/2] emacs: Correctly quote non-text/plain parts in reply\r
36 Date: Sat,  5 May 2012 13:24:29 -0600\r
37 Message-Id: <1336245869-32699-3-git-send-email-awg+notmuch@xvx.ca>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <1336245869-32699-1-git-send-email-awg+notmuch@xvx.ca>\r
40 References: <1336245869-32699-1-git-send-email-awg+notmuch@xvx.ca>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sat, 05 May 2012 19:24:38 -0000\r
54 \r
55 Quote non-text parts nicely by displaying them with mm-display-part\r
56 before calling message-cite-original to quote them. HTML-only emails\r
57 can now be quoted correctly. We re-use some code from notmuch-show\r
58 (notmuch-show-mm-display-part-inline), which has been moved to\r
59 notmuch-lib.el.\r
60 \r
61 Mark the test for this feature as not broken.\r
62 ---\r
63  emacs/notmuch-lib.el  |   19 +++++++++++++++++++\r
64  emacs/notmuch-mua.el  |   13 ++++++++-----\r
65  emacs/notmuch-show.el |   19 +------------------\r
66  test/emacs            |    1 -\r
67  4 files changed, 28 insertions(+), 24 deletions(-)\r
68 \r
69 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
70 index 6907a5f..7fa441a 100644\r
71 --- a/emacs/notmuch-lib.el\r
72 +++ b/emacs/notmuch-lib.el\r
73 @@ -21,6 +21,8 @@\r
74  \r
75  ;; This is an part of an emacs-based interface to the notmuch mail system.\r
76  \r
77 +(require 'mm-view)\r
78 +(require 'mm-decode)\r
79  (eval-when-compile (require 'cl))\r
80  \r
81  (defvar notmuch-command "notmuch"\r
82 @@ -237,6 +239,23 @@ the given type."\r
83    (or (plist-get part :content)\r
84        (notmuch-get-bodypart-internal (notmuch-id-to-query (plist-get msg :id)) nth process-crypto)))\r
85  \r
86 +(defun notmuch-mm-display-part-inline (msg part nth content-type process-crypto)\r
87 +  "Use the mm-decode/mm-view functions to display a part in the\r
88 +current buffer, if possible."\r
89 +  (let ((display-buffer (current-buffer)))\r
90 +    (with-temp-buffer\r
91 +      (let* ((charset (plist-get part :content-charset))\r
92 +            (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
93 +       ;; If the user wants the part inlined, insert the content and\r
94 +       ;; test whether we are able to inline it (which includes both\r
95 +       ;; capability and suitability tests).\r
96 +       (when (mm-inlined-p handle)\r
97 +         (insert (notmuch-get-bodypart-content msg part nth process-crypto))\r
98 +         (when (mm-inlinable-p handle)\r
99 +           (set-buffer display-buffer)\r
100 +           (mm-display-part handle)\r
101 +           t))))))\r
102 +\r
103  ;; Converts a plist of headers to an alist of headers. The input plist should\r
104  ;; have symbols of the form :Header as keys, and the resulting alist will have\r
105  ;; symbols of the form 'Header as keys.\r
106 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
107 index 87bd88d..88d7505 100644\r
108 --- a/emacs/notmuch-mua.el\r
109 +++ b/emacs/notmuch-mua.el\r
110 @@ -21,6 +21,7 @@\r
111  \r
112  (require 'json)\r
113  (require 'message)\r
114 +(require 'mm-view)\r
115  (require 'format-spec)\r
116  \r
117  (require 'notmuch-lib)\r
118 @@ -90,6 +91,12 @@ list."\r
119         else if (notmuch-match-content-type (plist-get part :content-type) "text/*")\r
120           collect part))\r
121  \r
122 +(defun notmuch-mua-insert-quotable-part (message part)\r
123 +  (notmuch-mm-display-part-inline message part (plist-get part :id)\r
124 +                                 (plist-get part :content-type)\r
125 +                                 notmuch-show-process-crypto)\r
126 +  (goto-char (point-max)))\r
127 +\r
128  ;; There is a bug in emacs 23's message.el that results in a newline\r
129  ;; not being inserted after the References header, so the next header\r
130  ;; is concatenated to the end of it. This function fixes the problem,\r
131 @@ -169,11 +176,7 @@ list."\r
132         ;; Get the parts of the original message that should be quoted; this includes\r
133         ;; all the text parts, except the non-preferred ones in a multipart/alternative.\r
134         (let ((quotable-parts (notmuch-mua-get-quotable-parts (plist-get original :body))))\r
135 -         (mapc (lambda (part)\r
136 -                 (insert (notmuch-get-bodypart-content original part\r
137 -                                                       (plist-get part :id)\r
138 -                                                       notmuch-show-process-crypto)))\r
139 -               quotable-parts))\r
140 +         (mapc (apply-partially 'notmuch-mua-insert-quotable-part original) quotable-parts))\r
141  \r
142         (set-mark (point))\r
143         (goto-char start)\r
144 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
145 index 37f0ebb..d318430 100644\r
146 --- a/emacs/notmuch-show.el\r
147 +++ b/emacs/notmuch-show.el\r
148 @@ -524,23 +524,6 @@ message at DEPTH in the current thread."\r
149      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
150        (mm-interactively-view-part handle))))\r
151  \r
152 -(defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
153 -  "Use the mm-decode/mm-view functions to display a part in the\r
154 -current buffer, if possible."\r
155 -  (let ((display-buffer (current-buffer)))\r
156 -    (with-temp-buffer\r
157 -      (let* ((charset (plist-get part :content-charset))\r
158 -            (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
159 -       ;; If the user wants the part inlined, insert the content and\r
160 -       ;; test whether we are able to inline it (which includes both\r
161 -       ;; capability and suitability tests).\r
162 -       (when (mm-inlined-p handle)\r
163 -         (insert (notmuch-get-bodypart-content msg part nth notmuch-show-process-crypto))\r
164 -         (when (mm-inlinable-p handle)\r
165 -           (set-buffer display-buffer)\r
166 -           (mm-display-part handle)\r
167 -           t))))))\r
168 -\r
169  (defun notmuch-show-multipart/*-to-list (part)\r
170    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
171           (plist-get part :content)))\r
172 @@ -785,7 +768,7 @@ current buffer, if possible."\r
173  (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
174    ;; This handler _must_ succeed - it is the handler of last resort.\r
175    (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
176 -  (notmuch-show-mm-display-part-inline msg part nth content-type)\r
177 +  (notmuch-mm-display-part-inline msg part nth content-type notmuch-show-process-crypto)\r
178    t)\r
179  \r
180  ;; Functions for determining how to handle MIME parts.\r
181 diff --git a/test/emacs b/test/emacs\r
182 index 5f238d9..a615b39 100755\r
183 --- a/test/emacs\r
184 +++ b/test/emacs\r
185 @@ -445,7 +445,6 @@ EOF\r
186  test_expect_equal_file OUTPUT EXPECTED\r
187  \r
188  test_begin_subtest "Reply within emacs to an html-only message"\r
189 -test_subtest_known_broken\r
190  add_message '[content-type]="text/html"' \\r
191             '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'\r
192  test_emacs "(let ((message-hidden-headers '()))\r
193 -- \r
194 1.7.5.4\r
195 \r