Re: [PATCH v4 13/16] add indexopts to notmuch python bindings.
[notmuch-archives.git] / da / 33ffb9e940960a6a3e43e03cc164e10bd71850
1 Return-Path: <markwalters1009@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 04552431FAF\r
6         for <notmuch@notmuchmail.org>; Mon, 23 Jun 2014 14:07:02 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id k4pWurzcqH0e for <notmuch@notmuchmail.org>;\r
18         Mon, 23 Jun 2014 14:06:56 -0700 (PDT)\r
19 Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com\r
20  [74.125.82.41])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  5320B431FAE    for <notmuch@notmuchmail.org>; Mon, 23 Jun 2014 14:06:56 -0700\r
23  (PDT)\r
24 Received: by mail-wg0-f41.google.com with SMTP id a1so6937775wgh.0\r
25         for <notmuch@notmuchmail.org>; Mon, 23 Jun 2014 14:06:54 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=BpqOnTUMRM3NxllU/+RHRQrpszvTI4c4dlyDHevdj+Y=;\r
29         b=Gd2Oja41g7dfWwRH2dBFYdA+gyamX8mMMNmW6Nu+uGnUR//84aG7SMBayb2ie6XI18\r
30         PEL3th/bEYxGksGD281uAM6ifvr0VMzePFNZn0T2wV/+WLkZn6xPRfkVwENENuLBMZVk\r
31         EIUB2WadbWd1JcxTl5mRgMPftQMCG47iJ345youcWM6OSwO5Cm3zDZRv8UpPgqS3quuf\r
32         sLtDfBFFBOq1DhGJSm1F01EhG3N3u131NJCjalktQXBQkznyUGABTcCvPx2HrHDq7TGx\r
33         TiWXTY0qiV+foVgZvrP3GUnmX+o9yBuNsisj8EMK8zmtTjnHMh+IAF3D5hgeL5qw6lM0\r
34         GU6A==\r
35 X-Received: by 10.180.198.226 with SMTP id jf2mr28730479wic.35.1403557613784; \r
36         Mon, 23 Jun 2014 14:06:53 -0700 (PDT)\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
38         by mx.google.com with ESMTPSA id\r
39         hb8sm28389256wib.12.2014.06.23.14.06.52 for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Mon, 23 Jun 2014 14:06:53 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH v2] emacs: set default in notmuch-read-query\r
45 Date: Mon, 23 Jun 2014 22:06:46 +0100\r
46 Message-Id: <1403557606-13397-1-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.10.4\r
48 In-Reply-To: <874n134bbi.fsf@qmul.ac.uk>\r
49 References: <874n134bbi.fsf@qmul.ac.uk>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Mon, 23 Jun 2014 21:07:02 -0000\r
63 \r
64 This adds the current query as a "default value" to\r
65 notmuch-read-qeury. The default value is available via a down-arrow as\r
66 opposed to history which is available from the up arrow.\r
67 \r
68 Note if a user presses return in the minibuffer this value is not\r
69 returned.\r
70 \r
71 The implementation is simple but notmuch-read-query could be called\r
72 via notmuch-search/notmuch-tree etc from any buffer so it makes sense\r
73 to put the decision of how to extract the current query in\r
74 notmuch-read-query rather than in each of the callers.\r
75 ---\r
76 \r
77 v2 keeps the logic for extracting a query in the relevant file\r
78 (show/tree etc) so notmuch-read-query just needs to choose which one\r
79 to call.\r
80 \r
81 Best wishes\r
82 \r
83 Mark\r
84 \r
85 \r
86 \r
87  emacs/notmuch-show.el |    9 +++++++++\r
88  emacs/notmuch-tree.el |    9 +++++++++\r
89  emacs/notmuch.el      |   10 +++++++++-\r
90  3 files changed, 27 insertions(+), 1 deletion(-)\r
91 \r
92 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
93 index df10d4b..313952f 100644\r
94 --- a/emacs/notmuch-show.el\r
95 +++ b/emacs/notmuch-show.el\r
96 @@ -1186,6 +1186,15 @@ (defun notmuch-show-capture-state ()\r
97   - the current message."\r
98    (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages)))\r
99  \r
100 +(defun notmuch-show-get-query ()\r
101 +  "Return the current query in this show buffer"\r
102 +  (if notmuch-show-query-context\r
103 +      (concat notmuch-show-thread-id\r
104 +             " and ("\r
105 +             notmuch-show-query-context\r
106 +             ")")\r
107 +    notmuch-show-thread-id))\r
108 +\r
109  (defun notmuch-show-apply-state (state)\r
110    "Apply STATE to the current buffer.\r
111  \r
112 diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el\r
113 index 7d5f475..e9249da 100644\r
114 --- a/emacs/notmuch-tree.el\r
115 +++ b/emacs/notmuch-tree.el\r
116 @@ -897,6 +897,15 @@ (defun notmuch-tree-worker (basic-query &optional query-context target open-targ\r
117        (set-process-filter proc 'notmuch-tree-process-filter)\r
118        (set-process-query-on-exit-flag proc nil))))\r
119  \r
120 +(defun notmuch-tree-get-query ()\r
121 +  "Return the current query in this tree buffer"\r
122 +  (if notmuch-tree-query-context\r
123 +      (concat notmuch-tree-basic-query\r
124 +             " and ("\r
125 +             notmuch-tree-query-context\r
126 +             ")")\r
127 +    notmuch-tree-basic-query))\r
128 +\r
129  (defun notmuch-tree (&optional query query-context target buffer-name open-target)\r
130    "Display threads matching QUERY in Tree View.\r
131  \r
132 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
133 index 6c0bc1b..5339a64 100644\r
134 --- a/emacs/notmuch.el\r
135 +++ b/emacs/notmuch.el\r
136 @@ -860,6 +860,10 @@ (defun notmuch-read-query (prompt)\r
137                           (concat "tag:" (notmuch-escape-boolean-term tag)))\r
138                         (process-lines notmuch-command "search" "--output=tags" "*")))))\r
139      (let ((keymap (copy-keymap minibuffer-local-map))\r
140 +         (current-query (case major-mode\r
141 +                          (notmuch-search-mode (notmuch-search-get-query))\r
142 +                          (notmuch-show-mode (notmuch-show-get-query))\r
143 +                          (notmuch-tree-mode (notmuch-tree-get-query))))\r
144           (minibuffer-completion-table\r
145            (completion-table-dynamic\r
146             (lambda (string)\r
147 @@ -877,7 +881,11 @@ (defun notmuch-read-query (prompt)\r
148        (define-key keymap (kbd "TAB") 'minibuffer-complete)\r
149        (let ((history-delete-duplicates t))\r
150         (read-from-minibuffer prompt nil keymap nil\r
151 -                             'notmuch-search-history nil nil)))))\r
152 +                             'notmuch-search-history current-query nil)))))\r
153 +\r
154 +(defun notmuch-search-get-query ()\r
155 +  "Return the current query in this search buffer"\r
156 +  notmuch-search-query-string)\r
157  \r
158  ;;;###autoload\r
159  (put 'notmuch-search 'notmuch-doc "Search for messages.")\r
160 -- \r
161 1.7.10.4\r
162 \r