Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / fb / b641fc2653b87fd17ce047077c9b8b28f755f4
1 Return-Path: <jani@nikula.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 02B77429E26\r
6         for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:54 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[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 A0XWRPRnd0lj for <notmuch@notmuchmail.org>;\r
17         Fri, 28 Oct 2011 13:59:52 -0700 (PDT)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id B9E10429E21\r
22         for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:50 -0700 (PDT)\r
23 Received: by mail-fx0-f53.google.com with SMTP id i28so4419077faa.26\r
24         for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 13:59:50 -0700 (PDT)\r
25 Received: by 10.223.91.143 with SMTP id n15mr8562643fam.23.1319835590481;\r
26         Fri, 28 Oct 2011 13:59:50 -0700 (PDT)\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
28         [80.220.92.23])\r
29         by mx.google.com with ESMTPS id v19sm19448615faa.13.2011.10.28.13.59.48\r
30         (version=SSLv3 cipher=OTHER); Fri, 28 Oct 2011 13:59:49 -0700 (PDT)\r
31 From: Jani Nikula <jani@nikula.org>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [RFC PATCH 3/3] emacs: support limiting the number of messages shown\r
34         in search results\r
35 Date: Fri, 28 Oct 2011 23:59:31 +0300\r
36 Message-Id:\r
37  <0290050284e4cb3a6f5ef0eb3582319f8d52ccf2.1319833617.git.jani@nikula.org>\r
38 X-Mailer: git-send-email 1.7.5.4\r
39 In-Reply-To: <cover.1319833617.git.jani@nikula.org>\r
40 References: <cover.1319833617.git.jani@nikula.org>\r
41 In-Reply-To: <cover.1319833617.git.jani@nikula.org>\r
42 References: <cover.1319833617.git.jani@nikula.org>\r
43 Cc: amdragon@mit.edu\r
44 X-BeenThere: notmuch@notmuchmail.org\r
45 X-Mailman-Version: 2.1.13\r
46 Precedence: list\r
47 List-Id: "Use and development of the notmuch mail system."\r
48         <notmuch.notmuchmail.org>\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
52 List-Post: <mailto:notmuch@notmuchmail.org>\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
56 X-List-Received-Date: Fri, 28 Oct 2011 20:59:54 -0000\r
57 \r
58 Add support for limiting the maximum number of messages initially displayed\r
59 in search results. When enabled, the search results will contain push\r
60 buttons to double the number of messages displayed or to show unlimited\r
61 messages.\r
62 \r
63 The approach is inspired by vc-print-log in Emacs vc.el.\r
64 \r
65 Signed-off-by: Jani Nikula <jani@nikula.org>\r
66 ---\r
67  emacs/notmuch-hello.el |   19 ++++++++++++++++---\r
68  emacs/notmuch.el       |   43 ++++++++++++++++++++++++++++++++++++++-----\r
69  2 files changed, 54 insertions(+), 8 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
72 index 65fde75..16eecb6 100644\r
73 --- a/emacs/notmuch-hello.el\r
74 +++ b/emacs/notmuch-hello.el\r
75 @@ -26,7 +26,7 @@\r
76  (require 'notmuch-lib)\r
77  (require 'notmuch-mua)\r
78  \r
79 -(declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))\r
80 +(declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation maxitems))\r
81  (declare-function notmuch-poll "notmuch" ())\r
82  \r
83  (defvar notmuch-hello-search-bar-marker nil\r
84 @@ -37,6 +37,18 @@\r
85    :type 'integer\r
86    :group 'notmuch)\r
87  \r
88 +(defcustom notmuch-search-maxitems 100\r
89 +  "The maximum number of messages to show in search results.\r
90 +\r
91 +This variables controls the maximum number of messages to\r
92 +initially show in search results. Set to 0 to unlimited. If\r
93 +non-zero, the search results will contain push buttons to double\r
94 +the number (can be repeated) or show unlimited number of\r
95 +messages. Note that this controls the number of messages; in a\r
96 +threaded view this is not the number of lines to show."\r
97 +  :type 'integer\r
98 +  :group 'notmuch)\r
99 +\r
100  (defcustom notmuch-show-empty-saved-searches nil\r
101    "Should saved searches with no messages be listed?"\r
102    :type 'boolean\r
103 @@ -151,7 +163,7 @@ Typically \",\" in the US and UK and \".\" in Europe."\r
104  (defun notmuch-hello-search (search)\r
105    (let ((search (notmuch-hello-trim search)))\r
106      (notmuch-hello-remember-search search)\r
107 -    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))\r
108 +    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation notmuch-search-maxitems)))\r
109  \r
110  (defun notmuch-hello-add-saved-search (widget)\r
111    (interactive)\r
112 @@ -201,7 +213,8 @@ diagonal."\r
113    (notmuch-search (widget-get widget\r
114                               :notmuch-search-terms)\r
115                   notmuch-search-oldest-first\r
116 -                 nil nil #'notmuch-hello-search-continuation))\r
117 +                 nil nil #'notmuch-hello-search-continuation\r
118 +                 notmuch-search-maxitems))\r
119  \r
120  (defun notmuch-saved-search-count (search)\r
121    (car (process-lines notmuch-command "count" search)))\r
122 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
123 index f11ec24..bb805da 100644\r
124 --- a/emacs/notmuch.el\r
125 +++ b/emacs/notmuch.el\r
126 @@ -193,6 +193,7 @@ For a mouse binding, return nil."\r
127  \r
128  (defvar notmuch-search-mode-map\r
129    (let ((map (make-sparse-keymap)))\r
130 +    (set-keymap-parent map widget-keymap)\r
131      (define-key map "?" 'notmuch-help)\r
132      (define-key map "q" 'notmuch-search-quit)\r
133      (define-key map "x" 'notmuch-search-quit)\r
134 @@ -217,7 +218,13 @@ For a mouse binding, return nil."\r
135      (define-key map "a" 'notmuch-search-archive-thread)\r
136      (define-key map "-" 'notmuch-search-remove-tag)\r
137      (define-key map "+" 'notmuch-search-add-tag)\r
138 -    (define-key map (kbd "RET") 'notmuch-search-show-thread)\r
139 +    ; Some hackery to allow RET both on buttons and messages. There's probably a\r
140 +    ; better way to do this...\r
141 +    (define-key map (kbd "RET") '(lambda (pos)\r
142 +                                  (interactive "@d")\r
143 +                                  (if (get-char-property pos 'button)\r
144 +                                      (widget-button-press pos)\r
145 +                                    (notmuch-search-show-thread))))\r
146      (define-key map (kbd "M-RET") 'notmuch-search-show-thread-crypto-switch)\r
147      map)\r
148    "Keymap for \"notmuch search\" buffers.")\r
149 @@ -239,6 +246,7 @@ For a mouse binding, return nil."\r
150  (defvar notmuch-search-target-thread)\r
151  (defvar notmuch-search-target-line)\r
152  (defvar notmuch-search-continuation)\r
153 +(defvar notmuch-search-maxitems)\r
154  \r
155  (defvar notmuch-search-disjunctive-regexp      "\\<[oO][rR]\\>")\r
156  \r
157 @@ -373,6 +381,7 @@ Complete list of currently available key bindings:\r
158    (make-local-variable 'notmuch-search-oldest-first)\r
159    (make-local-variable 'notmuch-search-target-thread)\r
160    (make-local-variable 'notmuch-search-target-line)\r
161 +  (make-local-variable 'notmuch-search-maxitems)\r
162    (set (make-local-variable 'notmuch-search-continuation) nil)\r
163    (set (make-local-variable 'scroll-preserve-screen-position) t)\r
164    (add-to-invisibility-spec 'notmuch-search)\r
165 @@ -633,6 +642,8 @@ This function advances the next thread when finished."\r
166                         (insert "End of search results.")\r
167                         (if (not (= exit-status 0))\r
168                             (insert (format " (process returned %d)" exit-status)))\r
169 +                       (if notmuch-search-maxitems\r
170 +                           (notmuch-search-setup-buttons))\r
171                         (insert "\n")\r
172                         (if (and atbob\r
173                                  (not (string= notmuch-search-target-thread "found")))\r
174 @@ -883,7 +894,7 @@ characters as well as `_.+-'.\r
175           )))\r
176  \r
177  ;;;###autoload\r
178 -(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)\r
179 +(defun notmuch-search (query &optional oldest-first target-thread target-line continuation maxitems)\r
180    "Run \"notmuch search\" with the given query string and display results.\r
181  \r
182  The optional parameters are used as follows:\r
183 @@ -899,6 +910,7 @@ The optional parameters are used as follows:\r
184      (notmuch-search-mode)\r
185      (set 'notmuch-search-query-string query)\r
186      (set 'notmuch-search-oldest-first oldest-first)\r
187 +    (set 'notmuch-search-maxitems maxitems)\r
188      (set 'notmuch-search-target-thread target-thread)\r
189      (set 'notmuch-search-target-line target-line)\r
190      (set 'notmuch-search-continuation continuation)\r
191 @@ -916,6 +928,8 @@ The optional parameters are used as follows:\r
192                      (if oldest-first\r
193                          "--sort=oldest-first"\r
194                        "--sort=newest-first")\r
195 +                    (if maxitems\r
196 +                        (format "--maxitems=%d" maxitems))\r
197                      query)))\r
198           (set-process-sentinel proc 'notmuch-search-process-sentinel)\r
199           (set-process-filter proc 'notmuch-search-process-filter))))\r
200 @@ -932,13 +946,32 @@ same relative position within the new buffer."\r
201    (interactive)\r
202    (let ((target-line (line-number-at-pos))\r
203         (oldest-first notmuch-search-oldest-first)\r
204 +       (maxitems notmuch-search-maxitems)\r
205         (target-thread (notmuch-search-find-thread-id))\r
206         (query notmuch-search-query-string)\r
207         (continuation notmuch-search-continuation))\r
208      (notmuch-kill-this-buffer)\r
209 -    (notmuch-search query oldest-first target-thread target-line continuation)\r
210 +    (notmuch-search query oldest-first target-thread target-line continuation maxitems)\r
211      (goto-char (point-min))))\r
212  \r
213 +(defun notmuch-search-setup-buttons ()\r
214 +  (widget-insert "    ")\r
215 +  (widget-create 'push-button\r
216 +                :notify (lambda (&rest ignore)\r
217 +                          (set 'notmuch-search-maxitems\r
218 +                               (* 2 notmuch-search-maxitems))\r
219 +                          (notmuch-search-refresh-view))\r
220 +                :help-echo "Double the number of messages shown"\r
221 +                "Show 2X messages")\r
222 +  (widget-insert "    ")\r
223 +  (widget-create 'push-button\r
224 +                :notify (lambda (&rest ignore)\r
225 +                          (set 'notmuch-search-maxitems 0)\r
226 +                          (notmuch-search-refresh-view))\r
227 +                :help-echo "Show all search results"\r
228 +                "Show unlimited messages")\r
229 +  (widget-setup))\r
230 +\r
231  (defcustom notmuch-poll-script ""\r
232    "An external script to incorporate new mail into the notmuch database.\r
233  \r
234 @@ -997,7 +1030,7 @@ current search results AND the additional query string provided."\r
235                          query)))\r
236      (notmuch-search (if (string= notmuch-search-query-string "*")\r
237                         grouped-query\r
238 -                     (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first)))\r
239 +                     (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first notmuch-search-maxitems)))\r
240  \r
241  (defun notmuch-search-filter-by-tag (tag)\r
242    "Filter the current search results based on a single tag.\r
243 @@ -1006,7 +1039,7 @@ Runs a new search matching only messages that match both the\r
244  current search results AND that are tagged with the given tag."\r
245    (interactive\r
246     (list (notmuch-select-tag-with-completion "Filter by tag: ")))\r
247 -  (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first))\r
248 +  (notmuch-search (concat notmuch-search-query-string " and tag:" tag) notmuch-search-oldest-first notmuch-search-maxitems))\r
249  \r
250  ;;;###autoload\r
251  (defun notmuch ()\r
252 -- \r
253 1.7.5.4\r
254 \r