--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1F649431FC0\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Jul 2014 14:22:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.502\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.502 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id tq4PVK8H2tz6 for <notmuch@notmuchmail.org>;\r
+ Mon, 14 Jul 2014 14:22:16 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A5884431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Jul 2014 14:22:15 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1X6nhH-0007jw-St; Mon, 14 Jul 2014 22:22:09 +0100\r
+Received: from [194.42.225.51] (helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1X6nhH-0007on-Ad; Mon, 14 Jul 2014 22:22:07 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/2] emacs: Introduce notmuch-jump: shortcut keys to saved\r
+ searches\r
+In-Reply-To: <1405353735-26244-2-git-send-email-amdragon@mit.edu>\r
+References: <1405353735-26244-1-git-send-email-amdragon@mit.edu>\r
+ <1405353735-26244-2-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 14 Jul 2014 22:22:05 +0100\r
+Message-ID: <87egxnd4aq.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Sender-Host-Address: 194.42.225.51\r
+X-QM-Geographic: According to ripencc,\r
+ this message was delivered by a machine in Britain (UK) (GB).\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: 5bdb0a34a3b8e8204b35fee859a54db1 (of first 20000 bytes)\r
+X-SpamAssassin-Score: 0.0\r
+X-SpamAssassin-SpamBar: /\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored 0.0 points. Summary of the scoring: \r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 14 Jul 2014 21:22:24 -0000\r
+\r
+\r
+On Mon, 14 Jul 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> This introduces notmuch-jump, which is like a user-friendly,\r
+> user-configurable global prefix map for saved searches. This provides\r
+> a non-modal and much faster way to access saved searches than\r
+> notmuch-hello.\r
+>\r
+> A user configures shortcut keys in notmuch-saved-searches, which are\r
+> immediately accessible from anywhere in Notmuch under the "j" key (for\r
+> "jump"). When the user hits "j", the minibuffer immediately shows a\r
+> helpful table of bindings reminiscent of a completions buffer.\r
+\r
+I am basically happy with this: the only downside compared to dme's\r
+patch is that this is quite substantially bigger. However, since this is\r
+all in it's own file that is not really a problem.\r
+\r
+I have a few comments below. In all cases I am happy to go with the\r
+current code if you think it's better than my suggestion.\r
+\r
+> This code is a combination of work from myself (originally,\r
+> "notmuch-go"), David Edmondson, and modifications from Mark Walters.\r
+> ---\r
+> emacs/Makefile.local | 3 +-\r
+> emacs/notmuch-hello.el | 2 +\r
+> emacs/notmuch-jump.el | 189 +++++++++++++++++++++++++++++++++++++++++++=\r
+++++++\r
+> emacs/notmuch-lib.el | 3 +\r
+> 4 files changed, 196 insertions(+), 1 deletion(-)\r
+> create mode 100644 emacs/notmuch-jump.el\r
+>\r
+> diff --git a/emacs/Makefile.local b/emacs/Makefile.local\r
+> index c0d6b19..1109cfa 100644\r
+> --- a/emacs/Makefile.local\r
+> +++ b/emacs/Makefile.local\r
+> @@ -18,7 +18,8 @@ emacs_sources :=3D \\r
+> $(dir)/notmuch-tag.el \\r
+> $(dir)/coolj.el \\r
+> $(dir)/notmuch-print.el \\r
+> - $(dir)/notmuch-version.el\r
+> + $(dir)/notmuch-version.el \\r
+> + $(dir)/notmuch-jump.el \\r
+>=20=20\r
+> $(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp\r
+> $(dir)/notmuch-version.el: $(srcdir)/$(dir)/notmuch-version.el.tmpl\r
+> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> index 3de5238..061b27d 100644\r
+> --- a/emacs/notmuch-hello.el\r
+> +++ b/emacs/notmuch-hello.el\r
+> @@ -85,6 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list\r
+> (group :format "%v" :inline t (const :format " Query: " :query) (stri=\r
+ng :format "%v")))\r
+> (checklist :inline t\r
+> :format "%v"\r
+> + (group :format "%v" :inline t (const :format "Shortcut key: " :ke=\r
+y) (key-sequence :format "%v"))\r
+> (group :format "%v" :inline t (const :format "Count-Query: " :cou=\r
+nt-query) (string :format "%v"))\r
+> (group :format "%v" :inline t (const :format "" :sort-order)\r
+> (choice :tag " Sort Order"\r
+> @@ -101,6 +102,7 @@ (defcustom notmuch-saved-searches '((:name "inbox" :q=\r
+uery "tag:inbox")\r
+>=20=20\r
+> :name Name of the search (required).\r
+> :query Search to run (required).\r
+> + :key Optional shortcut key for `notmuch-jump-search'.\r
+> :count-query Optional extra query to generate the count\r
+> shown. If not present then the :query property\r
+> is used.\r
+> diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el\r
+> new file mode 100644\r
+> index 0000000..cb1ae10\r
+> --- /dev/null\r
+> +++ b/emacs/notmuch-jump.el\r
+> @@ -0,0 +1,189 @@\r
+> +;; notmuch-jump.el --- User-friendly shortcut keys\r
+> +;;\r
+> +;; Copyright =C2=A9 Austin Clements\r
+> +;;\r
+> +;; This file is part of Notmuch.\r
+> +;;\r
+> +;; Notmuch is free software: you can redistribute it and/or modify it\r
+> +;; under the terms of the GNU General Public License as published by\r
+> +;; the Free Software Foundation, either version 3 of the License, or\r
+> +;; (at your option) any later version.\r
+> +;;\r
+> +;; Notmuch is distributed in the hope that it will be useful, but\r
+> +;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
+> +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+> +;; General Public License for more details.\r
+> +;;\r
+> +;; You should have received a copy of the GNU General Public License\r
+> +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
+> +;;\r
+> +;; Authors: Austin Clements <aclements@csail.mit.edu>\r
+> +;; David Edmondson <dme@dme.org>\r
+> +\r
+> +(eval-when-compile (require 'cl))\r
+> +\r
+> +(require 'notmuch-hello)\r
+> +\r
+> +;;;###autoload\r
+> +(defun notmuch-jump-search ()\r
+> + "Jump to a saved search by shortcut key.\r
+> +\r
+> +This prompts for and performs a saved search using the shortcut\r
+> +keys configured in the :key property of `notmuch-saved-searches'.\r
+> +Typically these shortcuts are a single key long, so this is a\r
+> +fast way to jump to a saved search from anywhere in Notmuch."\r
+> + (interactive)\r
+> +\r
+> + ;; Build the action map\r
+> + (let (action-map)\r
+> + (dolist (saved-search notmuch-saved-searches)\r
+> + (let* ((saved-search (notmuch-hello-saved-search-to-plist saved-se=\r
+arch))\r
+> + (key (plist-get saved-search :key)))\r
+> + (when key\r
+> + (let ((name (plist-get saved-search :name))\r
+> + (query (plist-get saved-search :query))\r
+> + (oldest-first\r
+> + (case (plist-get saved-search :sort-order)\r
+\r
+I would probably not do the saved-search-to-plist bit and just use\r
+notmuch-saved-search-get each time.\r
+\r
+> + (newest-first nil)\r
+> + (oldest-first t)\r
+> + (otherwise (default-value notmuch-search-oldest-first)))))\r
+> + (push (list key name\r
+> + `(lambda () (notmuch-search ',query ',oldest-first)))\r
+> + action-map)))))\r
+> + (setq action-map (nreverse action-map))\r
+> +\r
+> + (if action-map\r
+> + (notmuch-jump action-map "Search ")\r
+> + (error "No shortcut keys for saved searches. Please customize not=\r
+much-saved-searches."))))\r
+\r
+I would slightly rephrase the error: something more like "... To use\r
+notmuch-jump please customize notmuch-saved-searches." So that the user\r
+who doesn't want to use notmuch-jump doesn't think they are at fault.\r
+\r
+> +(defvar notmuch-jump--action nil)\r
+> +\r
+> +(defun notmuch-jump (action-map prompt)\r
+> + "Interactively prompt for one of the keys in ACTION-MAP.\r
+> +\r
+> +Displays a pop-up temporary buffer with a summary of all bindings\r
+> +in ACTION-MAP, reads a key from the minibuffer, and performs the\r
+> +corresponding action. The prompt can be canceled with C-g.\r
+\r
+Maybe say the prompt can be canceled with RET too?\r
+\r
+> +PROMPT must be a string to use for the prompt if this command was\r
+> +not invoked directly by a key binding (e.g., it was invoked\r
+> +through M-x). PROMPT should include a space at the end.\r
+\r
+I find the "j-" prompt a bit weird and would prefer something more like\r
+"Jump to search: " to be used however the user enters the function.\r
+\r
+> +ACTION-MAP must be a list of triples of the form\r
+> + (KEY LABEL ACTION)\r
+> +where KEY is a key binding, LABEL is a string label to display in\r
+> +the buffer, and ACTION is a nullary function to call. LABEL may\r
+> +be null, in which case the action will still be bound, but will\r
+> +not appear in the pop-up buffer.\r
+> +"\r
+> +\r
+> + (let* ((items (notmuch-jump--format-actions action-map))\r
+> + ;; Format the table of bindings and the full prompt\r
+> + (table\r
+> + (with-temp-buffer\r
+> + (notmuch-jump--insert-items (window-body-width) items)\r
+> + (buffer-string)))\r
+> + (prompt-text\r
+> + (if (eq this-original-command this-command)\r
+> + ;; Make it look like we're just part of any regular\r
+> + ;; submap prompt (like C-x, C-c, etc.)\r
+> + (concat (format-kbd-macro (this-command-keys)) "-")\r
+> + ;; We were invoked through something like M-x\r
+> + prompt))\r
+> + (full-prompt\r
+> + (concat table "\n\n"\r
+> + (propertize prompt-text 'face 'minibuffer-prompt)))\r
+> + ;; By default, the minibuffer applies the minibuffer face to\r
+> + ;; the entire prompt. However, we want to clearly\r
+> + ;; distinguish bindings (which we put in the prompt face\r
+> + ;; ourselves) from their labels, so disable the minibuffer's\r
+> + ;; own re-face-ing.\r
+> + (minibuffer-prompt-properties\r
+> + (notmuch-jump--plist-delete\r
+> + (copy-sequence minibuffer-prompt-properties)\r
+> + 'face))\r
+> + ;; Build the keymap with our bindings\r
+> + (minibuffer-map (notmuch-jump--make-keymap action-map))\r
+> + ;; The bindings save the the action in notmuch-jump--action\r
+> + (notmuch-jump--action nil))\r
+> + ;; Read the action\r
+> + (read-from-minibuffer full-prompt nil minibuffer-map)\r
+> +\r
+> + ;; If we got an action, do it\r
+> + (when notmuch-jump--action\r
+> + (funcall notmuch-jump--action))))\r
+> +\r
+> +(defun notmuch-jump--format-actions (action-map)\r
+> + "Format the actions in ACTION-MAP.\r
+> +\r
+> +Returns a list of strings, one for each item with a label in\r
+> +ACTION-MAP. These strings can be inserted into a tabular\r
+> +buffer."\r
+> +\r
+> + ;; Compute the maximum key description width\r
+> + (let ((key-width 1))\r
+> + (dolist (action action-map)\r
+\r
+The name "action" is slightly unfortunate when you use ACTION as the\r
+third item of each element of action-map when describing it\r
+above. However, no better name springs to mind. (Maybe "triple"?)\r
+\r
+> + (setq key-width\r
+> + (max key-width\r
+> + (string-width (format-kbd-macro (first action))))))\r
+> + ;; Format each action\r
+> + (mapcar (lambda (action)\r
+> + (let ((key (format-kbd-macro (first action)))\r
+> + (desc (second action)))\r
+> + (concat\r
+> + (propertize key 'face 'minibuffer-prompt)\r
+> + (make-string (- key-width (length key)) ? )\r
+> + " " desc)))\r
+> + action-map)))\r
+> +\r
+> +(defun notmuch-jump--insert-items (width items)\r
+> + "Make a table of ITEMS up to WIDTH wide in the current buffer."\r
+> + (let* ((nitems (length items))\r
+> + (col-width (+ 3 (apply #'max (mapcar #'string-width items))))\r
+> + (ncols (if (> (* col-width nitems) width)\r
+> + (max 1 (/ width col-width))\r
+> + ;; Items fit on one line. Space them out\r
+> + (setq col-width (/ width nitems))\r
+> + (length items))))\r
+> + (while items\r
+> + (dotimes (col ncols)\r
+> + (when items\r
+> + (let ((item (pop items)))\r
+> + (insert item)\r
+> + (when (and items (< col (- ncols 1)))\r
+> + (insert (make-string (- col-width (string-width item)) ? ))))))\r
+> + (when items\r
+> + (insert "\n")))))\r
+> +\r
+> +(defvar notmuch-jump-minibuffer-map\r
+> + (let ((map (make-sparse-keymap)))\r
+> + (set-keymap-parent map minibuffer-local-map)\r
+> + ;; Make this like a special-mode keymap, with no self-insert-command\r
+> + (suppress-keymap map)\r
+> + map)\r
+> + "Base keymap for notmuch-jump's minibuffer keymap.")\r
+> +\r
+> +(defun notmuch-jump--make-keymap (action-map)\r
+> + "Translate ACTION-MAP into a minibuffer keymap."\r
+> + (let ((map (make-sparse-keymap)))\r
+> + (set-keymap-parent map notmuch-jump-minibuffer-map)\r
+> + (dolist (action action-map)\r
+> + (define-key map (first action)\r
+> + `(lambda () (interactive)\r
+> + (setq notmuch-jump--action ',(third action))\r
+> + (exit-minibuffer))))\r
+> + map))\r
+> +\r
+> +(defun notmuch-jump--plist-delete (plist property)\r
+> + (let* ((xplist (cons nil plist))\r
+> + (pred xplist))\r
+> + (while (cdr pred)\r
+> + (when (eq (cadr pred) property)\r
+> + (setcdr pred (cdddr pred)))\r
+> + (setq pred (cddr pred)))\r
+> + (cdr xplist)))\r
+> +\r
+> +(unless (fboundp 'window-body-width)\r
+> + ;; Compatibility for Emacs pre-24\r
+> + (defun window-body-width (&optional window)\r
+> + (let ((edges (window-inside-edges window)))\r
+> + (- (caddr edges) (car edges)))))\r
+> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+> index 2941da3..135422d 100644\r
+> --- a/emacs/notmuch-lib.el\r
+> +++ b/emacs/notmuch-lib.el\r
+> @@ -130,9 +130,12 @@ (defvar notmuch-common-keymap\r
+> (define-key map "m" 'notmuch-mua-new-mail)\r
+> (define-key map "=3D" 'notmuch-refresh-this-buffer)\r
+> (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)\r
+> + (define-key map "j" 'notmuch-jump-search)\r
+> map)\r
+> "Keymap shared by all notmuch modes.")\r
+>=20=20\r
+> +(autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by=\r
+ shortcut key." t)\r
+\r
+We don't normally seem to use autoload but instead use\r
+declare-function. It might be worth being consistent (I am not very sure\r
+of the pros and cons of autoload). May also be worth having it with the\r
+other declare-functions to keep it clear how things are loaded.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+> +\r
+> ;; By default clicking on a button does not select the window\r
+> ;; containing the button (as opposed to clicking on a widget which\r
+> ;; does). This means that the button action is then executed in the\r
+> --=20\r
+> 2.0.0\r