summaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-09-16 15:52:12 -0700
committerCarl Worth <cworth@cworth.org>2010-09-16 15:52:12 -0700
commit4e77148a4ba9f3b217241818ea65f282ec434e56 (patch)
tree10b35787be582a67dee98289a87341239ea0d9bb /emacs
parent9f0accb6aa1be3aa3a00e564b1091f875cf45e80 (diff)
emacs: Allow '|' to operate on multiple messages (by means of prefix argument).
We extend the '|' command so that passing a prefix argument, (for example, "C-u |"), causes it to pipe all open messages in the current thread rather than just the single, current message.
Diffstat (limited to 'emacs')
-rw-r--r--emacs/notmuch-show.el41
1 files changed, 34 insertions, 7 deletions
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ff03936..98d25ef 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -774,6 +774,22 @@ All currently available key bindings:
"Mark the current message as read."
(notmuch-show-remove-tag "unread"))
+;; Functions for getting attributes of several messages in the current
+;; thread.
+
+(defun notmuch-show-get-message-ids-for-open-messages ()
+ "Return a list of all message IDs for open messages in the current thread."
+ (save-excursion
+ (let (message-ids done)
+ (goto-char (point-min))
+ (while (not done)
+ (if (notmuch-show-message-visible-p)
+ (setq message-ids (append message-ids (list (notmuch-show-get-message-id)))))
+ (setq done (not (notmuch-show-goto-message-next)))
+ )
+ message-ids
+ )))
+
;; Commands typically bound to keys.
(defun notmuch-show-advance-and-archive ()
@@ -904,16 +920,27 @@ any effects from previous calls to
(interactive)
(view-file (notmuch-show-get-filename)))
-(defun notmuch-show-pipe-message (command)
- "Pipe the contents of the current message to the given command.
+(defun notmuch-show-pipe-message (entire-thread command)
+ "Pipe the contents of the current message (or thread) to the given command.
The given command will be executed with the raw contents of the
current email message as stdin. Anything printed by the command
-to stdout or stderr will appear in the *Messages* buffer."
- (interactive "sPipe message to command: ")
- (apply 'start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*"
- (list command " < "
- (shell-quote-argument (notmuch-show-get-filename)))))
+to stdout or stderr will appear in the *Messages* buffer.
+
+When invoked with a prefix argument, the command will receive all
+open messages in the current thread (formatted as an mbox) rather
+than only the current message."
+ (interactive "P\nsPipe message to command: ")
+ (let (shell-command)
+ (if entire-thread
+ (setq shell-command
+ (concat "notmuch show --format=mbox "
+ (shell-quote-argument
+ (mapconcat 'identity (notmuch-show-get-message-ids-for-open-messages) " OR "))
+ " | " command))
+ (setq shell-command
+ (concat command " < " (shell-quote-argument (notmuch-show-get-filename)))))
+ (start-process-shell-command "notmuch-pipe-command" "*notmuch-pipe*" shell-command)))
(defun notmuch-show-add-tag (&rest toadd)
"Add a tag to the current message."