1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 93DCD431FBF
\r
6 for <notmuch@notmuchmail.org>; Wed, 7 May 2014 04:21:46 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id E8Cp5+8RTrMh for <notmuch@notmuchmail.org>;
\r
16 Wed, 7 May 2014 04:21:42 -0700 (PDT)
\r
17 Received: from mail-we0-f172.google.com (mail-we0-f172.google.com
\r
18 [74.125.82.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id CFA3C431FC3
\r
21 for <notmuch@notmuchmail.org>; Wed, 7 May 2014 04:21:39 -0700 (PDT)
\r
22 Received: by mail-we0-f172.google.com with SMTP id k48so841742wev.3
\r
23 for <notmuch@notmuchmail.org>; Wed, 07 May 2014 04:21:37 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
\r
28 bh=RdrK3DqqSYCN3W1Z9pFqjZ0Va8HuEzQVhgWkubstlIE=;
\r
29 b=VuIOfuwrNu7O6CZVrsaj1SaRDurWpN+O9NWW9vHB0wqWSUl6qA9UGyOqIXNyEnC/+O
\r
30 fki5XzSeuRPsKV63v4t4MLXpMWIWd8wHxoBgeeEGPHp203IM73oZN5I6+A89EyuoIzgd
\r
31 EyE0LpfC2ZeeixVYpNbztnUkYtpftR9JEydrdA9/CRUch19M1X2UFWqHB+ZZvq5y4bpy
\r
32 ykKdhFGQtcLjzP4FIG/sDNjAun4wz7+9mrNv8dgZrMZNx3Z545dS9aWpeKyI2eaTJw6e
\r
33 /Mg0voF8KNnNVu00vozovZNjxM4LBAPVW2XoNMzw7NKjIpvPR2WQKudxp7XuQePOAEDu
\r
36 ALoCoQmkcypotU04eTVfPIk5jziDuM/6DJpZqupRphgSIFgTg6Y9fDYzavb/uSXPD7MUyXxKdJdK
\r
37 X-Received: by 10.180.74.203 with SMTP id w11mr7206384wiv.27.1399461697275;
\r
38 Wed, 07 May 2014 04:21:37 -0700 (PDT)
\r
39 Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net.
\r
40 [81.149.164.25]) by mx.google.com with ESMTPSA id
\r
41 g13sm26211391wjn.15.2014.05.07.04.21.35 for <notmuch@notmuchmail.org>
\r
42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
43 Wed, 07 May 2014 04:21:36 -0700 (PDT)
\r
44 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
45 id D2BCF1088C5; Wed, 7 May 2014 12:21:34 +0100 (BST)
\r
46 From: David Edmondson <dme@dme.org>
\r
47 To: notmuch@notmuchmail.org
\r
48 Subject: [PATCH v2] emacs: Add support for saved search accelerators
\r
49 Date: Wed, 7 May 2014 12:21:34 +0100
\r
50 Message-Id: <1399461694-25350-2-git-send-email-dme@dme.org>
\r
51 X-Mailer: git-send-email 2.0.0.rc0
\r
52 In-Reply-To: <1399461694-25350-1-git-send-email-dme@dme.org>
\r
53 References: <1399385776-19918-1-git-send-email-dme@dme.org>
\r
54 <1399461694-25350-1-git-send-email-dme@dme.org>
\r
55 X-BeenThere: notmuch@notmuchmail.org
\r
56 X-Mailman-Version: 2.1.13
\r
58 List-Id: "Use and development of the notmuch mail system."
\r
59 <notmuch.notmuchmail.org>
\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
63 List-Post: <mailto:notmuch@notmuchmail.org>
\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
67 X-List-Received-Date: Wed, 07 May 2014 11:21:46 -0000
\r
69 Extended the saved search definition to allow the inclusion of an
\r
70 accelerator key for the search. Bind 'j' in the common mode map as a
\r
71 leader for such accelerator keys.
\r
73 emacs/notmuch-hello.el | 5 ++++-
\r
74 emacs/notmuch-lib.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++
\r
75 2 files changed, 50 insertions(+), 1 deletion(-)
\r
77 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
78 index 3de5238..64d5aa1 100644
\r
79 --- a/emacs/notmuch-hello.el
\r
80 +++ b/emacs/notmuch-hello.el
\r
81 @@ -85,6 +85,7 @@ searches so they still work in customize."
\r
82 (group :format "%v" :inline t (const :format " Query: " :query) (string :format "%v")))
\r
83 (checklist :inline t
\r
85 + (group :format "%v" :inline t (const :format " Key: " :key) (key-sequence :format "%v"))
\r
86 (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))
\r
87 (group :format "%v" :inline t (const :format "" :sort-order)
\r
88 (choice :tag " Sort Order"
\r
89 @@ -101,6 +102,7 @@ a plist. Supported properties are
\r
91 :name Name of the search (required).
\r
92 :query Search to run (required).
\r
93 + :key Optional accelerator key.
\r
94 :count-query Optional extra query to generate the count
\r
95 shown. If not present then the :query property
\r
97 @@ -551,7 +553,8 @@ with `notmuch-hello-query-counts'."
\r
99 (if (> column-indent 0)
\r
100 (widget-insert (make-string column-indent ? )))
\r
101 - (let* ((name (plist-get elem :name))
\r
102 + (let* ((key (plist-get elem :key))
\r
103 + (name (plist-get elem :name))
\r
104 (query (plist-get elem :query))
\r
105 (oldest-first (case (plist-get elem :sort-order)
\r
107 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
108 index 2941da3..f8c5f96 100644
\r
109 --- a/emacs/notmuch-lib.el
\r
110 +++ b/emacs/notmuch-lib.el
\r
112 (require 'mm-decode)
\r
115 +(declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))
\r
116 +(declare-function notmuch-saved-search-get "notmuch-hello" (saved-search field))
\r
117 +(defvar notmuch-saved-searches) ;; In `notmuch-hello.el'.
\r
119 (defvar notmuch-command "notmuch"
\r
120 "Command to run the notmuch binary.")
\r
122 @@ -130,6 +134,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
\r
123 (define-key map "m" 'notmuch-mua-new-mail)
\r
124 (define-key map "=" 'notmuch-refresh-this-buffer)
\r
125 (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)
\r
126 + (define-key map "j" 'notmuch-jump)
\r
128 "Keymap shared by all notmuch modes.")
\r
130 @@ -845,6 +850,47 @@ status."
\r
131 (defvar notmuch-show-process-crypto nil)
\r
132 (make-variable-buffer-local 'notmuch-show-process-crypto)
\r
134 +;; Jump key support:
\r
136 +(defvar notmuch-jump-search nil)
\r
137 +(defun notmuch-jump-map ()
\r
138 + (let ((map (make-sparse-keymap))
\r
140 + (set-keymap-parent map minibuffer-local-map)
\r
141 + (suppress-keymap map)
\r
142 + (dolist (saved-search notmuch-saved-searches)
\r
143 + (let ((key (notmuch-saved-search-get saved-search :key)))
\r
145 + (define-key map key `(lambda ()
\r
147 + (setq notmuch-jump-search ',saved-search)
\r
148 + (exit-minibuffer)))
\r
149 + (push (format "%s: %s"
\r
150 + (propertize key 'face 'minibuffer-prompt)
\r
151 + (notmuch-saved-search-get saved-search :name))
\r
153 + ;; Hitting ? displays a quick hint of the accelerators.
\r
154 + (define-key map "?" `(lambda ()
\r
157 + (mapconcat #'identity
\r
158 + ;; Reverse the list so
\r
159 + ;; that elements appear
\r
160 + ;; in the same order as
\r
161 + ;; `notmuch-saved-searches'.
\r
166 +(defun notmuch-jump ()
\r
167 + "Read a saved search accelerator key and perform the search."
\r
169 + (setq notmuch-jump-search nil)
\r
170 + (read-from-minibuffer "Jump to saved search: " nil (notmuch-jump-map))
\r
171 + (when notmuch-jump-search
\r
172 + (notmuch-search (notmuch-saved-search-get notmuch-jump-search :query)
\r
173 + (notmuch-saved-search-get notmuch-jump-search :oldest-first))))
\r
175 (provide 'notmuch-lib)
\r
177 ;; Local Variables:
\r