Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 76 / c45a6b5508a2a36012827e0b2efabf5f86177c
1 Return-Path: <scholler@fnb.tu-darmstadt.de>\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 arlo.cworth.org (Postfix) with ESMTP id 53B156DE1B96\r
6  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 15:02:37 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.009\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.009 tagged_above=-999 required=5 tests=[AWL=-0.001,\r
12   T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id j8vPUvJ_NQpO for <notmuch@notmuchmail.org>;\r
16  Thu,  3 Sep 2015 15:02:34 -0700 (PDT)\r
17 X-Greylist: delayed 441 seconds by postgrey-1.35 at arlo;\r
18  Thu, 03 Sep 2015 15:02:34 PDT\r
19 Received: from idun.ftbfs.de (idun.ftbfs.de [78.47.2.106])\r
20  by arlo.cworth.org (Postfix) with ESMTP id 7C5576DE1B92\r
21  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 15:02:34 -0700 (PDT)\r
22 Received: from localhost (localidun [10.0.0.76])\r
23  by idun.ftbfs.de (Postfix) with ESMTP id 7FABCEC390\r
24  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 23:55:09 +0200 (CEST)\r
25 Received: from localhost ([10.0.0.76])\r
26  by localhost (idun.ftbfs.de [10.0.0.76]) (amavisd-new, port 2525)\r
27  with SMTP id 06987-29 for <notmuch@notmuchmail.org>;\r
28  Thu, 3 Sep 2015 23:55:09 +0200 (CEST)\r
29 Received: from saga.ftbfs.de (unknown [10.0.0.77])\r
30  by idun.ftbfs.de (Postfix) with ESMTP id 19D3FEC38A\r
31  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 23:55:08 +0200 (CEST)\r
32 Received: by saga.ftbfs.de (Postfix, from userid 10)\r
33  id AC88B5C8AD; Thu,  3 Sep 2015 23:55:08 +0200 (CEST)\r
34 Received: by tardis.scholler.priv (Postfix, from userid 1000)\r
35  id EE92B104; Thu,  3 Sep 2015 23:54:43 +0200 (CEST)\r
36 From: Uli Scholler <uli@scholler.net>\r
37 To: notmuch@notmuchmail.org\r
38 Subject: [PATCH v2] emacs: wrap current search in parens when filtering\r
39 In-Reply-To: <m2zj142c0q.fsf@guru.guru-group.fi>\r
40 References: <1441231034-9413-1-git-send-email-uli@scholler.net>\r
41  <m2zj142c0q.fsf@guru.guru-group.fi>\r
42 User-Agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1\r
43  (x86_64-pc-linux-gnu)\r
44 Date: Thu, 03 Sep 2015 23:54:43 +0200\r
45 Message-ID: <87io7rxj6k.fsf@tardis.scholler.priv>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain\r
48 X-Virus-Scanned: at idun.ftbfs.de with p-bank undefined\r
49 X-Mailman-Approved-At: Thu, 03 Sep 2015 22:38:13 -0700\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.18\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: Thu, 03 Sep 2015 22:02:37 -0000\r
63 \r
64 Tomi Ollila <tomi.ollila@iki.fi> writes:\r
65 > But should this do the same "notmuch-search-disjunctive-regexp" check \r
66 > which is done when building up `grouped-query' ?\r
67 \r
68 Here is an improved version of my patch:\r
69 ---\r
70 \r
71 When filtering the current search further with notmuch-search-filter,\r
72 wrap the current search in parens if necessary.\r
73 \r
74 This fixes unexpected behavior when the current search is\r
75 complex (like "(tag:this and date:one_week_ago..) or tag:that").\r
76 ---\r
77  emacs/notmuch.el | 18 +++++++++++++-----\r
78  1 file changed, 13 insertions(+), 5 deletions(-)\r
79 \r
80 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
81 index 5284e77..e5e677f 100644\r
82 --- a/emacs/notmuch.el\r
83 +++ b/emacs/notmuch.el\r
84 @@ -978,18 +978,26 @@ default sort order is defined by `notmuch-search-oldest-first'."\r
85    (set 'notmuch-search-oldest-first (not notmuch-search-oldest-first))\r
86    (notmuch-search-refresh-view))\r
87  \r
88 +(defun notmuch-maybe-group-query-string (query-string)\r
89 +  "Group query if it contains a complex expression.\r
90 +\r
91 +Enclose QUERY-STRING in parentheses if it matches\r
92 +`notmuch-search-disjunctive-regexp'."\r
93 +  (if (string-match-p notmuch-search-disjunctive-regexp query-string)\r
94 +      (concat "( " query-string " )")\r
95 +    query-string))\r
96 +\r
97  (defun notmuch-search-filter (query)\r
98    "Filter the current search results based on an additional query string.\r
99  \r
100  Runs a new search matching only messages that match both the\r
101  current search results AND the additional query string provided."\r
102    (interactive (list (notmuch-read-query "Filter search: ")))\r
103 -  (let ((grouped-query (if (string-match-p notmuch-search-disjunctive-regexp query)\r
104 -                          (concat "( " query " )")\r
105 -                        query)))\r
106 -    (notmuch-search (if (string= notmuch-search-query-string "*")\r
107 +  (let ((grouped-query (notmuch-maybe-group-query-string query))\r
108 +       (grouped-search-query (notmuch-maybe-group-query-string notmuch-search-query-string)))\r
109 +    (notmuch-search (if (string= grouped-search-query "*")\r
110                         grouped-query\r
111 -                     (concat notmuch-search-query-string " and " grouped-query)) notmuch-search-oldest-first)))\r
112 +                     (concat grouped-search-query " and " grouped-query)) notmuch-search-oldest-first)))\r
113  \r
114  (defun notmuch-search-filter-by-tag (tag)\r
115    "Filter the current search results based on a single tag.\r
116 -- \r
117 2.1.4\r
118 \r
119 \r