[notmuch] [PATCH 8/9] Provide ability to save attachments
authorcamalot <camalot@picnicpark.org>
Fri, 27 Nov 2009 13:30:14 +0000 (05:30 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:35:44 +0000 (09:35 -0800)
e1/9bdc87b371d88558c859aef6dc538808df7e03 [new file with mode: 0644]

diff --git a/e1/9bdc87b371d88558c859aef6dc538808df7e03 b/e1/9bdc87b371d88558c859aef6dc538808df7e03
new file mode 100644 (file)
index 0000000..494c1ce
--- /dev/null
@@ -0,0 +1,126 @@
+Return-Path: <camalot@picnicpark.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4668841971B\r
+       for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 05:31:02 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8at0aSBext30 for <notmuch@notmuchmail.org>;\r
+       Fri, 27 Nov 2009 05:31:01 -0800 (PST)\r
+Received: from mout.perfora.net (mout.perfora.net [74.208.4.195])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3E83C41971A\r
+       for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 05:31:01 -0800 (PST)\r
+Received: from vps.nicira.com (66.7.219.28.static.dimenoc.com [66.7.219.28])\r
+       by mx.perfora.net (node=mxus1) with ESMTP (Nemesis)\r
+       id 0MPmLS-1NHqf00yCw-0050Pk for notmuch@notmuchmail.org;\r
+       Fri, 27 Nov 2009 08:31:00 -0500\r
+Received: from [76.210.240.177] (port=36300 helo=kea-nicira-lt)\r
+       by vps.nicira.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69)\r
+       (envelope-from <camalot@picnicpark.org>)\r
+       id 1NE0uY-0004d9-AW; Fri, 27 Nov 2009 08:30:59 -0500\r
+Received: by kea-nicira-lt (sSMTP sendmail emulation);\r
+       Fri, 27 Nov 2009 05:30:57 -0800\r
+From: camalot@picnicpark.org\r
+To: notmuch@notmuchmail.org\r
+Date: Fri, 27 Nov 2009 05:30:14 -0800\r
+Message-Id: <1259328615-1445-9-git-send-email-camalot@picnicpark.org>\r
+X-Mailer: git-send-email 1.6.5.3\r
+In-Reply-To: <1259328615-1445-8-git-send-email-camalot@picnicpark.org>\r
+References: <1259328615-1445-1-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-2-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-3-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-4-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-5-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-6-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-7-git-send-email-camalot@picnicpark.org>\r
+       <1259328615-1445-8-git-send-email-camalot@picnicpark.org>\r
+X-AntiAbuse: This header was added to track abuse,\r
+       please include it with any abuse report\r
+X-AntiAbuse: Primary Hostname - vps.nicira.com\r
+X-AntiAbuse: Original Domain - notmuchmail.org\r
+X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]\r
+X-AntiAbuse: Sender Address Domain - picnicpark.org\r
+X-Source: \r
+X-Source-Args: \r
+X-Source-Dir: \r
+Cc: Keith Amidon <keith@nicira.com>\r
+Subject: [notmuch] [PATCH 8/9] Provide ability to save attachments\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 27 Nov 2009 13:31:02 -0000\r
+\r
+From: Keith Amidon <keith@nicira.com>\r
+\r
+Previously the only way to save an attachment was to attempt to view\r
+it and then save it from within the viewer program.\r
+---\r
+ notmuch.el |   41 +++++++++++++++++++++++++++++++++++++++++\r
+ 1 files changed, 41 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/notmuch.el b/notmuch.el\r
+index eaa5798..0c6b527 100644\r
+--- a/notmuch.el\r
++++ b/notmuch.el\r
+@@ -303,6 +303,47 @@ buffer."\r
+   (with-current-notmuch-show-message\r
+    (mm-display-parts (mm-dissect-buffer))))\r
\r
++(defun notmuch-foreach-mime-part (function mm-handle)\r
++  (cond ((stringp (car mm-handle))\r
++         (dolist (part (cdr mm-handle))\r
++           (notmuch-foreach-mime-part function part)))\r
++        ((bufferp (car mm-handle))\r
++         (funcall function mm-handle))\r
++        (t (dolist (part mm-handle)\r
++             (notmuch-foreach-mime-part function part)))))\r
++\r
++(defun notmuch-count-attachments (mm-handle)\r
++  (let ((count 0))\r
++    (notmuch-foreach-mime-part\r
++     (lambda (p)\r
++       (let ((disposition (mm-handle-disposition p)))\r
++         (and (listp disposition)\r
++              (equal (car disposition) "attachment")\r
++              (incf count))))\r
++     mm-handle)\r
++    count))\r
++\r
++(defun notmuch-save-attachments (mm-handle &optional queryp)\r
++  (notmuch-foreach-mime-part\r
++   (lambda (p)\r
++     (let ((disposition (mm-handle-disposition p)))\r
++       (and (listp disposition)\r
++            (equal (car disposition) "attachment")\r
++            (or (not queryp)\r
++                (y-or-n-p\r
++                 (concat "Save '" (cdr (assq 'filename disposition)) "' ")))\r
++            (mm-save-part p))))\r
++   mm-handle))\r
++\r
++(defun notmuch-show-save-attachments ()\r
++  "Save the attachments to a message"\r
++  (interactive)\r
++  (with-current-notmuch-show-message\r
++   (let ((mm-handle (mm-dissect-buffer)))\r
++     (notmuch-save-attachments\r
++      mm-handle (> (notmuch-count-attachments mm-handle) 1))))\r
++  (message "Done"))\r
++\r
+ (defun notmuch-reply (query-string)\r
+   (switch-to-buffer (generate-new-buffer "notmuch-draft"))\r
+   (call-process notmuch-command nil t nil "reply" query-string)\r
+-- \r
+1.6.5.3\r
+\r