Re: [PATCH v4 09/16] index encrypted parts when asked.
[notmuch-archives.git] / e1 / 9bdc87b371d88558c859aef6dc538808df7e03
1 Return-Path: <camalot@picnicpark.org>\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 4668841971B\r
6         for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 05:31:02 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id 8at0aSBext30 for <notmuch@notmuchmail.org>;\r
11         Fri, 27 Nov 2009 05:31:01 -0800 (PST)\r
12 Received: from mout.perfora.net (mout.perfora.net [74.208.4.195])\r
13         by olra.theworths.org (Postfix) with ESMTP id 3E83C41971A\r
14         for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 05:31:01 -0800 (PST)\r
15 Received: from vps.nicira.com (66.7.219.28.static.dimenoc.com [66.7.219.28])\r
16         by mx.perfora.net (node=mxus1) with ESMTP (Nemesis)\r
17         id 0MPmLS-1NHqf00yCw-0050Pk for notmuch@notmuchmail.org;\r
18         Fri, 27 Nov 2009 08:31:00 -0500\r
19 Received: from [76.210.240.177] (port=36300 helo=kea-nicira-lt)\r
20         by vps.nicira.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69)\r
21         (envelope-from <camalot@picnicpark.org>)\r
22         id 1NE0uY-0004d9-AW; Fri, 27 Nov 2009 08:30:59 -0500\r
23 Received: by kea-nicira-lt (sSMTP sendmail emulation);\r
24         Fri, 27 Nov 2009 05:30:57 -0800\r
25 From: camalot@picnicpark.org\r
26 To: notmuch@notmuchmail.org\r
27 Date: Fri, 27 Nov 2009 05:30:14 -0800\r
28 Message-Id: <1259328615-1445-9-git-send-email-camalot@picnicpark.org>\r
29 X-Mailer: git-send-email 1.6.5.3\r
30 In-Reply-To: <1259328615-1445-8-git-send-email-camalot@picnicpark.org>\r
31 References: <1259328615-1445-1-git-send-email-camalot@picnicpark.org>\r
32         <1259328615-1445-2-git-send-email-camalot@picnicpark.org>\r
33         <1259328615-1445-3-git-send-email-camalot@picnicpark.org>\r
34         <1259328615-1445-4-git-send-email-camalot@picnicpark.org>\r
35         <1259328615-1445-5-git-send-email-camalot@picnicpark.org>\r
36         <1259328615-1445-6-git-send-email-camalot@picnicpark.org>\r
37         <1259328615-1445-7-git-send-email-camalot@picnicpark.org>\r
38         <1259328615-1445-8-git-send-email-camalot@picnicpark.org>\r
39 X-AntiAbuse: This header was added to track abuse,\r
40         please include it with any abuse report\r
41 X-AntiAbuse: Primary Hostname - vps.nicira.com\r
42 X-AntiAbuse: Original Domain - notmuchmail.org\r
43 X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]\r
44 X-AntiAbuse: Sender Address Domain - picnicpark.org\r
45 X-Source: \r
46 X-Source-Args: \r
47 X-Source-Dir: \r
48 Cc: Keith Amidon <keith@nicira.com>\r
49 Subject: [notmuch] [PATCH 8/9] Provide ability to save attachments\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.12\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Fri, 27 Nov 2009 13:31:02 -0000\r
63 \r
64 From: Keith Amidon <keith@nicira.com>\r
65 \r
66 Previously the only way to save an attachment was to attempt to view\r
67 it and then save it from within the viewer program.\r
68 ---\r
69  notmuch.el |   41 +++++++++++++++++++++++++++++++++++++++++\r
70  1 files changed, 41 insertions(+), 0 deletions(-)\r
71 \r
72 diff --git a/notmuch.el b/notmuch.el\r
73 index eaa5798..0c6b527 100644\r
74 --- a/notmuch.el\r
75 +++ b/notmuch.el\r
76 @@ -303,6 +303,47 @@ buffer."\r
77    (with-current-notmuch-show-message\r
78     (mm-display-parts (mm-dissect-buffer))))\r
79  \r
80 +(defun notmuch-foreach-mime-part (function mm-handle)\r
81 +  (cond ((stringp (car mm-handle))\r
82 +         (dolist (part (cdr mm-handle))\r
83 +           (notmuch-foreach-mime-part function part)))\r
84 +        ((bufferp (car mm-handle))\r
85 +         (funcall function mm-handle))\r
86 +        (t (dolist (part mm-handle)\r
87 +             (notmuch-foreach-mime-part function part)))))\r
88 +\r
89 +(defun notmuch-count-attachments (mm-handle)\r
90 +  (let ((count 0))\r
91 +    (notmuch-foreach-mime-part\r
92 +     (lambda (p)\r
93 +       (let ((disposition (mm-handle-disposition p)))\r
94 +         (and (listp disposition)\r
95 +              (equal (car disposition) "attachment")\r
96 +              (incf count))))\r
97 +     mm-handle)\r
98 +    count))\r
99 +\r
100 +(defun notmuch-save-attachments (mm-handle &optional queryp)\r
101 +  (notmuch-foreach-mime-part\r
102 +   (lambda (p)\r
103 +     (let ((disposition (mm-handle-disposition p)))\r
104 +       (and (listp disposition)\r
105 +            (equal (car disposition) "attachment")\r
106 +            (or (not queryp)\r
107 +                (y-or-n-p\r
108 +                 (concat "Save '" (cdr (assq 'filename disposition)) "' ")))\r
109 +            (mm-save-part p))))\r
110 +   mm-handle))\r
111 +\r
112 +(defun notmuch-show-save-attachments ()\r
113 +  "Save the attachments to a message"\r
114 +  (interactive)\r
115 +  (with-current-notmuch-show-message\r
116 +   (let ((mm-handle (mm-dissect-buffer)))\r
117 +     (notmuch-save-attachments\r
118 +      mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
119 +  (message "Done"))\r
120 +\r
121  (defun notmuch-reply (query-string)\r
122    (switch-to-buffer (generate-new-buffer "notmuch-draft"))\r
123    (call-process notmuch-command nil t nil "reply" query-string)\r
124 -- \r
125 1.6.5.3\r
126 \r