unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* feature request: highlighting of partial jump sequences
@ 2016-10-08 15:09 David Bremner
  2016-10-08 23:00 ` [PATCH] emacs: jump: make multilevel keys do multilevel jump Mark Walters
  2016-10-17 17:53 ` feature request: highlighting of partial jump sequences Matt Armstrong
  0 siblings, 2 replies; 10+ messages in thread
From: David Bremner @ 2016-10-08 15:09 UTC (permalink / raw)
  To: notmuch


I (very) recently started using longer key sequences with Mark's
tag-jump feature. One thing I miss from a similar feature in org-mode
(e.g. exporting) is some visual feedback on what I have typed so far,
and thus what my next key is likely to do.

d

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

* [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-08 15:09 feature request: highlighting of partial jump sequences David Bremner
@ 2016-10-08 23:00 ` Mark Walters
  2016-10-09  2:37   ` David Bremner
  2016-10-17 17:53 ` feature request: highlighting of partial jump sequences Matt Armstrong
  1 sibling, 1 reply; 10+ messages in thread
From: Mark Walters @ 2016-10-08 23:00 UTC (permalink / raw)
  To: notmuch

notmuch jump allows the user to specify a key sequence rather than
just a single key for its bindings. However, it doesn't show what has
already been typed so it can be difficult to see what has
happened. This makes each key press appear, and the jump menu reduce
to the possible follow up keys.
---

bremner pointed out that multi-key key sequences were unclear in
tag-jump (and other jump uses). This makes it clearer by displaying
the keys typed so far and reducing the displayed options based on what
has been typed so far. Backspace is bound to remove the last typed
character and return to the previous level. Slightly unfortunately
emacs likes to call backspace "DEL".

There is noticeable increase in the complexity of the jump
code. However, in the common case of all key sequences being single
keys then it looks exactly as before.

Finally there are a couple of corner cases that are of the form "don't
do that". The first is if the user specifies two bindings one of which
is a prefix of the other (I don't know what happens before but we now
just take the shorter one). The second is that the user can't bind
backspace in any submap (i.e. as the second or subsequent key of a
key-sequence) as it is used for going back up a level.

Best wishes

Mark




emacs/notmuch-jump.el | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 963253c..b7df1c2 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -104,7 +104,7 @@ not appear in the pop-up buffer.
 	   (copy-sequence minibuffer-prompt-properties)
 	   'face))
 	 ;; Build the keymap with our bindings
-	 (minibuffer-map (notmuch-jump--make-keymap action-map))
+	 (minibuffer-map (notmuch-jump--make-keymap action-map prompt))
 	 ;; The bindings save the the action in notmuch-jump--action
 	 (notmuch-jump--action nil))
     ;; Read the action
@@ -164,15 +164,43 @@ buffer."
     map)
   "Base keymap for notmuch-jump's minibuffer keymap.")
 
-(defun notmuch-jump--make-keymap (action-map)
+(defun notmuch-jump--make-keymap (action-map prompt)
   "Translate ACTION-MAP into a minibuffer keymap."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-jump-minibuffer-map)
     (dolist (action action-map)
-      (define-key map (first action)
-	`(lambda () (interactive)
-	   (setq notmuch-jump--action ',(third action))
-	   (exit-minibuffer))))
+      (if (= (length (first action)) 1)
+	  (define-key map (first action)
+	    `(lambda () (interactive)
+	       (setq notmuch-jump--action ',(third action))
+	       (exit-minibuffer)))))
+    ;; By doing this in two passes (and checking if we already have a
+    ;; binding) we avoid problems if the user specifies a binding which
+    ;; is a prefix of another binding.
+    (dolist (action action-map)
+      (if (> (length (first action)) 1)
+	  (let* ((key (elt (first action) 0))
+		 (keystr (string key))
+		 (new-prompt (concat prompt (format-kbd-macro keystr) " "))
+		 (action-submap nil))
+	    (unless (lookup-key map keystr)
+	      (dolist (act action-map)
+		(when (= key (elt (first act) 0))
+		  (push (list (substring (first act) 1)
+			      (second act)
+			      (third act))
+			action-submap)))
+	      ;; We deal with backspace specially
+	      (push (list (kbd "<backspace>")
+			  "Backup"
+			  `,(apply-partially #'notmuch-jump action-map prompt))
+		    action-submap)
+	      (setq action-submap (nreverse action-submap))
+	      (define-key map keystr
+		`(lambda () (interactive)
+		   (setq notmuch-jump--action
+			 ',(apply-partially #'notmuch-jump action-submap new-prompt))
+		   (exit-minibuffer)))))))
     map))
 
 ;;
-- 
2.1.4

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

* Re: [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-08 23:00 ` [PATCH] emacs: jump: make multilevel keys do multilevel jump Mark Walters
@ 2016-10-09  2:37   ` David Bremner
  2016-10-09  7:37     ` Mark Walters
  0 siblings, 1 reply; 10+ messages in thread
From: David Bremner @ 2016-10-09  2:37 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> notmuch jump allows the user to specify a key sequence rather than
> just a single key for its bindings. However, it doesn't show what has
> already been typed so it can be difficult to see what has
> happened. This makes each key press appear, and the jump menu reduce
> to the possible follow up keys.
> ---
>
> bremner pointed out that multi-key key sequences were unclear in
> tag-jump (and other jump uses). This makes it clearer by displaying
> the keys typed so far and reducing the displayed options based on what
> has been typed so far. Backspace is bound to remove the last typed
> character and return to the previous level. Slightly unfortunately
> emacs likes to call backspace "DEL".

I like the functionality a lot, but some things backspace/DEL caught my
attention

1) It would be nice if k <backspace> aborted the sequence (although it
doesn't claim it will, so technically not a bug)

2) it doesn't seem to work correctly in emacs -nw (I'm testing in emacs
25.1 atm, in case that's relevant). I just get a message
"delete-backward-char: Text is read-only"

There is some information about delete and backspace

      https://www.gnu.org/software/emacs/manual/elisp.html#Function-Keys

The cariable local-function-key map also seems relevant.

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

* [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-09  2:37   ` David Bremner
@ 2016-10-09  7:37     ` Mark Walters
  2016-10-09 11:46       ` David Bremner
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Walters @ 2016-10-09  7:37 UTC (permalink / raw)
  To: notmuch

notmuch jump allows the user to specify a key sequence rather than
just a single key for its bindings. However, it doesn't show what has
already been typed so it can be difficult to see what has
happened. This makes each key press appear, and the jump menu reduce
to the possible follow up keys.

We also bind backspace (emacs symbol DEL) to go back up a level in the
subjumpmaps, and to exit from the top level.
---

This fixes both the bug bremner pointed out about backspace not
working in a terminal and the bug/enhancement about exiting when
backspace is pressed at the top level.

[Note it is possible to (mis)configure a terminal so that this does not
work -- eg by setting backspace to do C-h -- but the standard C-?
should be fine.]

Best wishes

Mark


emacs/notmuch-jump.el | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 963253c..de14110 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -104,7 +104,7 @@ not appear in the pop-up buffer.
 	   (copy-sequence minibuffer-prompt-properties)
 	   'face))
 	 ;; Build the keymap with our bindings
-	 (minibuffer-map (notmuch-jump--make-keymap action-map))
+	 (minibuffer-map (notmuch-jump--make-keymap action-map prompt))
 	 ;; The bindings save the the action in notmuch-jump--action
 	 (notmuch-jump--action nil))
     ;; Read the action
@@ -161,18 +161,47 @@ buffer."
     (set-keymap-parent map minibuffer-local-map)
     ;; Make this like a special-mode keymap, with no self-insert-command
     (suppress-keymap map)
+    (define-key map (kbd "DEL") 'exit-minibuffer)
     map)
   "Base keymap for notmuch-jump's minibuffer keymap.")
 
-(defun notmuch-jump--make-keymap (action-map)
+(defun notmuch-jump--make-keymap (action-map prompt)
   "Translate ACTION-MAP into a minibuffer keymap."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-jump-minibuffer-map)
     (dolist (action action-map)
-      (define-key map (first action)
-	`(lambda () (interactive)
-	   (setq notmuch-jump--action ',(third action))
-	   (exit-minibuffer))))
+      (if (= (length (first action)) 1)
+	  (define-key map (first action)
+	    `(lambda () (interactive)
+	       (setq notmuch-jump--action ',(third action))
+	       (exit-minibuffer)))))
+    ;; By doing this in two passes (and checking if we already have a
+    ;; binding) we avoid problems if the user specifies a binding which
+    ;; is a prefix of another binding.
+    (dolist (action action-map)
+      (if (> (length (first action)) 1)
+	  (let* ((key (elt (first action) 0))
+		 (keystr (string key))
+		 (new-prompt (concat prompt (format-kbd-macro keystr) " "))
+		 (action-submap nil))
+	    (unless (lookup-key map keystr)
+	      (dolist (act action-map)
+		(when (= key (elt (first act) 0))
+		  (push (list (substring (first act) 1)
+			      (second act)
+			      (third act))
+			action-submap)))
+	      ;; We deal with backspace specially
+	      (push (list (kbd "DEL")
+			  "Backup"
+			  `,(apply-partially #'notmuch-jump action-map prompt))
+		    action-submap)
+	      (setq action-submap (nreverse action-submap))
+	      (define-key map keystr
+		`(lambda () (interactive)
+		   (setq notmuch-jump--action
+			 ',(apply-partially #'notmuch-jump action-submap new-prompt))
+		   (exit-minibuffer)))))))
     map))
 
 ;;
-- 
2.1.4

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

* Re: [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-09  7:37     ` Mark Walters
@ 2016-10-09 11:46       ` David Bremner
  2016-10-15 11:50         ` Mark Walters
  0 siblings, 1 reply; 10+ messages in thread
From: David Bremner @ 2016-10-09 11:46 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

>
> [Note it is possible to (mis)configure a terminal so that this does not
> work -- eg by setting backspace to do C-h -- but the standard C-?
> should be fine.]

This seems acceptable to me, but I'm curious what more serious emacs-in-terminal
users think.

> +			  `,(apply-partially #'notmuch-jump action-map prompt))

What is `, supposed to do here? To my limited understanding of
quasiquoting it looks like a nop.

d

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

* [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-09 11:46       ` David Bremner
@ 2016-10-15 11:50         ` Mark Walters
  2016-10-16  1:01           ` David Bremner
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Walters @ 2016-10-15 11:50 UTC (permalink / raw)
  To: notmuch

notmuch jump allows the user to specify a key sequence rather than
just a single key for its bindings. However, it doesn't show what has
already been typed so it can be difficult to see what has
happened. This makes each key press appear, and the jump menu reduce
to the possible follow up keys.

We also bind backspace (emacs symbol DEL) to go back up a level in the
subjumpmaps, and to exit from the top level.
---

This removes the no-op `,() construct from the previous version of
this patch, but is otherwise unchanged.

Best wishes

Mark
            
 emacs/notmuch-jump.el | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 963253c..3e20b8c 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -104,7 +104,7 @@ not appear in the pop-up buffer.
 	   (copy-sequence minibuffer-prompt-properties)
 	   'face))
 	 ;; Build the keymap with our bindings
-	 (minibuffer-map (notmuch-jump--make-keymap action-map))
+	 (minibuffer-map (notmuch-jump--make-keymap action-map prompt))
 	 ;; The bindings save the the action in notmuch-jump--action
 	 (notmuch-jump--action nil))
     ;; Read the action
@@ -161,18 +161,47 @@ buffer."
     (set-keymap-parent map minibuffer-local-map)
     ;; Make this like a special-mode keymap, with no self-insert-command
     (suppress-keymap map)
+    (define-key map (kbd "DEL") 'exit-minibuffer)
     map)
   "Base keymap for notmuch-jump's minibuffer keymap.")
 
-(defun notmuch-jump--make-keymap (action-map)
+(defun notmuch-jump--make-keymap (action-map prompt)
   "Translate ACTION-MAP into a minibuffer keymap."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-jump-minibuffer-map)
     (dolist (action action-map)
-      (define-key map (first action)
-	`(lambda () (interactive)
-	   (setq notmuch-jump--action ',(third action))
-	   (exit-minibuffer))))
+      (if (= (length (first action)) 1)
+	  (define-key map (first action)
+	    `(lambda () (interactive)
+	       (setq notmuch-jump--action ',(third action))
+	       (exit-minibuffer)))))
+    ;; By doing this in two passes (and checking if we already have a
+    ;; binding) we avoid problems if the user specifies a binding which
+    ;; is a prefix of another binding.
+    (dolist (action action-map)
+      (if (> (length (first action)) 1)
+	  (let* ((key (elt (first action) 0))
+		 (keystr (string key))
+		 (new-prompt (concat prompt (format-kbd-macro keystr) " "))
+		 (action-submap nil))
+	    (unless (lookup-key map keystr)
+	      (dolist (act action-map)
+		(when (= key (elt (first act) 0))
+		  (push (list (substring (first act) 1)
+			      (second act)
+			      (third act))
+			action-submap)))
+	      ;; We deal with backspace specially
+	      (push (list (kbd "DEL")
+			  "Backup"
+			  (apply-partially #'notmuch-jump action-map prompt))
+		    action-submap)
+	      (setq action-submap (nreverse action-submap))
+	      (define-key map keystr
+		`(lambda () (interactive)
+		   (setq notmuch-jump--action
+			 ',(apply-partially #'notmuch-jump action-submap new-prompt))
+		   (exit-minibuffer)))))))
     map))
 
 ;;
-- 
2.1.4

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

* Re: [PATCH] emacs: jump: make multilevel keys do multilevel jump
  2016-10-15 11:50         ` Mark Walters
@ 2016-10-16  1:01           ` David Bremner
  0 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2016-10-16  1:01 UTC (permalink / raw)
  To: Mark Walters, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> notmuch jump allows the user to specify a key sequence rather than
> just a single key for its bindings. However, it doesn't show what has
> already been typed so it can be difficult to see what has
> happened. This makes each key press appear, and the jump menu reduce
> to the possible follow up keys.
>
> We also bind backspace (emacs symbol DEL) to go back up a level in the
> subjumpmaps, and to exit from the top level.

pushed to master

d

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

* Re: feature request: highlighting of partial jump sequences
  2016-10-08 15:09 feature request: highlighting of partial jump sequences David Bremner
  2016-10-08 23:00 ` [PATCH] emacs: jump: make multilevel keys do multilevel jump Mark Walters
@ 2016-10-17 17:53 ` Matt Armstrong
  2016-10-18  9:38   ` Mark Walters
  1 sibling, 1 reply; 10+ messages in thread
From: Matt Armstrong @ 2016-10-17 17:53 UTC (permalink / raw)
  To: David Bremner, notmuch

David Bremner <david@tethera.net> writes:

> I (very) recently started using longer key sequences with Mark's
> tag-jump feature. One thing I miss from a similar feature in org-mode
> (e.g. exporting) is some visual feedback on what I have typed so far,
> and thus what my next key is likely to do.

Tangentially, has an alternative UI been considered such as something
based on ido?  I mention this merely because building on something
standard is probably going to be less work and more familiar to users.

The other day I was thinking that if no "jumps" are configured, and the
user has ido mode on, selecting among all saved searches with ido would
be a natural thing for 'j' to do.  Some users (probably me) may then
never bother to set up shortcut keys.

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

* Re: feature request: highlighting of partial jump sequences
  2016-10-17 17:53 ` feature request: highlighting of partial jump sequences Matt Armstrong
@ 2016-10-18  9:38   ` Mark Walters
  2016-10-18 17:07     ` Matt Armstrong
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Walters @ 2016-10-18  9:38 UTC (permalink / raw)
  To: Matt Armstrong, David Bremner, notmuch

On Mon, 17 Oct 2016, Matt Armstrong <marmstrong@google.com> wrote:
> David Bremner <david@tethera.net> writes:
>
>> I (very) recently started using longer key sequences with Mark's
>> tag-jump feature. One thing I miss from a similar feature in org-mode
>> (e.g. exporting) is some visual feedback on what I have typed so far,
>> and thus what my next key is likely to do.
>
> Tangentially, has an alternative UI been considered such as something
> based on ido?  I mention this merely because building on something
> standard is probably going to be less work and more familiar to users.

The nice feature of jump is that it is very fast to type: I can get to
my common saved searches in two keystrokes. I think the multistep is
more specialised and probably more useful for tag-jump -- I imagine uses
along the lines of k (to enter tag jump) n to enter notmuch:: prefixed
tags, and then a letter for the appropriate notmuch:: tag.

> The other day I was thinking that if no "jumps" are configured, and the
> user has ido mode on, selecting among all saved searches with ido would
> be a natural thing for 'j' to do.  Some users (probably me) may then
> never bother to set up shortcut keys.

I think this would make it very confusing when/if people did add a saved
jump. If we want to offer something like ido completion then I would
suggest putting it under a further character in the jump map. eg j j
would lead to ido completion, and then if people add normal jump short
cuts everything stays the same. (We would want to make sure that user
jump binding override this j binding so that we don't break anybodies
existing setup.)

Best wishes

Mark

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

* Re: feature request: highlighting of partial jump sequences
  2016-10-18  9:38   ` Mark Walters
@ 2016-10-18 17:07     ` Matt Armstrong
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Armstrong @ 2016-10-18 17:07 UTC (permalink / raw)
  To: Mark Walters, David Bremner, notmuch

Mark Walters <markwalters1009@gmail.com> writes:

> On Mon, 17 Oct 2016, Matt Armstrong <marmstrong@google.com> wrote:
>> David Bremner <david@tethera.net> writes:
>>
>>> I (very) recently started using longer key sequences with Mark's
>>> tag-jump feature. One thing I miss from a similar feature in org-mode
>>> (e.g. exporting) is some visual feedback on what I have typed so far,
>>> and thus what my next key is likely to do.
>>
>> Tangentially, has an alternative UI been considered such as something
>> based on ido?  I mention this merely because building on something
>> standard is probably going to be less work and more familiar to users.
>
> The nice feature of jump is that it is very fast to type: I can get to
> my common saved searches in two keystrokes. I think the multistep is
> more specialised and probably more useful for tag-jump -- I imagine
> uses along the lines of k (to enter tag jump) n to enter notmuch::
> prefixed tags, and then a letter for the appropriate notmuch:: tag.
>
>> The other day I was thinking that if no "jumps" are configured, and the
>> user has ido mode on, selecting among all saved searches with ido would
>> be a natural thing for 'j' to do.  Some users (probably me) may then
>> never bother to set up shortcut keys.
>
> I think this would make it very confusing when/if people did add a saved
> jump. If we want to offer something like ido completion then I would
> suggest putting it under a further character in the jump map. eg j j
> would lead to ido completion, and then if people add normal jump short
> cuts everything stays the same. (We would want to make sure that user
> jump binding override this j binding so that we don't break anybodies
> existing setup.)
>
> Best wishes

Mark, no disagreement from me.  I might, someday, hack up something
based on ido (or an ido-like UI) to see how it works out.

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

end of thread, other threads:[~2016-10-18 17:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-08 15:09 feature request: highlighting of partial jump sequences David Bremner
2016-10-08 23:00 ` [PATCH] emacs: jump: make multilevel keys do multilevel jump Mark Walters
2016-10-09  2:37   ` David Bremner
2016-10-09  7:37     ` Mark Walters
2016-10-09 11:46       ` David Bremner
2016-10-15 11:50         ` Mark Walters
2016-10-16  1:01           ` David Bremner
2016-10-17 17:53 ` feature request: highlighting of partial jump sequences Matt Armstrong
2016-10-18  9:38   ` Mark Walters
2016-10-18 17:07     ` Matt Armstrong

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