[Patch v2] emacs: add pipe attachment command
authorMark Walters <markwalters1009@gmail.com>
Mon, 7 May 2012 07:33:28 +0000 (08:33 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:58 +0000 (09:46 -0800)
a0/40f7be49d2c8cdc64d5072cdc3c102ac4c4612 [new file with mode: 0644]

diff --git a/a0/40f7be49d2c8cdc64d5072cdc3c102ac4c4612 b/a0/40f7be49d2c8cdc64d5072cdc3c102ac4c4612
new file mode 100644 (file)
index 0000000..ac8c854
--- /dev/null
@@ -0,0 +1,133 @@
+Return-Path: <markwalters1009@gmail.com>\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 D1867431FB6\r
+       for <notmuch@notmuchmail.org>; Mon,  7 May 2012 00:33:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 4MO3reEpkEaq for <notmuch@notmuchmail.org>;\r
+       Mon,  7 May 2012 00:33:29 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 289D5431FAE\r
+       for <notmuch@notmuchmail.org>; Mon,  7 May 2012 00:33:28 -0700 (PDT)\r
+Received: by werm13 with SMTP id m13so3555582wer.26\r
+       for <notmuch@notmuchmail.org>; Mon, 07 May 2012 00:33:27 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=HFkmsJJYhJTnEW7EVXTWzV5EMvQSIkzfUes+kBo3hXs=;\r
+       b=VQafU+bZgMxIWqfi6OsWIeQNiPIDZJblbFbRs4DJxae3m3gZleegjG2TIDJYTrcEQS\r
+       6erUelHa1aB40myPOwh0OkTLm81Zs7WZh7WKGr1DzMtO3fYh1PjQ62Gv0vQvcETEFyuA\r
+       2QoCAd66FNwpz/P62RBBt0YwcU1vVVpKy3RuE/QkMKqQGZjovRlplvl8czoCsO7VUgt1\r
+       CVorb2kh6tOfgzCDzXNSeIbjv71AEM2ReLQMBnQ/AVT0aMEDEqFygQomByLqMjScpIJd\r
+       n57BsPfNHckbx002pxO02h009c2GPahnSq3RhUIUpNtN2jstpM6zuAd+AI/YApPYjUtt\r
+       dViw==\r
+Received: by 10.216.135.131 with SMTP id u3mr8919003wei.46.1336376007521;\r
+       Mon, 07 May 2012 00:33:27 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ j3sm31391138wiw.1.2012.05.07.00.33.25 (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 07 May 2012 00:33:26 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2] emacs: add pipe attachment command\r
+Date: Mon,  7 May 2012 08:33:28 +0100\r
+Message-Id: <1336376008-13014-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1336374129-10225-1-git-send-email-jrollins@finestructure.net>\r
+References: <1336374129-10225-1-git-send-email-jrollins@finestructure.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Mon, 07 May 2012 07:33:30 -0000\r
+\r
+Allow the user to pipe the attachment somewhere. Bound to '|' on the\r
+attachment button.\r
+---\r
+\r
+Thanks for the review!\r
+\r
+Here is a rebased to current master version of the previous patch: no\r
+other changes.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+ emacs/notmuch-show.el |   27 +++++++++++++++++++++++++++\r
+ 1 files changed, 27 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index d318430..b6a1980 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -453,6 +453,7 @@ message at DEPTH in the current thread."\r
+     (define-key map "s" 'notmuch-show-part-button-save)\r
+     (define-key map "v" 'notmuch-show-part-button-view)\r
+     (define-key map "o" 'notmuch-show-part-button-interactively-view)\r
++    (define-key map "|" 'notmuch-show-part-button-pipe)\r
+     map)\r
+   "Submap for button commands")\r
+ (fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
+@@ -524,6 +525,28 @@ message at DEPTH in the current thread."\r
+     (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
+       (mm-interactively-view-part handle))))\r
+ \r
++(defun notmuch-show-pipe-part (message-id nth &optional filename content-type)\r
++  (notmuch-with-temp-part-buffer message-id nth\r
++    (let ((handle (mm-make-handle (current-buffer) (list content-type))))\r
++      (mm-pipe-part handle))))\r
++\r
++(defun notmuch-show-mm-display-part-inline (msg part nth content-type)\r
++  "Use the mm-decode/mm-view functions to display a part in the\r
++current buffer, if possible."\r
++  (let ((display-buffer (current-buffer)))\r
++    (with-temp-buffer\r
++      (let* ((charset (plist-get part :content-charset))\r
++           (handle (mm-make-handle (current-buffer) `(,content-type (charset . ,charset)))))\r
++      ;; If the user wants the part inlined, insert the content and\r
++      ;; test whether we are able to inline it (which includes both\r
++      ;; capability and suitability tests).\r
++      (when (mm-inlined-p handle)\r
++        (insert (notmuch-get-bodypart-content msg part nth notmuch-show-process-crypto))\r
++        (when (mm-inlinable-p handle)\r
++          (set-buffer display-buffer)\r
++          (mm-display-part handle)\r
++          t))))))\r
++\r
+ (defun notmuch-show-multipart/*-to-list (part)\r
+   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
+         (plist-get part :content)))\r
+@@ -1874,6 +1897,10 @@ the user (see `notmuch-show-stash-mlarchive-link-alist')."\r
+   (interactive)\r
+   (notmuch-show-part-button-internal button #'notmuch-show-interactively-view-part))\r
+ \r
++(defun notmuch-show-part-button-pipe (&optional button)\r
++  (interactive)\r
++  (notmuch-show-part-button-internal button #'notmuch-show-pipe-part))\r
++\r
+ (defun notmuch-show-part-button-internal (button handler)\r
+   (let ((button (or button (button-at (point)))))\r
+     (if button\r
+-- \r
+1.7.9.1\r
+\r