From 24ceef58a6200c4b7fd0d64285f0b6c36b75efb8 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Thu, 8 May 2014 10:14:47 +0100 Subject: [PATCH] Re: [PATCH v2] emacs: Add support for saved search accelerators --- 47/460c0c5095be75e82043032069922fb4d994aa | 212 ++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 47/460c0c5095be75e82043032069922fb4d994aa diff --git a/47/460c0c5095be75e82043032069922fb4d994aa b/47/460c0c5095be75e82043032069922fb4d994aa new file mode 100644 index 000000000..e703f8a87 --- /dev/null +++ b/47/460c0c5095be75e82043032069922fb4d994aa @@ -0,0 +1,212 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id BD8D0431FBF + for ; Thu, 8 May 2014 02:15:20 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 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_MED=-2.3] 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 lFYIBb2kDbLL for ; + Thu, 8 May 2014 02:15:14 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id A6D3A431FAE + for ; Thu, 8 May 2014 02:15:13 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1WiKQ1-0000zx-O7; Thu, 08 May 2014 10:15:12 +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 1WiKPh-0005Fj-AG; Thu, 08 May 2014 10:14:49 +0100 +From: Mark Walters +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] emacs: Add support for saved search accelerators +In-Reply-To: <1399461694-25350-2-git-send-email-dme@dme.org> +References: <1399385776-19918-1-git-send-email-dme@dme.org> + <1399461694-25350-1-git-send-email-dme@dme.org> + <1399461694-25350-2-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: Thu, 08 May 2014 10:14:47 +0100 +Message-ID: <87zjislji0.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: 07f41aa1f7ae45e6727c096e1e45db39 (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.1 AWL AWL: From: address is in the auto white-list +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: Thu, 08 May 2014 09:15:20 -0000 + + +Hi + +This version looks good to me. + +The only slight query I have is which key to bind it to: Austin used g +in notmuch-go and this uses j. Austin said on irc that he chose g +because it wasn't bound and matched gmail's shortcut. + +Personally I like j (as it starts fewer words than g) and given that we +don't match any of gmail's other bindings I don't think there is much +advantage to doing so in this case. + +In any case that's all bikeshedding: I like this patch with either +binding. + +Best wishes + +Mark + + + +On Wed, 07 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. +> --- +> emacs/notmuch-hello.el | 5 ++++- +> emacs/notmuch-lib.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ +> 2 files changed, 50 insertions(+), 1 deletion(-) +> +> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +> index 3de5238..64d5aa1 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) (key-sequence :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" +> @@ -101,6 +102,7 @@ a plist. Supported properties are +> +> :name Name of the search (required). +> :query Search to run (required). +> + :key Optional accelerator key. +> :count-query Optional extra query to generate the count +> shown. If not present then the :query property +> is used. +> @@ -551,7 +553,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) +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index 2941da3..f8c5f96 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -25,6 +25,10 @@ +> (require 'mm-decode) +> (require 'cl) +> +> +(declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation)) +> +(declare-function notmuch-saved-search-get "notmuch-hello" (saved-search field)) +> +(defvar notmuch-saved-searches) ;; In `notmuch-hello.el'. +> + +> (defvar notmuch-command "notmuch" +> "Command to run the notmuch binary.") +> +> @@ -130,6 +134,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 +850,47 @@ 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)) +> + help) +> + (set-keymap-parent map minibuffer-local-map) +> + (suppress-keymap map) +> + (dolist (saved-search notmuch-saved-searches) +> + (let ((key (notmuch-saved-search-get saved-search :key))) +> + (when key +> + (define-key map key `(lambda () +> + (interactive) +> + (setq notmuch-jump-search ',saved-search) +> + (exit-minibuffer))) +> + (push (format "%s: %s" +> + (propertize key 'face 'minibuffer-prompt) +> + (notmuch-saved-search-get saved-search :name)) +> + help)))) +> + ;; Hitting ? displays a quick hint of the accelerators. +> + (define-key map "?" `(lambda () +> + (interactive) +> + (message "%s" +> + (mapconcat #'identity +> + ;; Reverse the list so +> + ;; that elements appear +> + ;; in the same order as +> + ;; `notmuch-saved-searches'. +> + (reverse ',help) +> + " ")))) +> + map)) +> + +> +(defun notmuch-jump () +> + "Read a saved search accelerator key and perform the search." +> + (interactive) +> + (setq notmuch-jump-search nil) +> + (read-from-minibuffer "Jump to saved search: " nil (notmuch-jump-map)) +> + (when notmuch-jump-search +> + (notmuch-search (notmuch-saved-search-get notmuch-jump-search :query) +> + (notmuch-saved-search-get notmuch-jump-search :oldest-first)))) +> + +> (provide 'notmuch-lib) +> +> ;; Local Variables: +> -- +> 2.0.0.rc0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2