[notmuch] [PATCH 1/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.

david at tethera.net david at tethera.net
Sat Dec 26 19:51:16 PST 2009


From: David Bremner <bremner at unb.ca>

Provide key bindings for stuffing everything with a notmuch-show-get-foo
function into the emacs kill-ring as text.

Currently this is just message-id, filename, and tags.
---
 notmuch.el |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 97914f2..8df0778 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -51,6 +51,17 @@
 (require 'mm-view)
 (require 'message)
 
+(defvar notmuch-show-stash-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "m" 'notmuch-show-stash-message-id)
+    (define-key map "F" 'notmuch-show-stash-filename)
+    (define-key map "T" 'notmuch-show-stash-tags)
+    map)
+  "Submap for stash commands"
+  )
+
+(fset 'notmuch-show-stash-map notmuch-show-stash-map)
+
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "?" 'notmuch-help)
@@ -78,6 +89,7 @@
     (define-key map "n" 'notmuch-show-next-message)
     (define-key map (kbd "DEL") 'notmuch-show-rewind)
     (define-key map " " 'notmuch-show-advance-marking-read-and-archiving)
+    (define-key map "z" 'notmuch-show-stash-map)
     map)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
@@ -920,6 +932,25 @@ All currently available key bindings:
   :options '(hl-line-mode)
   :group 'notmuch)
 
+(defun notmuch-show-do-stash (text)
+    (kill-new text)
+    (message (concat "Saved " text)))
+
+(defun notmuch-show-stash-message-id ()
+  "Copy message-id of current message to kill-ring."
+  (interactive)
+  (notmuch-show-do-stash (notmuch-show-get-message-id)))
+
+(defun notmuch-show-stash-filename ()
+  "Copy filename of current message to kill-ring."
+  (interactive)
+  (notmuch-show-do-stash (notmuch-show-get-filename)))
+
+(defun notmuch-show-stash-tags ()
+  "Copy tags of current message to kill-ring as a comma separated list."
+  (interactive)
+  (notmuch-show-do-stash (mapconcat 'identity (notmuch-show-get-tags) ",")))
+
 ; Make show mode a bit prettier, highlighting URLs and using word wrap
 
 (defun notmuch-show-pretty-hook ()
-- 
1.6.5



More information about the notmuch mailing list