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