unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: add pipe attachment command
@ 2012-05-05 12:31 Mark Walters
  2012-05-07  7:02 ` Jameson Graef Rollins
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Walters @ 2012-05-05 12:31 UTC (permalink / raw)
  To: notmuch

Allow the user to pipe the attachment somewhere. Bound to '|' on the
attachment button.
---

I found myself missing this functionality. It uses mm-pipe-part which
is nice as it sends single line output to the minibuffer and multiline
output to a new emacs buffer.


 emacs/notmuch-show.el |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 37f0ebb..55aa505 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,11 @@ 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."
@@ -1891,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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] emacs: add pipe attachment command
  2012-05-05 12:31 [PATCH] emacs: add pipe attachment command Mark Walters
@ 2012-05-07  7:02 ` Jameson Graef Rollins
  2012-05-07  7:33   ` [Patch v2] " Mark Walters
  2012-06-22 10:46   ` [PATCH] " David Bremner
  0 siblings, 2 replies; 7+ messages in thread
From: Jameson Graef Rollins @ 2012-05-07  7:02 UTC (permalink / raw)
  To: Notmuch Mail

From: Mark Walters <markwalters1009@gmail.com>

Allow the user to pipe the attachment somewhere. Bound to '|' on the
attachment button.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
---
Nice missing feature.  Tested and reviewed.  It just needed to be
rebased against the current master.

 emacs/notmuch-show.el |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d318430..26bff8f 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,11 @@ 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-multipart/*-to-list (part)
   (mapcar (lambda (inner-part) (plist-get inner-part :content-type))
 	  (plist-get part :content)))
@@ -1874,6 +1880,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.10

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Patch v2] emacs: add pipe attachment command
  2012-05-07  7:02 ` Jameson Graef Rollins
@ 2012-05-07  7:33   ` Mark Walters
  2012-05-07 15:22     ` Jameson Graef Rollins
  2012-06-22 10:46   ` [PATCH] " David Bremner
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Walters @ 2012-05-07  7:33 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Patch v2] emacs: add pipe attachment command
  2012-05-07  7:33   ` [Patch v2] " Mark Walters
@ 2012-05-07 15:22     ` Jameson Graef Rollins
  2012-05-07 15:46       ` Mark Walters
  0 siblings, 1 reply; 7+ messages in thread
From: Jameson Graef Rollins @ 2012-05-07 15:22 UTC (permalink / raw)
  To: Mark Walters, notmuch

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]

On Mon, May 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> Here is a rebased to current master version of the previous patch: no
> other changes.

Actually, what I sent was a rebase.  And this rebase doesn't look
correct.  The notmuch-show-mm-display-part-inline function moved to
notmuch-lib.el.  It certainly has nothing to do with this patch, so I
don't think adding it here is correct.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] emacs: add pipe attachment command
  2012-05-07 15:22     ` Jameson Graef Rollins
@ 2012-05-07 15:46       ` Mark Walters
  2012-05-07 15:57         ` Jameson Graef Rollins
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Walters @ 2012-05-07 15:46 UTC (permalink / raw)
  To: Jameson Graef Rollins, notmuch


On Mon, 07 May 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
> On Mon, May 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:
>> Here is a rebased to current master version of the previous patch: no
>> other changes.
>
> Actually, what I sent was a rebase.  

Sorry somehow I missed that you had actually sent the rebase too: and
then I messed up my rebase. How embarrassing! 

Anyway many thanks for the correct rebase, and for spotting my stupid error.

Best wishes

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] emacs: add pipe attachment command
  2012-05-07 15:46       ` Mark Walters
@ 2012-05-07 15:57         ` Jameson Graef Rollins
  0 siblings, 0 replies; 7+ messages in thread
From: Jameson Graef Rollins @ 2012-05-07 15:57 UTC (permalink / raw)
  To: Mark Walters, notmuch

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]

On Mon, May 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> Sorry somehow I missed that you had actually sent the rebase too: and
> then I messed up my rebase. How embarrassing! 
>
> Anyway many thanks for the correct rebase, and for spotting my stupid error.

np ;) I've done plenty of things much more embarrassing than that!

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] emacs: add pipe attachment command
  2012-05-07  7:02 ` Jameson Graef Rollins
  2012-05-07  7:33   ` [Patch v2] " Mark Walters
@ 2012-06-22 10:46   ` David Bremner
  1 sibling, 0 replies; 7+ messages in thread
From: David Bremner @ 2012-06-22 10:46 UTC (permalink / raw)
  To: Jameson Graef Rollins, Notmuch Mail

Jameson Graef Rollins <jrollins@finestructure.net> writes:

> From: Mark Walters <markwalters1009@gmail.com>
>
> Allow the user to pipe the attachment somewhere. Bound to '|' on the
> attachment button.
>

pushed

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-06-22 10:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-05 12:31 [PATCH] emacs: add pipe attachment command Mark Walters
2012-05-07  7:02 ` Jameson Graef Rollins
2012-05-07  7:33   ` [Patch v2] " Mark Walters
2012-05-07 15:22     ` Jameson Graef Rollins
2012-05-07 15:46       ` Mark Walters
2012-05-07 15:57         ` Jameson Graef Rollins
2012-06-22 10:46   ` [PATCH] " David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).