Re: notmuch and "mute" -- useful to anyone?
[notmuch-archives.git] / 0d / 81bcb6e870708ca75db753b8d9e3bf13f748c8
1 Return-Path: <m.walters@qmul.ac.uk>\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 28D71431FC7\r
6         for <notmuch@notmuchmail.org>; Tue,  6 May 2014 09:43:38 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.502\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.502 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id ux9qhNfSM5us for <notmuch@notmuchmail.org>;\r
17         Tue,  6 May 2014 09:43:30 -0700 (PDT)\r
18 Received: from mail1.qmul.ac.uk (mail1.qmul.ac.uk [138.37.6.7])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 83D5F431FAF\r
22         for <notmuch@notmuchmail.org>; Tue,  6 May 2014 09:43:30 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail1.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1WhiQl-00057k-He; Tue, 06 May 2014 17:43:28 +0100\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WhiQl-0006nJ-6E; Tue, 06 May 2014 17:41:23 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
33 Subject: Re: [RFC] [PATCH] emacs: Add support for saved search accelerators.\r
34 In-Reply-To: <1399385776-19918-1-git-send-email-dme@dme.org>\r
35 References: <1399385776-19918-1-git-send-email-dme@dme.org>\r
36 User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
37         (x86_64-pc-linux-gnu)\r
38 Date: Tue, 06 May 2014 17:41:21 +0100\r
39 Message-ID: <87oazaq2q6.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 87.81.223.162\r
43 X-QM-Geographic: According to ripencc,\r
44         this message was delivered by a machine in Britain (UK) (GB).\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: a8a84af88f5258eb440537911183618f (of first 20000 bytes)\r
47 X-QM-Scan-Virus: ClamAV says the message is clean\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Tue, 06 May 2014 16:43:38 -0000\r
61 \r
62 \r
63 Hi\r
64 \r
65 Yes this looks nice modulo polishing. I think the nifty window-splitting\r
66 Austin's notmuch-go does is moderately orthogonal to the keyboard\r
67 shortcuts (since shortcuts can be used without it, and it could be used\r
68 for other things too)\r
69 \r
70 On Tue, 06 May 2014, David Edmondson <dme@dme.org> wrote:\r
71 > Extended the saved search definition to allow the inclusion of an\r
72 > accelerator key for the search. Bind 'j' in the common mode map as a\r
73 > leader for such accelerator keys.\r
74 > ---\r
75 >\r
76 > This arose out a conversation in #notmuch and Mark's patch to extend\r
77 > the saved search custom specification based on requirements for an\r
78 > external package (Austin's notmuch-go.el).\r
79 >\r
80 > Re-organising the layout of the saved searches is missing (as it's\r
81 > lots of fiddling about with absolute numbers and I didn't want to\r
82 > waste time on it if this is going nowhere), so the saved searches may\r
83 > not all line up correctly in notmuch-hello.\r
84 >\r
85 >  emacs/notmuch-hello.el |  8 ++++++--\r
86 >  emacs/notmuch-lib.el   | 27 +++++++++++++++++++++++++++\r
87 >  2 files changed, 33 insertions(+), 2 deletions(-)\r
88 >\r
89 > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
90 > index 3de5238..56379ef 100644\r
91 > --- a/emacs/notmuch-hello.el\r
92 > +++ b/emacs/notmuch-hello.el\r
93 > @@ -85,6 +85,7 @@ searches so they still work in customize."\r
94 >               (group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))\r
95 >         (checklist :inline t\r
96 >                    :format "%v"\r
97 > +                  (group :format "%v" :inline t (const :format "    Key: " :key) (string :format "%v"))\r
98 \r
99 if you use key-sequence rather than string then this is a bit nicer. It\r
100 allows a multiple key press binding: eg  "n i" or "C-n".\r
101 \r
102 >                    (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
103 >                    (group :format "%v" :inline t (const :format "" :sort-order)\r
104 >                           (choice :tag " Sort Order"\r
105 > @@ -551,7 +552,8 @@ with `notmuch-hello-query-counts'."\r
106 >           (when elem\r
107 >             (if (> column-indent 0)\r
108 >                 (widget-insert (make-string column-indent ? )))\r
109 > -           (let* ((name (plist-get elem :name))\r
110 > +           (let* ((key (plist-get elem :key))\r
111 > +                  (name (plist-get elem :name))\r
112 >                    (query (plist-get elem :query))\r
113 >                    (oldest-first (case (plist-get elem :sort-order)\r
114 >                                    (newest-first nil)\r
115 > @@ -564,7 +566,9 @@ with `notmuch-hello-query-counts'."\r
116 >                              :notify #'notmuch-hello-widget-search\r
117 >                              :notmuch-search-terms query\r
118 >                              :notmuch-search-oldest-first oldest-first\r
119 > -                            name)\r
120 > +                            (if key\r
121 > +                                (concat name " (" key ")")\r
122 > +                              name))\r
123 \r
124 I think it might be worth having an option to suppress the display of\r
125 the binding: I think inbox (i) would annoy me, but it is good for discoverability.\r
126 I, personally, would be completely happy without the displayed binding.\r
127 \r
128 Actually just a thought: could ? in jump-mode-map be bound to something\r
129 that displayed the bindings?\r
130 \r
131 >               (setq column-indent\r
132 >                     (1+ (max 0 (- column-width (length name)))))))\r
133 >           (setq count (1+ count))\r
134 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
135 > index 2941da3..9aa7ba7 100644\r
136 > --- a/emacs/notmuch-lib.el\r
137 > +++ b/emacs/notmuch-lib.el\r
138 > @@ -130,6 +130,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
139 >      (define-key map "m" 'notmuch-mua-new-mail)\r
140 >      (define-key map "=" 'notmuch-refresh-this-buffer)\r
141 >      (define-key map "G" 'notmuch-poll-and-refresh-this-buffer)\r
142 > +    (define-key map "j" 'notmuch-jump)\r
143 >      map)\r
144 >    "Keymap shared by all notmuch modes.")\r
145 >  \r
146 > @@ -845,6 +846,32 @@ status."\r
147 >  (defvar notmuch-show-process-crypto nil)\r
148 >  (make-variable-buffer-local 'notmuch-show-process-crypto)\r
149 >  \r
150 > +;; Jump key support:\r
151 > +\r
152 > +(defvar notmuch-jump-search nil)\r
153 > +(defun notmuch-jump-map ()\r
154 > +  (let ((map (make-sparse-keymap)))\r
155 > +    (set-keymap-parent map nil)\r
156 \r
157 if you make the parent keymap the minibuffer-local-map then the various\r
158 exits from the minibuffer work (ctrl-g and return for example)\r
159 \r
160 > +    (suppress-keymap map)\r
161 > +    (dolist (saved-search notmuch-saved-searches)\r
162 > +      (let ((key (plist-get saved-search :key)))\r
163 > +     (when key\r
164 > +       (define-key map key `(lambda ()\r
165 > +                              (interactive)\r
166 > +                              (setq notmuch-jump-search ',saved-search)\r
167 > +                              (exit-minibuffer)\r
168 > +                              )))))\r
169 > +    map))\r
170 > +\r
171 > +(defun notmuch-jump ()\r
172 > +  "Read a saved search accelerator key and perform the associated\r
173 > +search."\r
174 > +  (interactive)\r
175 > +  (read-from-minibuffer "Jump to saved search: " nil (notmuch-jump-map))\r
176 > +  (when notmuch-jump-search\r
177 > +    (notmuch-search (plist-get notmuch-jump-search :query)\r
178 > +                 (plist-get notmuch-jump-search :oldest-first))))\r
179 \r
180 These two plist-gets should be notmuch-saved-search-get. That is a\r
181 helper so that people with old style saved searches (a cons cell of name\r
182 and query) don't get errors.\r
183 \r
184 (There were also a couple of "not yet declared" things.)\r
185 \r
186 Best wishes\r
187 \r
188 Mark\r
189 \r
190 > +\r
191 >  (provide 'notmuch-lib)\r
192 >  \r
193 >  ;; Local Variables:\r
194 > -- \r
195 > 2.0.0.rc0\r
196 >\r
197 > _______________________________________________\r
198 > notmuch mailing list\r
199 > notmuch@notmuchmail.org\r
200 > http://notmuchmail.org/mailman/listinfo/notmuch\r