unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch.el: add a submap (on "z" for "ztash") to stash things.
@ 2009-12-25 19:53 david
  2009-12-27  3:51 ` (no subject) david
  2010-02-12  3:01 ` Rebased and updated stash patches david
  0 siblings, 2 replies; 10+ messages in thread
From: david @ 2009-12-25 19:53 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@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.
---

One thing I find myself doing often is going into raw message mode in
order to grab a message-id. This patch automates that by letting you
stash the message id in the emacs kill-ring (and X clipboard, if
running under X).  It also allows the same for filename and tags.
It would be pretty trivial to add other similar commands for stashing 
other headers and parts of a message given a corresponding 
notmuch-show-get-foo function.

 notmuch.el |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 97914f2..53eb5a3 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,22 @@ 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 ()
+  (interactive)
+  (notmuch-show-do-stash (notmuch-show-get-message-id)))
+
+(defun notmuch-show-stash-filename ()
+  (interactive)
+  (notmuch-show-do-stash (notmuch-show-get-filename)))
+
+(defun notmuch-show-stash-tags ()
+  (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.7

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

end of thread, other threads:[~2010-02-20 20:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-25 19:53 [PATCH] notmuch.el: add a submap (on "z" for "ztash") to stash things david
2009-12-27  3:51 ` (no subject) david
2009-12-27  3:51   ` [PATCH 1/2] notmuch.el: add a submap (on "z" for "ztash") to stash things david
2009-12-27  3:51     ` [PATCH 2/2] notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix david
2010-02-12  3:01 ` Rebased and updated stash patches david
2010-02-12  3:01   ` [PATCH 1/2] notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix david
2010-02-12  3:01     ` [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things david
2010-02-12  3:56       ` Jameson Rollins
2010-02-12 15:50       ` Michal Sojka
2010-02-20 20:31       ` Carl Worth

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).