From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 28D71431FC7 for ; Tue, 6 May 2014 09:43:38 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.502 X-Spam-Level: X-Spam-Status: No, score=0.502 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ux9qhNfSM5us for ; Tue, 6 May 2014 09:43:30 -0700 (PDT) Received: from mail1.qmul.ac.uk (mail1.qmul.ac.uk [138.37.6.7]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 83D5F431FAF for ; Tue, 6 May 2014 09:43:30 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail1.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1WhiQl-00057k-He; Tue, 06 May 2014 17:43:28 +0100 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1WhiQl-0006nJ-6E; Tue, 06 May 2014 17:41:23 +0100 From: Mark Walters To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [RFC] [PATCH] emacs: Add support for saved search accelerators. In-Reply-To: <1399385776-19918-1-git-send-email-dme@dme.org> References: <1399385776-19918-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Tue, 06 May 2014 17:41:21 +0100 Message-ID: <87oazaq2q6.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 87.81.223.162 X-QM-Geographic: According to ripencc, this message was delivered by a machine in Britain (UK) (GB). X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: a8a84af88f5258eb440537911183618f (of first 20000 bytes) X-QM-Scan-Virus: ClamAV says the message is clean X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2014 16:43:38 -0000 Hi Yes this looks nice modulo polishing. I think the nifty window-splitting Austin's notmuch-go does is moderately orthogonal to the keyboard shortcuts (since shortcuts can be used without it, and it could be used for other things too) On Tue, 06 May 2014, David Edmondson wrote: > 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")) if you use key-sequence rather than string then this is a bit nicer. It allows a multiple key press binding: eg "n i" or "C-n". > (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)) I think it might be worth having an option to suppress the display of the binding: I think inbox (i) would annoy me, but it is good for discoverability. I, personally, would be completely happy without the displayed binding. Actually just a thought: could ? in jump-mode-map be bound to something that displayed the bindings? > (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) if you make the parent keymap the minibuffer-local-map then the various exits from the minibuffer work (ctrl-g and return for example) > + (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)))) These two plist-gets should be notmuch-saved-search-get. That is a helper so that people with old style saved searches (a cons cell of name and query) don't get errors. (There were also a couple of "not yet declared" things.) Best wishes Mark > + > (provide 'notmuch-lib) > > ;; Local Variables: > -- > 2.0.0.rc0 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch