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 EE2A6429E25 for ; Tue, 6 May 2014 07:16:25 -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 jvChatfKDnxr for ; Tue, 6 May 2014 07:16:20 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 427AA431FD6 for ; Tue, 6 May 2014 07:16:20 -0700 (PDT) Received: by mail-wg0-f50.google.com with SMTP id x12so2977241wgg.9 for ; Tue, 06 May 2014 07:16:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=XYSvl8PuSAAHcr81492E7eFt5egw7rzl6TPD5VqyZFw=; b=LsTweXzeG57kqdgzrl1TW5ax9jFjEo/0jC6SIKj1y3uxr/dMDjQLxk5zsOF4xE2RDm C2Xn71LfkTcZMlwU3h6p0osxWtZjlrY9FeVNDTBOzJt+lgu+0aI0XnUcITbd/F5Wk2aE pZKmsGNG2RGJzg5jYUch/xXVNfXJ6DIPSv76UWFsXBi3LKDp4fw/w8OA0fNLLdKMqxHA 6Lt4wAGr25Tq7/wCbZyQ9qi1ycn2Ch9o8vgb80CqTBamx2SHxZD3W9dP9Sx9jx7y85C2 4enJ9ePTzCkl5aYFRXXqdaZLNvkal0vf/Mf9f4fKbmckNKqdCCFzZiMeLuRKeSCHTGRn rxxg== X-Gm-Message-State: ALoCoQll1K15fxdP9HUQWGi6jlNY0WGb1/KsIW4DYRo9Cet424n5CHXV7fnGMjuyQ4G48V4aS5Gq X-Received: by 10.194.60.114 with SMTP id g18mr2583687wjr.61.1399385778972; Tue, 06 May 2014 07:16:18 -0700 (PDT) Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net. [81.149.164.25]) by mx.google.com with ESMTPSA id v15sm756960wjq.17.2014.05.06.07.16.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 May 2014 07:16:17 -0700 (PDT) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 1CF8A1009A6; Tue, 6 May 2014 15:16:16 +0100 (BST) From: David Edmondson To: notmuch@notmuchmail.org Subject: [RFC] [PATCH] emacs: Add support for saved search accelerators. Date: Tue, 6 May 2014 15:16:16 +0100 Message-Id: <1399385776-19918-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 2.0.0.rc0 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 14:16:26 -0000 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")) (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)) (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) + (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)))) + (provide 'notmuch-lib) ;; Local Variables: -- 2.0.0.rc0