[PATCH] emacs: jump: show key shortcut

Subject: [PATCH] emacs: jump: show key shortcut

Date: Sun, 20 Dec 2015 09:26:27 +0000

To: notmuch@notmuchmail.org

Cc:

From: Mark Walters


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


Thread: