Re: [PATCH] doc: Allow rst2man.py as an alternative to rst2man
[notmuch-archives.git] / 6b / 133af2ca48eed65c2e6f5266ce35b3a6e15486
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 3B636431FC9\r
6         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 12:24:09 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, 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 Q1UFLG2ERcis for <notmuch@notmuchmail.org>;\r
17         Wed, 18 Jan 2012 12:24:05 -0800 (PST)\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
19         [209.85.214.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 6550A431FC4\r
22         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 12:24:02 -0800 (PST)\r
23 Received: by mail-bk0-f53.google.com with SMTP id y12so2078178bkt.26\r
24         for <notmuch@notmuchmail.org>; Wed, 18 Jan 2012 12:24:02 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=zYDwm5/vF84k0K408pBI0zR4klfBYhjGCIeqfZyiaIM=;\r
28         b=SQPadjCjM6UaWutBbovOw0LpIqBNs+Kup8Jf2AgIAbc9gFGfbMgaPemPYKYKFxzgaT\r
29         IbFMDfbdCEEqdS30IoCUdvjnzklNS2lvlYumc2Tv6egPacKxhY7w24Cr2O1MqRo4nfYN\r
30         9rY9xG9nQCN66hYr8BiFqX+hvQmacbCmsN2Jc=\r
31 Received: by 10.205.141.76 with SMTP id jd12mr1970995bkc.42.1326918242077;\r
32         Wed, 18 Jan 2012 12:24:02 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id y22sm57205116bkf.4.2012.01.18.12.23.59\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Wed, 18 Jan 2012 12:24:00 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v2 2/3] emacs: use a single history for all searches\r
40 Date: Thu, 19 Jan 2012 00:22:55 +0400\r
41 Message-Id: <1326918176-20352-3-git-send-email-dmitry.kurochkin@gmail.com>\r
42 X-Mailer: git-send-email 1.7.8.3\r
43 In-Reply-To: <1326918176-20352-1-git-send-email-dmitry.kurochkin@gmail.com>\r
44 References: <1326828850-8519-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45         <1326918176-20352-1-git-send-email-dmitry.kurochkin@gmail.com>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Wed, 18 Jan 2012 20:24:09 -0000\r
59 \r
60 There are two ways to do search in Emacs UI: search widget in\r
61 notmuch-hello buffer and `notmuch-search' function bound to "s".\r
62 Before the change, these search mechanisms used different history\r
63 lists.  The patch makes notmuch-hello search use the same history list\r
64 as `notmuch-search' function.\r
65 ---\r
66  emacs/notmuch-hello.el |   49 ++++++++++++++---------------------------------\r
67  emacs/notmuch-lib.el   |    9 ++++++++\r
68  emacs/notmuch.el       |   19 ++++++++++++-----\r
69  3 files changed, 37 insertions(+), 40 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
72 index 08fcd22..cb36977 100644\r
73 --- a/emacs/notmuch-hello.el\r
74 +++ b/emacs/notmuch-hello.el\r
75 @@ -29,8 +29,8 @@\r
76  (declare-function notmuch-search "notmuch" (query &optional oldest-first target-thread target-line continuation))\r
77  (declare-function notmuch-poll "notmuch" ())\r
78  \r
79 -(defcustom notmuch-recent-searches-max 10\r
80 -  "The number of recent searches to store and display."\r
81 +(defcustom notmuch-hello-recent-searches-max 10\r
82 +  "The number of recent searches to display."\r
83    :type 'integer\r
84    :group 'notmuch)\r
85  \r
86 @@ -151,16 +151,6 @@ International Bureau of Weights and Measures."\r
87  (defvar notmuch-hello-url "http://notmuchmail.org"\r
88    "The `notmuch' web site.")\r
89  \r
90 -(defvar notmuch-hello-recent-searches nil)\r
91 -\r
92 -(defun notmuch-hello-remember-search (search)\r
93 -  (setq notmuch-hello-recent-searches\r
94 -       (delete search notmuch-hello-recent-searches))\r
95 -  (push search notmuch-hello-recent-searches)\r
96 -  (if (> (length notmuch-hello-recent-searches)\r
97 -        notmuch-recent-searches-max)\r
98 -      (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))\r
99 -\r
100  (defun notmuch-hello-nice-number (n)\r
101    (let (result)\r
102      (while (> n 0)\r
103 @@ -173,16 +163,9 @@ International Bureau of Weights and Measures."\r
104               (format "%s%03d" notmuch-hello-thousands-separator elem))\r
105              (cdr result)))))\r
106  \r
107 -(defun notmuch-hello-trim (search)\r
108 -  "Trim whitespace."\r
109 -  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)\r
110 -      (match-string 1 search)\r
111 -    search))\r
112 -\r
113  (defun notmuch-hello-search (search)\r
114 -  (let ((search (notmuch-hello-trim search)))\r
115 -    (notmuch-hello-remember-search search)\r
116 -    (notmuch-search search notmuch-search-oldest-first nil nil #'notmuch-hello-search-continuation)))\r
117 +  (notmuch-search search notmuch-search-oldest-first nil nil\r
118 +                 #'notmuch-hello-search-continuation))\r
119  \r
120  (defun notmuch-hello-add-saved-search (widget)\r
121    (interactive)\r
122 @@ -461,7 +444,7 @@ Complete list of currently available key bindings:\r
123  \r
124      (let ((found-target-pos nil)\r
125           (final-target-pos nil)\r
126 -         (search-bar-pos))\r
127 +         (default-pos))\r
128        (let* ((saved-alist\r
129               ;; Filter out empty saved searches if required.\r
130               (if notmuch-show-empty-saved-searches\r
131 @@ -493,7 +476,7 @@ Complete list of currently available key bindings:\r
132             (indent-rigidly start (point) notmuch-hello-indent)))\r
133  \r
134         (widget-insert "\nSearch: ")\r
135 -       (setq search-bar-pos (point-marker))\r
136 +       (setq default-pos (point-marker))\r
137         (widget-create 'editable-field\r
138                        ;; Leave some space at the start and end of the\r
139                        ;; search boxes.\r
140 @@ -507,18 +490,18 @@ Complete list of currently available key bindings:\r
141         (put-text-property (1- (point)) (point) 'invisible t)\r
142         (widget-insert "\n")\r
143  \r
144 -       (when notmuch-hello-recent-searches\r
145 +       (when notmuch-search-history\r
146           (widget-insert "\nRecent searches: ")\r
147           (widget-create 'push-button\r
148                          :notify (lambda (&rest ignore)\r
149 -                                  (setq notmuch-hello-recent-searches nil)\r
150 +                                  (setq notmuch-search-history nil)\r
151                                    (notmuch-hello-update))\r
152                          "clear")\r
153           (widget-insert "\n\n")\r
154 -         (let ((start (point))\r
155 -               (nth 0))\r
156 -           (mapc (lambda (search)\r
157 -                   (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))\r
158 +         (let ((start (point)))\r
159 +           (loop for i from 1 to notmuch-hello-recent-searches-max\r
160 +                 for search in notmuch-search-history do\r
161 +                   (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))\r
162                       (set widget-symbol\r
163                            (widget-create 'editable-field\r
164                                           ;; Don't let the search boxes be\r
165 @@ -545,9 +528,7 @@ Complete list of currently available key bindings:\r
166                                                (notmuch-hello-add-saved-search widget))\r
167                                      :notmuch-saved-search-widget widget-symbol\r
168                                      "save"))\r
169 -                   (widget-insert "\n")\r
170 -                   (setq nth (1+ nth)))\r
171 -                 notmuch-hello-recent-searches)\r
172 +                   (widget-insert "\n"))\r
173             (indent-rigidly start (point) notmuch-hello-indent)))\r
174  \r
175         (when alltags-alist\r
176 @@ -576,7 +557,7 @@ Complete list of currently available key bindings:\r
177        (let ((start (point)))\r
178         (widget-insert "\n\n")\r
179         (widget-insert "Type a search query and hit RET to view matching threads.\n")\r
180 -       (when notmuch-hello-recent-searches\r
181 +       (when notmuch-search-history\r
182           (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")\r
183           (widget-insert "Save recent searches with the `save' button.\n"))\r
184         (when notmuch-saved-searches\r
185 @@ -594,7 +575,7 @@ Complete list of currently available key bindings:\r
186           (widget-forward 1)))\r
187  \r
188        (unless (widget-at)\r
189 -       (goto-char search-bar-pos))))\r
190 +       (goto-char default-pos))))\r
191  \r
192    (run-hooks 'notmuch-hello-refresh-hook))\r
193  \r
194 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
195 index 0f856bf..dfbc2e0 100644\r
196 --- a/emacs/notmuch-lib.el\r
197 +++ b/emacs/notmuch-lib.el\r
198 @@ -35,6 +35,9 @@\r
199  \r
200  ;;\r
201  \r
202 +(defvar notmuch-search-history nil\r
203 +  "Variable to store notmuch searches history.")\r
204 +\r
205  (defcustom notmuch-saved-searches nil\r
206    "A list of saved searches to display."\r
207    :type '(alist :key-type string :value-type string)\r
208 @@ -114,6 +117,12 @@ the user hasn't set this variable with the old or new value."\r
209        (setq list (cdr list)))\r
210      (nreverse out)))\r
211  \r
212 +(defun notmuch-trim (search)\r
213 +  "Trim whitespaces."\r
214 +  (if (string-match "^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$" search)\r
215 +      (match-string 1 search)\r
216 +    search))\r
217 +\r
218  ; This lets us avoid compiling these replacement functions when emacs\r
219  ; is sufficiently new enough to supply them alone. We do the macro\r
220  ; treatment rather than just wrapping our defun calls in a when form\r
221 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
222 index ef4dcc7..450c0c1 100644\r
223 --- a/emacs/notmuch.el\r
224 +++ b/emacs/notmuch.el\r
225 @@ -916,21 +916,28 @@ PROMPT is the string to prompt with."\r
226                (t (list string)))))))\r
227        ;; this was simpler than convincing completing-read to accept spaces:\r
228        (define-key keymap (kbd "<tab>") 'minibuffer-complete)\r
229 -      (read-from-minibuffer prompt nil keymap nil\r
230 -                           'notmuch-query-history nil nil))))\r
231 +      (let ((history-delete-duplicates t))\r
232 +       (read-from-minibuffer prompt nil keymap nil\r
233 +                             'notmuch-search-history nil nil)))))\r
234  \r
235  ;;;###autoload\r
236 -(defun notmuch-search (query &optional oldest-first target-thread target-line continuation)\r
237 -  "Run \"notmuch search\" with the given query string and display results.\r
238 +(defun notmuch-search (&optional query oldest-first target-thread target-line continuation)\r
239 +  "Run \"notmuch search\" with the given `query' and display results.\r
240  \r
241 -The optional parameters are used as follows:\r
242 +If `query' is nil, it is read interactively from the minibuffer.\r
243 +Other optional parameters are used as follows:\r
244  \r
245    oldest-first: A Boolean controlling the sort order of returned threads\r
246    target-thread: A thread ID (with the thread: prefix) that will be made\r
247                   current if it appears in the search results.\r
248    target-line: The line number to move to if the target thread does not\r
249                 appear in the search results."\r
250 -  (interactive (list (notmuch-read-query "Notmuch search: ")))\r
251 +  (interactive)\r
252 +  (if (null query)\r
253 +      (setq query (notmuch-read-query "Notmuch search: "))\r
254 +    (setq query (notmuch-trim query))\r
255 +    (let ((history-delete-duplicates t))\r
256 +      (add-to-history 'notmuch-search-history query)))\r
257    (let ((buffer (get-buffer-create (notmuch-search-buffer-title query))))\r
258      (switch-to-buffer buffer)\r
259      (notmuch-search-mode)\r
260 -- \r
261 1.7.8.3\r
262 \r