unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/1] emacs: add '?' to some prefix keymaps to describe its bindings
@ 2013-08-24 12:15 Tomi Ollila
  2013-08-25 10:24 ` Mark Walters
  0 siblings, 1 reply; 2+ messages in thread
From: Tomi Ollila @ 2013-08-24 12:15 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

Added (private) function `notmuch--prefix-bindings' which wraps
`describe-prefix-bindings' to provide more suitable user interface for
showing the key sequences that follow a particular notmuch prefix
keymap invocation.

The key '?' in prefix keymaps `notmuch-search-stash-map',
`notmuch-show-stash-map' and `notmuch-show-part-map' is bound to this
function via `lambda' expression. By using this lambda expression the
pop-up binding description window shows '??' instead of
`notmuch--prefix-bindings' for the binding of '?' -- which suits our
needs perfectly.
---
 emacs/notmuch-lib.el  | 9 +++++++++
 emacs/notmuch-show.el | 2 ++
 emacs/notmuch.el      | 1 +
 3 files changed, 12 insertions(+)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 4796f17..8191aec 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -553,6 +553,15 @@ status."
        (message "%s" (error-message-string err))))
     (ignore-errors (delete-file err-file))))
 
+(defun notmuch--prefix-bindings ()
+  "Notmuch private wrapper for `describe-prefix-bindings'."
+  ;;(interactive)
+  (describe-prefix-bindings)
+  (pop-to-buffer "*Help*") ; XXX that's what describe-bindings-internal uses
+  (let ((buffer-read-only nil))
+    (goto-char (point-min))
+    (insert "\nPress 'q' to quit this window.\n\n")))
+
 ;; This variable is used only buffer local, but it needs to be
 ;; declared globally first to avoid compiler warnings.
 (defvar notmuch-show-process-crypto nil)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..98bf3d4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1248,6 +1248,7 @@ reset based on the original query."
     (define-key map "t" 'notmuch-show-stash-to)
     (define-key map "l" 'notmuch-show-stash-mlarchive-link)
     (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)
+    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
     map)
   "Submap for stash commands")
 (fset 'notmuch-show-stash-map notmuch-show-stash-map)
@@ -1258,6 +1259,7 @@ reset based on the original query."
     (define-key map "v" 'notmuch-show-view-part)
     (define-key map "o" 'notmuch-show-interactively-view-part)
     (define-key map "|" 'notmuch-show-pipe-part)
+    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
     map)
   "Submap for part commands")
 (fset 'notmuch-show-part-map notmuch-show-part-map)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f3ce840..3a115c8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -245,6 +245,7 @@ For a mouse binding, return nil."
 (defvar notmuch-search-stash-map
   (let ((map (make-sparse-keymap)))
     (define-key map "i" 'notmuch-search-stash-thread-id)
+    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
     map)
   "Submap for stash commands")
 (fset 'notmuch-search-stash-map notmuch-search-stash-map)
-- 
1.8.0

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

* Re: [PATCH 1/1] emacs: add '?' to some prefix keymaps to describe its bindings
  2013-08-24 12:15 [PATCH 1/1] emacs: add '?' to some prefix keymaps to describe its bindings Tomi Ollila
@ 2013-08-25 10:24 ` Mark Walters
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Walters @ 2013-08-25 10:24 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila


On Sat, 24 Aug 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> Added (private) function `notmuch--prefix-bindings' which wraps
> `describe-prefix-bindings' to provide more suitable user interface for
> showing the key sequences that follow a particular notmuch prefix
> keymap invocation.
>
> The key '?' in prefix keymaps `notmuch-search-stash-map',
> `notmuch-show-stash-map' and `notmuch-show-part-map' is bound to this
> function via `lambda' expression. By using this lambda expression the
> pop-up binding description window shows '??' instead of
> `notmuch--prefix-bindings' for the binding of '?' -- which suits our
> needs perfectly.

This looks good to me +1. 

[I think I would prefer docstrings to function names but getting that
does not seem to be easy so is probably not worth the effort.]

Best wishes

Mark


> ---
>  emacs/notmuch-lib.el  | 9 +++++++++
>  emacs/notmuch-show.el | 2 ++
>  emacs/notmuch.el      | 1 +
>  3 files changed, 12 insertions(+)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 4796f17..8191aec 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -553,6 +553,15 @@ status."
>         (message "%s" (error-message-string err))))
>      (ignore-errors (delete-file err-file))))
>  
> +(defun notmuch--prefix-bindings ()
> +  "Notmuch private wrapper for `describe-prefix-bindings'."
> +  ;;(interactive)
> +  (describe-prefix-bindings)
> +  (pop-to-buffer "*Help*") ; XXX that's what describe-bindings-internal uses
> +  (let ((buffer-read-only nil))
> +    (goto-char (point-min))
> +    (insert "\nPress 'q' to quit this window.\n\n")))
> +
>  ;; This variable is used only buffer local, but it needs to be
>  ;; declared globally first to avoid compiler warnings.
>  (defvar notmuch-show-process-crypto nil)
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 82b70ba..98bf3d4 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1248,6 +1248,7 @@ reset based on the original query."
>      (define-key map "t" 'notmuch-show-stash-to)
>      (define-key map "l" 'notmuch-show-stash-mlarchive-link)
>      (define-key map "L" 'notmuch-show-stash-mlarchive-link-and-go)
> +    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
>      map)
>    "Submap for stash commands")
>  (fset 'notmuch-show-stash-map notmuch-show-stash-map)
> @@ -1258,6 +1259,7 @@ reset based on the original query."
>      (define-key map "v" 'notmuch-show-view-part)
>      (define-key map "o" 'notmuch-show-interactively-view-part)
>      (define-key map "|" 'notmuch-show-pipe-part)
> +    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
>      map)
>    "Submap for part commands")
>  (fset 'notmuch-show-part-map notmuch-show-part-map)
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index f3ce840..3a115c8 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -245,6 +245,7 @@ For a mouse binding, return nil."
>  (defvar notmuch-search-stash-map
>    (let ((map (make-sparse-keymap)))
>      (define-key map "i" 'notmuch-search-stash-thread-id)
> +    (define-key map "?" (lambda () (interactive) (notmuch--prefix-bindings)))
>      map)
>    "Submap for stash commands")
>  (fset 'notmuch-search-stash-map notmuch-search-stash-map)
> -- 
> 1.8.0
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

end of thread, other threads:[~2013-08-26 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-24 12:15 [PATCH 1/1] emacs: add '?' to some prefix keymaps to describe its bindings Tomi Ollila
2013-08-25 10:24 ` Mark Walters

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