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