[PATCH 0/3] Add notmuch-pick to contrib

Mark Walters markwalters1009 at gmail.com
Sat Dec 1 13:03:06 PST 2012


Hi

On Sun, 28 Oct 2012, David Bremner <david at tethera.net> wrote:
> Mark Walters <markwalters1009 at gmail.com> writes:
>
>> This is a new version of notmuch-pick (previous version at
>> id:"1343164911-31589-1-git-send-email-markwalters1009 at gmail.com")following
>> suggestions of Tomi and David in that thread. The main change is that
>> it is now entirely self contained in contrib: all the user needs to do
>> is copy the notmuch-pick.el somewhere in the emacs load path and add
>> (require 'notmuch-pick nil t) to their .emacs file.
>
> I have pushed this to contrib.
>
> We do need tests before this goes mainline. What about (untested) having
> the tests in contrib/notmuch-pick for now, including as needed from
> ../../test.
>
> We should mention it in NEWS; at this point I think it is reasonable to
> expect to do at least one release with pick in contrib.
>
> As a vague feature request, what about forwarding unknown keys to
> the notmuch-show buffer?

Here is an implementation of forwarding unknown keys to the show
buffer. The main pass-through part is based on an idea of David's on
irc. 

The implementation is not perfect but  might be sufficiently good
to be worth adding.

I can't easily see how to decide if a key is unknown because that isn't
really the right question: almost all keys are bound by the global emacs
keymap and some of those bindings we want to use (eg like <down> for
next line). Keys like "t" etc are also bound to "insert t" but those
flag an error as the buffer is readonly. It might be possible to hook
into things from that "error" but I couldn't see how to make it work.

Instead this works the other way round: it takes the notmuch-show
keymap, pulls them all into the pick keymap (with a wrapper so the
action takes place in the message-pane), and then adds the pick
keybindings (so they overwrite show-mode ones when the overlap).

One question is what to do with the fall through if the pick-message
pane is not open: I have opted for opening the pane with the current
message, running the appropriate show command, and closing the current
pane. This means that things like "view all attachments (v)" or "stash
message id (c i)" work regardless of whether the message pane is open.

Anyway what does anyone think?

Oh one last thing: it does somewhat mess up the "help" for notmuch pick.

Best wishes

Mark


---
 contrib/notmuch-pick/notmuch-pick.el |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
index 755cbbc..cded5a1 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -166,9 +166,25 @@
 (defvar notmuch-pick-process-state nil
   "Parsing state of the search process filter.")
 
+(defun notmuch-pick-message-buffer-command ()
+  "Pass key through to show pane"
+  (interactive)
+  (let ((command (lookup-key notmuch-show-mode-map (this-command-keys)))
+	(split-pane (window-live-p notmuch-pick-message-window)))
+    (unless split-pane
+      (notmuch-pick-show-message))
+    (with-current-buffer notmuch-pick-message-buffer
+      (funcall command))
+    (unless split-pane
+      (notmuch-pick-close-message-window))))
 
 (defvar notmuch-pick-mode-map
   (let ((map (make-sparse-keymap)))
+    ;; This has to come first so it gets overwritten by pick's own
+    ;; commands.
+    (loop for seq being the key-seqs of notmuch-show-mode-map
+	  do
+	  (define-key map seq 'notmuch-pick-message-buffer-command))
     (define-key map [mouse-1] 'notmuch-pick-show-message)
     (define-key map "q" 'notmuch-pick-quit)
     (define-key map "x" 'notmuch-pick-quit)
-- 
1.7.9.1






More information about the notmuch mailing list