[PATCH] lib: provide _notmuch_database_log_append
[notmuch-archives.git] / 9c / 4190e09a159c3d7ccd9c9b0a87d14f5fd12046
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 A79AF421197\r
6         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 12:38:50 -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: -1.098\r
10 X-Spam-Level: \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 LXSr5I+udUmu for <notmuch@notmuchmail.org>;\r
17         Tue, 17 Jan 2012 12:38:50 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 9B270421192\r
22         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 12:38:49 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1RnFno-0004we-GG; Tue, 17 Jan 2012 20:38:44 +0000\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1RnFno-0000Rg-08; Tue, 17 Jan 2012 20:38:44 +0000\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Austin Clements <amdragon@MIT.EDU>\r
34 Subject: Re: [PATCH 1/1] Make buttons for attachments allow viewing as well as\r
35         saving\r
36 In-Reply-To: <20120117202603.GP16740@mit.edu>\r
37 References: <1326629796-11436-1-git-send-email-markwalters1009@gmail.com>\r
38         <1326629796-11436-2-git-send-email-markwalters1009@gmail.com>\r
39         <87wr8r5trv.fsf@servo.finestructure.net>\r
40         <87lip7fhkc.fsf@qmul.ac.uk> <20120117022330.GE16740@mit.edu>\r
41         <8739beitq4.fsf@qmul.ac.uk> <20120117202603.GP16740@mit.edu>\r
42 User-Agent: Notmuch/0.11~rc2+73~g1ea2b60 (http://notmuchmail.org) Emacs/23.2.1\r
43         (i486-pc-linux-gnu)\r
44 Date: Tue, 17 Jan 2012 20:39:31 +0000\r
45 Message-ID: <871uqy3vy4.fsf@qmul.ac.uk>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain; charset=us-ascii\r
48 X-Sender-Host-Address: 94.192.233.223\r
49 X-QM-SPAM-Info: Sender has good ham record.  :)\r
50 X-QM-Body-MD5: 474436974fe97c3a85ecdb65173ebaca (of first 20000 bytes)\r
51 X-SpamAssassin-Score: -1.7\r
52 X-SpamAssassin-SpamBar: -\r
53 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
54         determine if it is\r
55         spam. We require at least 5.0 points to mark a message as spam.\r
56         This message scored -1.7 points.\r
57         Summary of the scoring: \r
58         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
59         *      medium trust\r
60         *      [138.37.6.40 listed in list.dnswl.org]\r
61         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
62         provider *      (markwalters1009[at]gmail.com)\r
63         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
64         *      domain\r
65         *  0.6 AWL AWL: From: address is in the auto white-list\r
66 X-QM-Scan-Virus: ClamAV says the message is clean\r
67 Cc: notmuch@notmuchmail.org\r
68 X-BeenThere: notmuch@notmuchmail.org\r
69 X-Mailman-Version: 2.1.13\r
70 Precedence: list\r
71 List-Id: "Use and development of the notmuch mail system."\r
72         <notmuch.notmuchmail.org>\r
73 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
75 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
76 List-Post: <mailto:notmuch@notmuchmail.org>\r
77 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
78 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
79         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
80 X-List-Received-Date: Tue, 17 Jan 2012 20:38:50 -0000\r
81 \r
82 \r
83 > > I am happy to make that change. My original patch in the summer was more\r
84 > > like that:\r
85 > > id:"CALUdzSWAto+4mCUOOMk+8vFs+Pog-xUma6u-Aqx2M6-sbyQROg@mail.gmail.com"\r
86\r
87 > Is this the right id?  I couldn't find it in the list archive.\r
88 \r
89 Sorry I messed up: it should be id:"87mxehqhbl.fsf@r102.config" However\r
90 I have included my current draft along these lines. I think it is\r
91 working but I am not submitting yet: just asking if this is the right\r
92 idea.\r
93 \r
94 Best wishes \r
95 \r
96 Mark\r
97 \r
98 >From 9e52414b9871369c1cbb5c3e72d833b56bb236d4 Mon Sep 17 00:00:00 2001\r
99 From: Mark Walters <markwalters1009@gmail.com>\r
100 Date: Sat, 14 Jan 2012 18:04:22 +0000\r
101 Subject: [PATCH] Make buttons for attachments allow viewing as well as saving\r
102 \r
103 Define a keymap for attachment buttons to allow multiple actions.\r
104 Define 3 possible actions:\r
105     save attachment: exactly as currently,\r
106     view attachment: uses mailcap entry,\r
107     view attachment with user chosen program\r
108 \r
109 Keymap on a button is: s for save, v for view and o for view with\r
110 other program. Default (i.e. enter or mouse button) is save but this\r
111 is configurable in notmuch customize.\r
112 \r
113 One implementation detail: the view attachment function forces all\r
114 attachments to be "displayed" using mailcap even if emacs could\r
115 display them itself. Thus, for example, text/html appears in a browser\r
116 and text/plain asks whether to save (on a standard debian setup)\r
117 ---\r
118  emacs/notmuch-show.el |   87 ++++++++++++++++++++++++++++++++++++++++++++----\r
119  1 files changed, 79 insertions(+), 8 deletions(-)\r
120 \r
121 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
122 index 03c1f6b..2413caa 100644\r
123 --- a/emacs/notmuch-show.el\r
124 +++ b/emacs/notmuch-show.el\r
125 @@ -281,10 +281,21 @@ message at DEPTH in the current thread."\r
126         (run-hooks 'notmuch-show-markup-headers-hook)))))\r
127  \r
128  (define-button-type 'notmuch-show-part-button-type\r
129 -  'action 'notmuch-show-part-button-action\r
130 +  'action 'notmuch-show-part-button-default\r
131 +  'keymap 'notmuch-show-part-button-map\r
132    'follow-link t\r
133    'face 'message-mml)\r
134  \r
135 +(defvar notmuch-show-part-button-map\r
136 +  (let ((map (make-sparse-keymap)))\r
137 +       (set-keymap-parent map button-map)\r
138 +       (define-key map "s" 'notmuch-show-part-button-save)\r
139 +       (define-key map "v" 'notmuch-show-part-button-view)\r
140 +       (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
141 +    map)\r
142 +  "Submap for button commands")\r
143 +(fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
144 +\r
145  (defun notmuch-show-insert-part-header (nth content-type declared-type &optional name comment)\r
146    (let ((button))\r
147      (setq button\r
148 @@ -299,7 +310,8 @@ message at DEPTH in the current thread."\r
149                    " ]")\r
150            :type 'notmuch-show-part-button-type\r
151            :notmuch-part nth\r
152 -          :notmuch-filename name))\r
153 +          :notmuch-filename name\r
154 +          :notmuch-content-type content-type))\r
155      (insert "\n")\r
156      ;; return button\r
157      button))\r
158 @@ -323,6 +335,28 @@ message at DEPTH in the current thread."\r
159         ;; ange-ftp, which is reasonable to use here.\r
160         (mm-write-region (point-min) (point-max) file nil nil nil 'no-conversion t)))))\r
161  \r
162 +(defun notmuch-show-view-part (message-id nth content-type)\r
163 +  (let ((process-crypto notmuch-show-process-crypto))\r
164 +    (with-temp-buffer\r
165 +      (setq notmuch-show-process-crypto process-crypto)\r
166 +      ;; Always acquires the part via `notmuch part', even if it is\r
167 +      ;; available in the JSON output.\r
168 +      (insert (notmuch-show-get-bodypart-internal message-id nth))\r
169 +      ;; set mm-inlined-types to nil to force an external viewer\r
170 +      (let ((handle (mm-make-handle (current-buffer) (list content-type)))\r
171 +           (mm-inlined-types nil))\r
172 +       (mm-display-part handle t)))))\r
173 +\r
174 +(defun notmuch-show-interactively-view-part (message-id nth content-type)\r
175 +  (let ((process-crypto notmuch-show-process-crypto))\r
176 +    (with-temp-buffer\r
177 +      (setq notmuch-show-process-crypto process-crypto)\r
178 +      ;; Always acquires the part via `notmuch part', even if it is\r
179 +      ;; available in the JSON output.\r
180 +      (insert (notmuch-show-get-bodypart-internal message-id nth))\r
181 +      (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
182 +       (mm-interactively-view-part handle)))))\r
183 +\r
184  (defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
185    "Use the mm-decode/mm-view functions to display a part in the\r
186  current buffer, if possible."\r
187 @@ -1502,12 +1536,49 @@ buffer."\r
188  \r
189  ;; Commands typically bound to buttons.\r
190  \r
191 -(defun notmuch-show-part-button-action (button)\r
192 -  (let ((nth (button-get button :notmuch-part)))\r
193 -    (if nth\r
194 -       (notmuch-show-save-part (notmuch-show-get-message-id) nth\r
195 -                               (button-get button :notmuch-filename))\r
196 -      (message "Not a valid part (is it a fake part?)."))))\r
197 +(defcustom notmuch-show-part-button-default-action 'notmuch-show-part-button-save\r
198 +  "Default part header button action (on ENTER or mouse click)."\r
199 +  :group 'notmuch\r
200 +  :type '(choice (const :tag "Save part"\r
201 +                       notmuch-show-part-button-save)\r
202 +                (const :tag "View part"\r
203 +                       notmuch-show-part-button-view)\r
204 +                (const :tag "View interactively"\r
205 +                       notmuch-show-part-button-interactively-view)))\r
206 +\r
207 +(defun notmuch-show-part-button-default (&optional button)\r
208 +  (interactive)\r
209 +  (funcall notmuch-show-part-button-default-action button))\r
210 +\r
211 +(defun notmuch-show-part-button-save (&optional button)\r
212 +  (interactive)\r
213 +  (let ((button (or button (button-at (point)))))\r
214 +    (if button\r
215 +       (let ((nth (button-get button :notmuch-part)))\r
216 +         (if nth\r
217 +             (notmuch-show-save-part (notmuch-show-get-message-id) nth\r
218 +                                     (button-get button :notmuch-filename))\r
219 +           (message "Not a valid part (is it a fake part?)."))))))\r
220 +\r
221 +(defun notmuch-show-part-button-view (&optional button)\r
222 +  (interactive)\r
223 +  (let ((button (or button (button-at (point)))))\r
224 +    (if button\r
225 +       (let ((nth (button-get button :notmuch-part)))\r
226 +         (if nth\r
227 +             (notmuch-show-view-part (notmuch-show-get-message-id) nth\r
228 +                                     (button-get button :notmuch-content-type))\r
229 +           (message "Not a valid part (is it a fake part?)."))))))\r
230 +\r
231 +(defun notmuch-show-part-button-interactively-view (&optional button)\r
232 +  (interactive)\r
233 +  (let ((button (or button (button-at (point)))))\r
234 +    (if button\r
235 +       (let ((nth (button-get button :notmuch-part)))\r
236 +         (if nth\r
237 +             (notmuch-show-interactively-view-part (notmuch-show-get-message-id) nth\r
238 +                                                   (button-get button :notmuch-content-type))\r
239 +           (message "Not a valid part (is it a fake part?)."))))))\r
240  \r
241  ;;\r
242  \r
243 -- \r
244 1.7.2.3\r
245 \r