* [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
* (no subject)
2009-12-25 19:53 [PATCH] notmuch.el: add a submap (on "z" for "ztash") to stash things david
@ 2009-12-27 3:51 ` david
2009-12-27 3:51 ` [PATCH 1/2] notmuch.el: add a submap (on "z" for "ztash") to stash things david
2010-02-12 3:01 ` Rebased and updated stash patches david
1 sibling, 1 reply; 10+ messages in thread
From: david @ 2009-12-27 3:51 UTC (permalink / raw)
To: notmuch
Thanks to Micah Anderson on IRC for pointing out that the previous
version of this patch broke '?' in notmuch-show mode. This was
arguably a bug in the notmuch help code, fixed in patch 2 of the
series. I wouldn't be surprised if 'map-keymap' could be used other
places in the code, but I kept things minimal-ish. The first patch
has been revised to actually include documentation strings (blush).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.
2009-12-27 3:51 ` (no subject) david
@ 2009-12-27 3:51 ` 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
0 siblings, 1 reply; 10+ messages in thread
From: david @ 2009-12-27 3:51 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.
---
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix
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 ` david
0 siblings, 0 replies; 10+ messages in thread
From: david @ 2009-12-27 3:51 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
From: David Bremner <bremner@unb.ca>
The previous version would crash when a key was bound to a sparse
keymap, since apparently these are not straightforward lists. The
usage of map-keymap is a bit obscure: it only has side-effects, no
return value.
---
notmuch.el | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index 8df0778..7b058de 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -846,8 +846,12 @@ For a mouse binding, return nil."
(if (mouse-event-p key)
nil
(if (keymapp action)
- (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key))))
- (mapconcat substitute (cdr action) "\n"))
+ (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key)))
+ (as-list))
+ (map-keymap (lambda (a b)
+ (push (cons a b) as-list))
+ action)
+ (mapconcat substitute as-list "\n"))
(concat prefix (format-kbd-macro (vector key))
"\t"
(notmuch-documentation-first-line action))))))
--
1.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Rebased and updated stash patches.
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
@ 2010-02-12 3:01 ` 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
1 sibling, 1 reply; 10+ messages in thread
From: david @ 2010-02-12 3:01 UTC (permalink / raw)
To: notmuch
These patches let you header fields and similar into the emacs kill-ring
(and the X11 clipboard/selection, if things are setup right).
Patch 1/2 is actually a bug fix to master, unchanged since last time.
The bug didn't manifest because no submaps were used.
Patch 2/2 is rebased against current master and several more commands are provided.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] notmuch.el: convert sparse keymap to a list in notmuch-substitute-one-command-key-with-prefix
2010-02-12 3:01 ` Rebased and updated stash patches david
@ 2010-02-12 3:01 ` david
2010-02-12 3:01 ` [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things david
0 siblings, 1 reply; 10+ messages in thread
From: david @ 2010-02-12 3:01 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
From: David Bremner <bremner@unb.ca>
The previous version would crash when a key was bound to a sparse
keymap, since apparently these are not straightforward lists. The
usage of map-keymap is a bit obscure: it only has side-effects, no
return value.
---
notmuch.el | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index d2a3b1b..60ef592 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -984,8 +984,12 @@ For a mouse binding, return nil."
(if (mouse-event-p key)
nil
(if (keymapp action)
- (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key))))
- (mapconcat substitute (cdr action) "\n"))
+ (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key)))
+ (as-list))
+ (map-keymap (lambda (a b)
+ (push (cons a b) as-list))
+ action)
+ (mapconcat substitute as-list "\n"))
(concat prefix (format-kbd-macro (vector key))
"\t"
(notmuch-documentation-first-line action))))))
--
1.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.
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 ` david
2010-02-12 3:56 ` Jameson Rollins
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: david @ 2010-02-12 3:01 UTC (permalink / raw)
To: notmuch; +Cc: David Bremner
From: David Bremner <bremner@unb.ca>
Provide key bindings for stuffing various RFC822 header fields and other metadata
into the emacs kill-ring as text. The bindings are as follows:
z F notmuch-show-stash-filename
z T notmuch-show-stash-tags
z c notmuch-show-stash-cc
z d notmuch-show-stash-date
z f notmuch-show-stash-from
z m notmuch-show-stash-message-id
z s notmuch-show-stash-subject
z t notmuch-show-stash-to
---
notmuch.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/notmuch.el b/notmuch.el
index 60ef592..faca26d 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -51,6 +51,22 @@
(require 'mm-view)
(require 'message)
+(defvar notmuch-show-stash-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map "c" 'notmuch-show-stash-cc)
+ (define-key map "d" 'notmuch-show-stash-date)
+ (define-key map "F" 'notmuch-show-stash-filename)
+ (define-key map "f" 'notmuch-show-stash-from)
+ (define-key map "m" 'notmuch-show-stash-message-id)
+ (define-key map "s" 'notmuch-show-stash-subject)
+ (define-key map "T" 'notmuch-show-stash-tags)
+ (define-key map "t" 'notmuch-show-stash-to)
+ 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)
@@ -80,6 +96,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)
@@ -1074,6 +1091,50 @@ 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-cc ()
+ "Copy CC field of current message to kill-ring."
+ (interactive)
+ (notmuch-show-do-stash (notmuch-show-get-cc)))
+
+(defun notmuch-show-stash-date ()
+ "Copy date of current message to kill-ring."
+ (interactive)
+ (notmuch-show-do-stash (notmuch-show-get-date)))
+
+(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-from ()
+ "Copy From address of current message to kill-ring."
+ (interactive)
+ (notmuch-show-do-stash (notmuch-show-get-from)))
+
+(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-subject ()
+ "Copy Subject field of current message to kill-ring."
+ (interactive)
+ (notmuch-show-do-stash (notmuch-show-get-subject)))
+
+(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) ",")))
+
+(defun notmuch-show-stash-to ()
+ "Copy To address of current message to kill-ring."
+ (interactive)
+ (notmuch-show-do-stash (notmuch-show-get-to)))
+
; Make show mode a bit prettier, highlighting URLs and using word wrap
(defun notmuch-show-pretty-hook ()
--
1.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.
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
2 siblings, 0 replies; 10+ messages in thread
From: Jameson Rollins @ 2010-02-12 3:56 UTC (permalink / raw)
To: david, notmuch; +Cc: David Bremner
[-- Attachment #1: Type: text/plain, Size: 577 bytes --]
On Thu, 11 Feb 2010 23:01:08 -0400, david@tethera.net wrote:
> From: David Bremner <bremner@unb.ca>
>
> Provide key bindings for stuffing various RFC822 header fields and other metadata
> into the emacs kill-ring as text. The bindings are as follows:
>
> z F notmuch-show-stash-filename
> z T notmuch-show-stash-tags
> z c notmuch-show-stash-cc
> z d notmuch-show-stash-date
> z f notmuch-show-stash-from
> z m notmuch-show-stash-message-id
> z s notmuch-show-stash-subject
> z t notmuch-show-stash-to
Great new emacs UI feature. Love it.
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.
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
2 siblings, 0 replies; 10+ messages in thread
From: Michal Sojka @ 2010-02-12 15:50 UTC (permalink / raw)
To: david, notmuch; +Cc: David Bremner
On Thu, 11 Feb 2010 23:01:08 -0400, david@tethera.net wrote:
> From: David Bremner <bremner@unb.ca>
>
> Provide key bindings for stuffing various RFC822 header fields and other metadata
> into the emacs kill-ring as text. The bindings are as follows:
>
> z F notmuch-show-stash-filename
> z T notmuch-show-stash-tags
> z c notmuch-show-stash-cc
> z d notmuch-show-stash-date
> z f notmuch-show-stash-from
> z m notmuch-show-stash-message-id
> z s notmuch-show-stash-subject
> z t notmuch-show-stash-to
Great! I've always wished to have this.
Michal
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] notmuch.el: add a submap (on "z" for "ztash") to stash things.
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
2 siblings, 0 replies; 10+ messages in thread
From: Carl Worth @ 2010-02-20 20:31 UTC (permalink / raw)
To: david, notmuch; +Cc: David Bremner
[-- Attachment #1: Type: text/plain, Size: 841 bytes --]
On Thu, 11 Feb 2010 23:01:08 -0400, david@tethera.net wrote:
> From: David Bremner <bremner@unb.ca>
>
> Provide key bindings for stuffing various RFC822 header fields and other metadata
> into the emacs kill-ring as text. The bindings are as follows:
A fantastic feature, David! Thanks so much!
I've now applied this, (and pushed it out). As we discussed in IRC, I
also changed the keybinding from 'z' to 'c'.
So, for everyone who didn't pick up on this feature, you can now use the
keybinding 'c i' to copy a message ID when viewing a message within
emacs. Then, if using X, you can immediately use the middle-mouse button
(or similar) to paste that message into an application of choice. It's
very convenient.
There are also similar keybindings for copying out other portions of the
message header. Enjoy!
-Carl
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [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).