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 87478431FC2 for ; Tue, 15 Jul 2014 07:06:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 HEQw+xwK3ArC for ; Tue, 15 Jul 2014 07:06:17 -0700 (PDT) Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu [18.7.68.35]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 46E5E431FBD for ; Tue, 15 Jul 2014 07:06:17 -0700 (PDT) X-AuditID: 12074423-f79bf6d000007580-ff-53c53556efd4 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) (using TLS with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id 06.09.30080.65535C35; Tue, 15 Jul 2014 10:06:14 -0400 (EDT) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s6FE6Dv1018297; Tue, 15 Jul 2014 10:06:13 -0400 Received: from drake.dyndns.org (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [216.15.114.40]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6FE6AAu008823 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 15 Jul 2014 10:06:12 -0400 Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1X73Mv-0000gx-2K; Tue, 15 Jul 2014 10:06:09 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 0/2] emacs: Shortcut keys to saved searches Date: Tue, 15 Jul 2014 10:06:04 -0400 Message-Id: <1405433166-2198-1-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1405353735-26244-1-git-send-email-amdragon@mit.edu> References: <1405353735-26244-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsUixCmqrRtmejTYoLnFyuJGazejxb47W5gs Vs/lsbh+cyazA4vHrud/mTx2zrrL7vFs1S1mjy2H3jMHsERx2aSk5mSWpRbp2yVwZWyde4ip oFm+4taDG4wNjGcluhg5OSQETCQOLpjFBGGLSVy4t56ti5GLQ0hgNpPE3bOzWCCcjYwSV1vn MUE4d5gkml5fZQVpERKYyyhx4LItiM0moCGxbf9yRhBbREBaYufd2WA1zAK2Ep9a/4OtEBaw k/i+/z0ziM0ioCpx/ctzdhCbV8BeYt69LlaIM+QkGm58YgOxOQUcJd68OAa1y0Fi05rPTBMY +RcwMqxilE3JrdLNTczMKU5N1i1OTszLSy3SNdPLzSzRS00p3cQICjh2F+UdjH8OKh1iFOBg VOLhlXh3OFiINbGsuDL3EKMkB5OSKG8x29FgIb6k/JTKjMTijPii0pzU4kOMEhzMSiK8kiZA Od6UxMqq1KJ8mJQ0B4uSOO9ba6tgIYH0xJLU7NTUgtQimKwMB4eSBC8zSKNgUWp6akVaZk4J QpqJgxNkOA/QcF6w4cUFibnFmekQ+VOMilLivCeMgRICIImM0jy4XlhCeMUoDvSKMO8VkCoe YDKB634FNJgJaHB5zWGQwSWJCCmpBsasIGnusvAfOyodGNiZ3rMc+JvQnOvb+abr/Qtphpk3 4rUWTVVczMe+veO5VEPKpYZfZ5NOPtJLtGcTdNnymrFc+JFw3r6TayStnVgPvmvv7LqUes2f Iz2ZK7w458f5ZX9juz8+3DVXc83+y9k2h9iYJ997oz/rw9lvJ7494n+0pvSFRPu1MEclluKM REMt5qLiRADCQO0m4wIAAA== 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, 15 Jul 2014 14:06:22 -0000 This is version 2 of id:1405353735-26244-1-git-send-email-amdragon@mit.edu and addresses Mark's comments in id:87egxnd4aq.fsf@qmul.ac.uk. The diff from v1 is below. diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el index cb1ae10..9cb1e6a 100644 --- a/emacs/notmuch-jump.el +++ b/emacs/notmuch-jump.el @@ -53,20 +53,19 @@ (defun notmuch-jump-search () (setq action-map (nreverse action-map)) (if action-map - (notmuch-jump action-map "Search ") - (error "No shortcut keys for saved searches. Please customize notmuch-saved-searches.")))) + (notmuch-jump action-map "Search: ") + (error "To use notmuch-jump, please customize shortcut keys in notmuch-saved-searches.")))) (defvar notmuch-jump--action nil) (defun notmuch-jump (action-map prompt) "Interactively prompt for one of the keys in ACTION-MAP. -Displays a pop-up temporary buffer with a summary of all bindings -in ACTION-MAP, reads a key from the minibuffer, and performs the -corresponding action. The prompt can be canceled with C-g. -PROMPT must be a string to use for the prompt if this command was -not invoked directly by a key binding (e.g., it was invoked -through M-x). PROMPT should include a space at the end. +Displays a summary of all bindings in ACTION-MAP in the +minibuffer, reads a key from the minibuffer, and performs the +corresponding action. The prompt can be canceled with C-g or +RET. PROMPT must be a string to use for the prompt. PROMPT +should include a space at the end. ACTION-MAP must be a list of triples of the form (KEY LABEL ACTION) @@ -82,16 +81,9 @@ (defun notmuch-jump (action-map prompt) (with-temp-buffer (notmuch-jump--insert-items (window-body-width) items) (buffer-string))) - (prompt-text - (if (eq this-original-command this-command) - ;; Make it look like we're just part of any regular - ;; submap prompt (like C-x, C-c, etc.) - (concat (format-kbd-macro (this-command-keys)) "-") - ;; We were invoked through something like M-x - prompt)) (full-prompt (concat table "\n\n" - (propertize prompt-text 'face 'minibuffer-prompt))) + (propertize prompt 'face 'minibuffer-prompt))) ;; By default, the minibuffer applies the minibuffer face to ;; the entire prompt. However, we want to clearly ;; distinguish bindings (which we put in the prompt face @@ -121,14 +113,14 @@ (defun notmuch-jump--format-actions (action-map) ;; Compute the maximum key description width (let ((key-width 1)) - (dolist (action action-map) + (dolist (entry action-map) (setq key-width (max key-width - (string-width (format-kbd-macro (first action)))))) + (string-width (format-kbd-macro (first entry)))))) ;; Format each action - (mapcar (lambda (action) - (let ((key (format-kbd-macro (first action))) - (desc (second action))) + (mapcar (lambda (entry) + (let ((key (format-kbd-macro (first entry))) + (desc (second entry))) (concat (propertize key 'face 'minibuffer-prompt) (make-string (- key-width (length key)) ? ) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 135422d..b338aaa 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -25,6 +25,9 @@ (require 'mm-decode) (require 'cl) +(autoload 'notmuch-jump-search "notmuch-jump" + "Jump to a saved search by shortcut key." t) + (defvar notmuch-command "notmuch" "Command to run the notmuch binary.") @@ -134,8 +137,6 @@ (defvar notmuch-common-keymap map) "Keymap shared by all notmuch modes.") -(autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by shortcut key." t) - ;; By default clicking on a button does not select the window ;; containing the button (as opposed to clicking on a widget which ;; does). This means that the button action is then executed in the