unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: hello: display jump key next to saved search when available
@ 2015-12-13 18:24 Jani Nikula
  2015-12-13 19:09 ` Andrew Burgess
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jani Nikula @ 2015-12-13 18:24 UTC (permalink / raw)
  To: notmuch

Display the shortcut jump key next to the saved search name in notmuch
hello, if one is defined for the saved search.

---

This is probably something with infinite bikeshedding
potential. Therefore I just quickly hacked something together as a
proof of concept. This displays the jump keys like this:

	154 Inbox [j i]

Maybe the space between "j" and the key is unnecessary? Maybe the "j"
itself is unnecessary? Maybe the brackets are unnecessary? Maybe it
could use some color? Does displaying these need to be customizable?
Etc?
---
 emacs/notmuch-hello.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 738baad23b20..3c5440331669 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -578,7 +578,9 @@ with `notmuch-hello-query-counts'."
 				     (oldest-first t)
 				     (otherwise notmuch-search-oldest-first)))
 		     (search-type (eq (plist-get elem :search-type) 'tree))
-		     (msg-count (plist-get elem :count)))
+		     (msg-count (plist-get elem :count))
+		     (key (plist-get elem :key))
+		     (shortcut (if key (format " [j %s]" key) nil)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
 		(widget-create 'push-button
@@ -587,8 +589,10 @@ with `notmuch-hello-query-counts'."
 			       :notmuch-search-oldest-first oldest-first
 			       :notmuch-search-type search-type
 			       name)
+		(when shortcut
+		  (widget-insert shortcut))
 		(setq column-indent
-		      (1+ (max 0 (- column-width (length name)))))))
+		      (1+ (max 0 (- column-width (length name) (length shortcut)))))))
 	    (setq count (1+ count))
 	    (when (eq (% count tags-per-line) 0)
 	      (setq column-indent 0)
-- 
2.1.4

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

* Re: [PATCH] emacs: hello: display jump key next to saved search when available
  2015-12-13 18:24 [PATCH] emacs: hello: display jump key next to saved search when available Jani Nikula
@ 2015-12-13 19:09 ` Andrew Burgess
  2015-12-20  9:26 ` [PATCH] emacs: jump: show key shortcut Mark Walters
  2016-02-07  9:20 ` [PATCH] emacs: hello: display jump key next to saved search when available David Edmondson
  2 siblings, 0 replies; 7+ messages in thread
From: Andrew Burgess @ 2015-12-13 19:09 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

* Jani Nikula <jani@nikula.org> [2015-12-13 20:24:03 +0200]:

> Display the shortcut jump key next to the saved search name in notmuch
> hello, if one is defined for the saved search.
> 
> ---
> 
> This is probably something with infinite bikeshedding
> potential. Therefore I just quickly hacked something together as a
> proof of concept. This displays the jump keys like this:
> 
> 	154 Inbox [j i]
> 
> Maybe the space between "j" and the key is unnecessary? Maybe the "j"
> itself is unnecessary? Maybe the brackets are unnecessary? Maybe it
> could use some color? Does displaying these need to be customizable?
> Etc?
> ---
>  emacs/notmuch-hello.el | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 738baad23b20..3c5440331669 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -578,7 +578,9 @@ with `notmuch-hello-query-counts'."
>  				     (oldest-first t)
>  				     (otherwise notmuch-search-oldest-first)))
>  		     (search-type (eq (plist-get elem :search-type) 'tree))
> -		     (msg-count (plist-get elem :count)))
> +		     (msg-count (plist-get elem :count))
> +		     (key (plist-get elem :key))
> +		     (shortcut (if key (format " [j %s]" key) nil)))

You should probably make use of `substitute-command-key' instead of
hard-coding the "j", something like (untested):

    (format (substitute-command-key " [\[notmuch-jump-search] %s]") key)

Thanks,
Andrew

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

* [PATCH] emacs: jump: show key shortcut
  2015-12-13 18:24 [PATCH] emacs: hello: display jump key next to saved search when available Jani Nikula
  2015-12-13 19:09 ` Andrew Burgess
@ 2015-12-20  9:26 ` Mark Walters
  2015-12-20 12:50   ` Jani Nikula
  2016-02-07  9:20 ` [PATCH] emacs: hello: display jump key next to saved search when available David Edmondson
  2 siblings, 1 reply; 7+ messages in thread
From: Mark Walters @ 2015-12-20  9:26 UTC (permalink / raw)
  To: notmuch

This shows the jump key shortcut in the hello screen -- it underlines
the letter, if it is present, in the search name.
---

In id:1450031043-24038-1-git-send-email-jani@nikula.org Jani suggested
showing jump key shortcuts in the hello screen. I like the idea but
found the method a little cluttered.

This is an alternative approach which underlines the relevant key in
the search name (if it occurs).  This is relatively unintrusive
(possibly even too hard to see) and is in line with how many other
applications show shortcuts.

I am guessing that most people choose a shortcut key with some
relevance to the search name (eg i for inbox) so in most cases I think
the shortcut will be shown. Of course multi-key shortcuts will not be shown.

If people think the underlining is too discreet then we could change the 'underline
below to '(:foreground "red") or similar.

Best wishes

Mark



emacs/notmuch-hello.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 8bde808..de77730 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -572,7 +572,9 @@ with `notmuch-hello-query-counts'."
 	      (if (> column-indent 0)
 		  (widget-insert (make-string column-indent ? )))
 	      (let* ((name (plist-get elem :name))
+		     (key (plist-get elem :key))
 		     (query (plist-get elem :query))
+
 		     (oldest-first (case (plist-get elem :sort-order)
 				     (newest-first nil)
 				     (oldest-first t)
@@ -581,6 +583,12 @@ with `notmuch-hello-query-counts'."
 		     (msg-count (plist-get elem :count)))
 		(widget-insert (format "%8s "
 				       (notmuch-hello-nice-number msg-count)))
+		(save-match-data
+		  (let ((case-fold-search nil))
+		    (when (and key (string-match key name))
+		      (add-face-text-property (match-beginning 0) (match-end 0)
+					      'underline
+					      nil name))))
 		(widget-create 'push-button
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
-- 
2.1.4

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

* Re: [PATCH] emacs: jump: show key shortcut
  2015-12-20  9:26 ` [PATCH] emacs: jump: show key shortcut Mark Walters
@ 2015-12-20 12:50   ` Jani Nikula
  0 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2015-12-20 12:50 UTC (permalink / raw)
  To: Mark Walters, notmuch

On Sun, 20 Dec 2015, Mark Walters <markwalters1009@gmail.com> wrote:
> This shows the jump key shortcut in the hello screen -- it underlines
> the letter, if it is present, in the search name.
> ---
>
> In id:1450031043-24038-1-git-send-email-jani@nikula.org Jani suggested
> showing jump key shortcuts in the hello screen. I like the idea but
> found the method a little cluttered.

Yes; it was a proof-of-concept.

> This is an alternative approach which underlines the relevant key in
> the search name (if it occurs).  This is relatively unintrusive
> (possibly even too hard to see) and is in line with how many other
> applications show shortcuts.
>
> I am guessing that most people choose a shortcut key with some
> relevance to the search name (eg i for inbox) so in most cases I think
> the shortcut will be shown. Of course multi-key shortcuts will not be shown.

While I understand your thinking, this falls short for me in several
ways.

First is that it's case sensitive. "i for Inbox" doesn't work. However
if you made it case insensitive, it might be silly for upper case
shortcuts.

Second is that automatic selection of the letter to underline is not
necessarily the logical one. "n for Inbox (notmuch)" underlines n in
"Inbox" instead of "notmuch". Hard to do anything about this. But it can
be confusing UI wise.

Third is that I do use characters not in the search name. For example "*
for flagged". I'm not happy that there is no fallback when the letter is
not present.

> If people think the underlining is too discreet then we could change
> the 'underline below to '(:foreground "red") or similar.

I don't think I would find the "fruit salad" visually pleasing. If
different colors were used, I'd prefer the letters were separate from
the name. Like in the jump search menu. I might like that the best.

Talking of the jump search menu, is it intentional that you underline
the keys there now too?

Finally, if this is supposed to be helpful to newcomers too, the user
won't know how to access these underlined shortcuts, as you have to hit
"j" first.


BR,
Jani.



>
> Best wishes
>
> Mark
>
>
>
> emacs/notmuch-hello.el | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 8bde808..de77730 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -572,7 +572,9 @@ with `notmuch-hello-query-counts'."
>  	      (if (> column-indent 0)
>  		  (widget-insert (make-string column-indent ? )))
>  	      (let* ((name (plist-get elem :name))
> +		     (key (plist-get elem :key))
>  		     (query (plist-get elem :query))
> +
>  		     (oldest-first (case (plist-get elem :sort-order)
>  				     (newest-first nil)
>  				     (oldest-first t)
> @@ -581,6 +583,12 @@ with `notmuch-hello-query-counts'."
>  		     (msg-count (plist-get elem :count)))
>  		(widget-insert (format "%8s "
>  				       (notmuch-hello-nice-number msg-count)))
> +		(save-match-data
> +		  (let ((case-fold-search nil))
> +		    (when (and key (string-match key name))
> +		      (add-face-text-property (match-beginning 0) (match-end 0)
> +					      'underline
> +					      nil name))))
>  		(widget-create 'push-button
>  			       :notify #'notmuch-hello-widget-search
>  			       :notmuch-search-terms query
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH] emacs: hello: display jump key next to saved search when available
  2015-12-13 18:24 [PATCH] emacs: hello: display jump key next to saved search when available Jani Nikula
  2015-12-13 19:09 ` Andrew Burgess
  2015-12-20  9:26 ` [PATCH] emacs: jump: show key shortcut Mark Walters
@ 2016-02-07  9:20 ` David Edmondson
  2016-02-07 10:58   ` Jani Nikula
  2 siblings, 1 reply; 7+ messages in thread
From: David Edmondson @ 2016-02-07  9:20 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Sun, Dec 13 2015, Jani Nikula <jani@nikula.org> wrote:
> Display the shortcut jump key next to the saved search name in notmuch
> hello, if one is defined for the saved search.

I quite like the idea of this (and Mark's followup), but I wonder about
the utility. With notmuch-jump, as soon as I hit `j' a list of the
possible keystrokes and the corresponding search is presented, so I
don't need to refer to the list in the hello buffer to know what to do.

>
> ---
>
> This is probably something with infinite bikeshedding
> potential. Therefore I just quickly hacked something together as a
> proof of concept. This displays the jump keys like this:
>
> 	154 Inbox [j i]
>
> Maybe the space between "j" and the key is unnecessary? Maybe the "j"
> itself is unnecessary? Maybe the brackets are unnecessary? Maybe it
> could use some color? Does displaying these need to be customizable?
> Etc?
> ---
>  emacs/notmuch-hello.el | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 738baad23b20..3c5440331669 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -578,7 +578,9 @@ with `notmuch-hello-query-counts'."
>  				     (oldest-first t)
>  				     (otherwise notmuch-search-oldest-first)))
>  		     (search-type (eq (plist-get elem :search-type) 'tree))
> -		     (msg-count (plist-get elem :count)))
> +		     (msg-count (plist-get elem :count))
> +		     (key (plist-get elem :key))
> +		     (shortcut (if key (format " [j %s]" key) nil)))
>  		(widget-insert (format "%8s "
>  				       (notmuch-hello-nice-number msg-count)))
>  		(widget-create 'push-button
> @@ -587,8 +589,10 @@ with `notmuch-hello-query-counts'."
>  			       :notmuch-search-oldest-first oldest-first
>  			       :notmuch-search-type search-type
>  			       name)
> +		(when shortcut
> +		  (widget-insert shortcut))
>  		(setq column-indent
> -		      (1+ (max 0 (- column-width (length name)))))))
> +		      (1+ (max 0 (- column-width (length name) (length shortcut)))))))
>  	    (setq count (1+ count))
>  	    (when (eq (% count tags-per-line) 0)
>  	      (setq column-indent 0)
> -- 
> 2.1.4
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH] emacs: hello: display jump key next to saved search when available
  2016-02-07  9:20 ` [PATCH] emacs: hello: display jump key next to saved search when available David Edmondson
@ 2016-02-07 10:58   ` Jani Nikula
  2016-02-09 20:42     ` David Edmondson
  0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2016-02-07 10:58 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Sun, 07 Feb 2016, David Edmondson <dme@dme.org> wrote:
> On Sun, Dec 13 2015, Jani Nikula <jani@nikula.org> wrote:
>> Display the shortcut jump key next to the saved search name in notmuch
>> hello, if one is defined for the saved search.
>
> I quite like the idea of this (and Mark's followup), but I wonder about
> the utility. With notmuch-jump, as soon as I hit `j' a list of the
> possible keystrokes and the corresponding search is presented, so I
> don't need to refer to the list in the hello buffer to know what to do.

Much of the point in this was to discuss how to make the UI, and the
very capable features we have, more discoverable to new uses. Most
people won't start by reading the documentation (which we don't even
really have for notmuch-emacs). Keeping the UI uncluttered and clean at
the same time is hard.

Perhaps promoting the '?' key in my other patch is enough. Perhaps an
alternative would be to highlight the 'j' key in "Saved searches:
[edit]" somehow.

BR,
Jani.

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

* Re: [PATCH] emacs: hello: display jump key next to saved search when available
  2016-02-07 10:58   ` Jani Nikula
@ 2016-02-09 20:42     ` David Edmondson
  0 siblings, 0 replies; 7+ messages in thread
From: David Edmondson @ 2016-02-09 20:42 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Sun, Feb 07 2016, Jani Nikula wrote:
> On Sun, 07 Feb 2016, David Edmondson <dme@dme.org> wrote:
>> On Sun, Dec 13 2015, Jani Nikula <jani@nikula.org> wrote:
>>> Display the shortcut jump key next to the saved search name in notmuch
>>> hello, if one is defined for the saved search.
>>
>> I quite like the idea of this (and Mark's followup), but I wonder about
>> the utility. With notmuch-jump, as soon as I hit `j' a list of the
>> possible keystrokes and the corresponding search is presented, so I
>> don't need to refer to the list in the hello buffer to know what to do.
>
> Much of the point in this was to discuss how to make the UI, and the
> very capable features we have, more discoverable to new uses. Most
> people won't start by reading the documentation (which we don't even
> really have for notmuch-emacs). Keeping the UI uncluttered and clean at
> the same time is hard.
>
> Perhaps promoting the '?' key in my other patch is enough. Perhaps an
> alternative would be to highlight the 'j' key in "Saved searches:
> [edit]" somehow.

I think the advertisement of '?' is sufficient. We don't provide an
on-screen guide in any of the other modes and (it appears to be emerging
that) emacs tools are providing help for complex sequences of operations
via secondary popups (like notmuch-jump or the magit equivalent).

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

end of thread, other threads:[~2016-02-09 20:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13 18:24 [PATCH] emacs: hello: display jump key next to saved search when available Jani Nikula
2015-12-13 19:09 ` Andrew Burgess
2015-12-20  9:26 ` [PATCH] emacs: jump: show key shortcut Mark Walters
2015-12-20 12:50   ` Jani Nikula
2016-02-07  9:20 ` [PATCH] emacs: hello: display jump key next to saved search when available David Edmondson
2016-02-07 10:58   ` Jani Nikula
2016-02-09 20:42     ` David Edmondson

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