unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [RFC] [PATCH] emacs: Add support for saved search accelerators.
@ 2014-05-06 14:16 David Edmondson
  2014-05-06 16:41 ` Mark Walters
  2014-05-07 11:21 ` [PATCH v2] emacs: Add support for saved search accelerator keys David Edmondson
  0 siblings, 2 replies; 13+ messages in thread
From: David Edmondson @ 2014-05-06 14:16 UTC (permalink / raw)
  To: notmuch

Extended the saved search definition to allow the inclusion of an
accelerator key for the search. Bind 'j' in the common mode map as a
leader for such accelerator keys.
---

This arose out a conversation in #notmuch and Mark's patch to extend
the saved search custom specification based on requirements for an
external package (Austin's notmuch-go.el).

Re-organising the layout of the saved searches is missing (as it's
lots of fiddling about with absolute numbers and I didn't want to
waste time on it if this is going nowhere), so the saved searches may
not all line up correctly in notmuch-hello.

 emacs/notmuch-hello.el |  8 ++++++--
 emacs/notmuch-lib.el   | 27 +++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3de5238..56379ef 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -85,6 +85,7 @@ searches so they still work in customize."
 		(group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))
 	  (checklist :inline t
 		     :format "%v"
+		     (group :format "%v" :inline t (const :format "    Key: " :key) (string :format "%v"))
 		     (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
 		     (group :format "%v" :inline t (const :format "" :sort-order)
 			    (choice :tag " Sort Order"
@@ -551,7 +552,8 @@ with `notmuch-hello-query-counts'."
 	    (when elem
 	      (if (> column-indent 0)
 		  (widget-insert (make-string column-indent ? )))
-	      (let* ((name (plist-get elem :name))
+	      (let* ((key (plist-get elem :key))
+		     (name (plist-get elem :name))
 		     (query (plist-get elem :query))
 		     (oldest-first (case (plist-get elem :sort-order)
 				     (newest-first nil)
@@ -564,7 +566,9 @@ with `notmuch-hello-query-counts'."
 			       :notify #'notmuch-hello-widget-search
 			       :notmuch-search-terms query
 			       :notmuch-search-oldest-first oldest-first
-			       name)
+			       (if key
+				   (concat name " (" key ")")
+				 name))
 		(setq column-indent
 		      (1+ (max 0 (- column-width (length name)))))))
 	    (setq count (1+ count))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 2941da3..9aa7ba7 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -130,6 +130,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
     (define-key map "m" 'notmuch-mua-new-mail)
     (define-key map "=" 'notmuch-refresh-this-buffer)
     (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
+    (define-key map "j" 'notmuch-jump)
     map)
   "Keymap shared by all notmuch modes.")
 
@@ -845,6 +846,32 @@ status."
 (defvar notmuch-show-process-crypto nil)
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 
+;; Jump key support:
+
+(defvar notmuch-jump-search nil)
+(defun notmuch-jump-map ()
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map nil)
+    (suppress-keymap map)
+    (dolist (saved-search notmuch-saved-searches)
+      (let ((key (plist-get saved-search :key)))
+	(when key
+	  (define-key map key `(lambda ()
+				 (interactive)
+				 (setq notmuch-jump-search ',saved-search)
+				 (exit-minibuffer)
+				 )))))
+    map))
+
+(defun notmuch-jump ()
+  "Read a saved search accelerator key and perform the associated
+search."
+  (interactive)
+  (read-from-minibuffer "Jump to saved search: " nil (notmuch-jump-map))
+  (when notmuch-jump-search
+    (notmuch-search (plist-get notmuch-jump-search :query)
+		    (plist-get notmuch-jump-search :oldest-first))))
+
 (provide 'notmuch-lib)
 
 ;; Local Variables:
-- 
2.0.0.rc0

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

end of thread, other threads:[~2014-07-13 15:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 14:16 [RFC] [PATCH] emacs: Add support for saved search accelerators David Edmondson
2014-05-06 16:41 ` Mark Walters
2014-05-07 11:21 ` [PATCH v2] emacs: Add support for saved search accelerator keys David Edmondson
2014-05-07 11:21   ` [PATCH v2] emacs: Add support for saved search accelerators David Edmondson
2014-05-08  9:14     ` Mark Walters
2014-05-10 21:04       ` Aaron Ecay
2014-05-12  6:07         ` David Edmondson
2014-06-06 13:12           ` Mark Walters
2014-07-12 19:31     ` David Bremner
2014-07-13  3:50       ` Austin Clements
2014-07-13 14:20         ` David Bremner
2014-07-13 14:32           ` Austin Clements
2014-07-13 15:06             ` 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).