--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 2062C431FC4\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Jul 2014 20:46:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 Bk-mPmHeZqu4 for <notmuch@notmuchmail.org>;\r
+ Mon, 14 Jul 2014 20:46:50 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
+ [18.9.25.13])\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 34598431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Jul 2014 20:46:50 -0700 (PDT)\r
+X-AuditID: 1209190d-f79c06d000002f07-43-53c4a429729b\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 13.B9.12039.924A4C35; Mon, 14 Jul 2014 23:46:49 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s6F3klvJ004257; \r
+ Mon, 14 Jul 2014 23:46:48 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6F3kjEY026768\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Mon, 14 Jul 2014 23:46:46 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1X6thV-0005Vg-4p; Mon, 14 Jul 2014 23:46:45 -0400\r
+Date: Mon, 14 Jul 2014 23:46:45 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH 1/2] emacs: Introduce notmuch-jump: shortcut keys to\r
+ saved searches\r
+Message-ID: <20140715034645.GE4660@mit.edu>\r
+References: <1405353735-26244-1-git-send-email-amdragon@mit.edu>\r
+ <1405353735-26244-2-git-send-email-amdragon@mit.edu>\r
+ <87egxnd4aq.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=iso-8859-1\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: 8bit\r
+In-Reply-To: <87egxnd4aq.fsf@qmul.ac.uk>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrFKsWRmVeSWpSXmKPExsUixCmqrau55EiwwctfChY3WrsZLfbd2cJk\r
+ sXouj8X1mzOZHVg8dj3/y+Sxc9Zddo9nq24xe2w59J45gCWKyyYlNSezLLVI3y6BK+PV7aCC\r
+ 5qKK1w0LmRsYV0V0MXJySAiYSBw/1MUMYYtJXLi3nq2LkYtDSGA2k8T+f5fYQBJCAhsZJX7/\r
+ 4YRInGaSOPRkPyOEs4RR4mDPBLB2FgFVifvbnzCC2GwCGhLb9i8Hs0UEdCRuH1rADmIzC1hL\r
+ vFv1DywuLBAp8fn1VVYQm1dAW2L3rrlQq6cySpz8u5YNIiEocXLmExaIZh2JnVvvAMU5gGxp\r
+ ieX/OCDC8hLNW2eD3cAJtPdN41Ow+aICKhJTTm5jm8AoPAvJpFlIJs1CmDQLyaQFjCyrGGVT\r
+ cqt0cxMzc4pTk3WLkxPz8lKLdI30cjNL9FJTSjcxgqNFkncH47uDSocYBTgYlXh4T3w6HCzE\r
+ mlhWXJl7iFGSg0lJlLdg6pFgIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8HouBcrwpiZVVqUX5\r
+ MClpDhYlcd631lbBQgLpiSWp2ampBalFMFkZDg4lCV5VkEbBotT01Iq0zJwShDQTByfIcB6g\r
+ 4dPBhhcXJOYWZ6ZD5E8x6nJ0XT/WxiTEkpeflyolzvt1EVCRAEhRRmke3BxYknvFKA70ljBv\r
+ BMgoHmCChJv0CmgJE9CS8prDIEtKEhFSUg2MZeeObpp8bFf/7FuuD0+LbI2xubnLjWcfU3f7\r
+ lY/7Hk5ddKx0/7/vMY/8a6JeLBTr4FxvJWB8P5XHT0lrwuzvjIE10SyK0fw/3E0n1Wd/Xv7T\r
+ +32ETELVvQZ3jmzuVcdrLu6dFLXyz9Xl1k/ymblrFkhIOrg9VPi999r1Z34zhB7LrPJ7zBUv\r
+ qsRSnJFoqMVcVJwIADugN4dNAwAA\r
+Cc: notmuch@notmuchmail.org\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: Tue, 15 Jul 2014 03:46:59 -0000\r
+\r
+Quoth Mark Walters on Jul 14 at 10:22 pm:\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
+> > 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 := \\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
+> > \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) (string :format "%v")))\r
+> > (checklist :inline t\r
+> > :format "%v"\r
+> > + (group :format "%v" :inline t (const :format "Shortcut key: " :key) (key-sequence :format "%v"))\r
+> > (group :format "%v" :inline t (const :format "Count-Query: " :count-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" :query "tag:inbox")\r
+> > \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 © 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-search))\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
+What's the downside of notmuch-hello-saved-search-to-plist? Using\r
+notmuch-saved-search-get everywhere is more verbose.\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 notmuch-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
+Good idea.\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
+Done. I also fixed the docstring's mention of a pop-up temporary\r
+buffer, since that's not how the code works any more.\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
+The intent was to make it act like a prefix keymap. For example, if\r
+you hit "C-x", Emacs will show "C-x-" in the minibuffer until you hit\r
+the next key. OTOH, Emacs isn't exactly a paragon of usability, so\r
+you're probably right and this should just use the provided prompt\r
+string regardless.\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
+Good catch. Changed to "entry" (for an entry in the action map).\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 "=" '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
+> > \r
+> > +(autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by 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
+I used autoload because it won't bother even reading\r
+notmuch-jump.el(c) until the user hits "j" for the first time (and,\r
+hence, won't load it at all if they don't use jump). This is easy\r
+with notmuch-jump because it's self-contained and has a single clear\r
+entry-point and no customizable variables.\r
+\r
+declare-function, on the other hand, still requires you to load the\r
+source containing the function (either eagerly, which is what notmuch\r
+usually does, or with an autoload).\r
+\r
+I think we should do *more* autoloading, though maybe it's not\r
+practical for the bulk of notmuch-emacs.\r
+\r
+I'm happy to move the autoload call to somewhere else, though\r
+notmuch-lib doesn't actually have any declare-functions (since it's\r
+sort of a root of the dependency tree). I could put it right below\r
+the requires, since that's where we usually put declare-functions.\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