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 EBD96429E25
\r
6 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 19:48:02 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 0DGIGIfFU8sl for <notmuch@notmuchmail.org>;
\r
17 Fri, 23 Dec 2011 19:48:01 -0800 (PST)
\r
18 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com
\r
19 [209.85.212.181]) (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 7F79C429E26
\r
22 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 19:48:01 -0800 (PST)
\r
23 Received: by wibhq2 with SMTP id hq2so4263920wib.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 19:48:00 -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;
\r
27 bh=oY82o7LylFAewpy5yxV5y4zpMoecmULBLzOmhDB6Mlw=;
\r
28 b=Z0l5emhWQ5ix6qqGyCnHNG1C+ZXQKE+lRz2AFkc5tGUhBdVOedHZIp9l0dQwPXIWRh
\r
29 2/yiBczaNIwx6KyKc1/BDI8bc3ecfqfn/WCDRJ037W7fk7dA/u1J1YV6JZZ31wGpMfRp
\r
30 D2DQh9S/cZPcGnL7i2KJYmXh9U+rJA8Tb8GB0=
\r
31 Received: by 10.180.19.74 with SMTP id c10mr37386068wie.8.1324698480230;
\r
32 Fri, 23 Dec 2011 19:48:00 -0800 (PST)
\r
33 Received: from localhost ([91.144.186.21])
\r
34 by mx.google.com with ESMTPS id fg15sm15920365wbb.7.2011.12.23.19.47.59
\r
35 (version=TLSv1/SSLv3 cipher=OTHER);
\r
36 Fri, 23 Dec 2011 19:47:59 -0800 (PST)
\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 1/3] emacs: use a single history for all searches
\r
40 Date: Sat, 24 Dec 2011 07:47:14 +0400
\r
41 Message-Id: <1324698436-8532-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
42 X-Mailer: git-send-email 1.7.7.3
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Sat, 24 Dec 2011 03:48:03 -0000
\r
57 There are two ways to do search in Emacs UI: search widget in
\r
58 notmuch-hello buffer and `notmuch-search' function bound to "s".
\r
59 Before the change, these search mechanisms used different history
\r
60 lists. The patch makes notmuch-hello search use the same history list
\r
61 as `notmuch-search' function.
\r
63 emacs/notmuch-hello.el | 35 +++++++++++++++--------------------
\r
64 emacs/notmuch.el | 8 +++-----
\r
65 2 files changed, 18 insertions(+), 25 deletions(-)
\r
67 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
68 index 333d4c1..ba34ac5 100644
\r
69 --- a/emacs/notmuch-hello.el
\r
70 +++ b/emacs/notmuch-hello.el
\r
72 (defvar notmuch-hello-search-bar-marker nil
\r
73 "The position of the search bar within the notmuch-hello buffer.")
\r
75 -(defcustom notmuch-recent-searches-max 10
\r
76 - "The number of recent searches to store and display."
\r
77 +(defvar notmuch-query-history nil
\r
78 + "Variable to store history for notmuch queries.")
\r
80 +(defcustom notmuch-hello-recent-searches-max 10
\r
81 + "The number of recent searches to display."
\r
85 @@ -154,15 +157,9 @@ International Bureau of Weights and Measures."
\r
86 (defvar notmuch-hello-url "http://notmuchmail.org"
\r
87 "The `notmuch' web site.")
\r
89 -(defvar notmuch-hello-recent-searches nil)
\r
91 (defun notmuch-hello-remember-search (search)
\r
92 - (setq notmuch-hello-recent-searches
\r
93 - (delete search notmuch-hello-recent-searches))
\r
94 - (push search notmuch-hello-recent-searches)
\r
95 - (if (> (length notmuch-hello-recent-searches)
\r
96 - notmuch-recent-searches-max)
\r
97 - (setq notmuch-hello-recent-searches (butlast notmuch-hello-recent-searches))))
\r
98 + (let ((history-delete-duplicates t))
\r
99 + (add-to-history 'notmuch-query-history search)))
\r
101 (defun notmuch-hello-nice-number (n)
\r
103 @@ -512,18 +509,18 @@ Complete list of currently available key bindings:
\r
104 (put-text-property (1- (point)) (point) 'invisible t)
\r
105 (widget-insert "\n")
\r
107 - (when notmuch-hello-recent-searches
\r
108 + (when notmuch-query-history
\r
109 (widget-insert "\nRecent searches: ")
\r
110 (widget-create 'push-button
\r
111 :notify (lambda (&rest ignore)
\r
112 - (setq notmuch-hello-recent-searches nil)
\r
113 + (setq notmuch-query-history nil)
\r
114 (notmuch-hello-update))
\r
116 (widget-insert "\n\n")
\r
117 - (let ((start (point))
\r
119 - (mapc (lambda (search)
\r
120 - (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))
\r
121 + (let ((start (point)))
\r
122 + (loop for i from 1 to notmuch-hello-recent-searches-max
\r
123 + for search in notmuch-query-history do
\r
124 + (let ((widget-symbol (intern (format "notmuch-hello-search-%d" i))))
\r
126 (widget-create 'editable-field
\r
127 ;; Don't let the search boxes be
\r
128 @@ -550,9 +547,7 @@ Complete list of currently available key bindings:
\r
129 (notmuch-hello-add-saved-search widget))
\r
130 :notmuch-saved-search-widget widget-symbol
\r
132 - (widget-insert "\n")
\r
133 - (setq nth (1+ nth)))
\r
134 - notmuch-hello-recent-searches)
\r
135 + (widget-insert "\n"))
\r
136 (indent-rigidly start (point) notmuch-hello-indent)))
\r
138 (when alltags-alist
\r
139 @@ -581,7 +576,7 @@ Complete list of currently available key bindings:
\r
140 (let ((start (point)))
\r
141 (widget-insert "\n\n")
\r
142 (widget-insert "Type a search query and hit RET to view matching threads.\n")
\r
143 - (when notmuch-hello-recent-searches
\r
144 + (when notmuch-query-history
\r
145 (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")
\r
146 (widget-insert "Save recent searches with the `save' button.\n"))
\r
147 (when notmuch-saved-searches
\r
148 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
149 index 270f983..546f306 100644
\r
150 --- a/emacs/notmuch.el
\r
151 +++ b/emacs/notmuch.el
\r
152 @@ -72,9 +72,6 @@ For example:
\r
153 :type '(alist :key-type (string) :value-type (string))
\r
156 -(defvar notmuch-query-history nil
\r
157 - "Variable to store minibuffer history for notmuch queries")
\r
159 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
161 (with-output-to-string
\r
162 @@ -902,8 +899,9 @@ PROMPT is the string to prompt with."
\r
163 (t (list string)))))))
\r
164 ;; this was simpler than convincing completing-read to accept spaces:
\r
165 (define-key keymap (kbd "<tab>") 'minibuffer-complete)
\r
166 - (read-from-minibuffer prompt nil keymap nil
\r
167 - 'notmuch-query-history nil nil))))
\r
168 + (let ((history-delete-duplicates t))
\r
169 + (read-from-minibuffer prompt nil keymap nil
\r
170 + 'notmuch-query-history nil nil)))))
\r
173 (defun notmuch-search (query &optional oldest-first target-thread target-line continuation)
\r