Re: Flat search and threaded views
[notmuch-archives.git] / 38 / 9109bf5c7e006f071278e56c56b8ce5c383305
1 Return-Path: <amdragon@mit.edu>\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 6A9BE431FB6\r
6         for <notmuch@notmuchmail.org>; Mon,  5 Aug 2013 12:00:03 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id zt7tlyITOaMD for <notmuch@notmuchmail.org>;\r
16         Mon,  5 Aug 2013 11:59:57 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu\r
18         [18.7.68.34])\r
19         by olra.theworths.org (Postfix) with ESMTP id EF31C431FAE\r
20         for <notmuch@notmuchmail.org>; Mon,  5 Aug 2013 11:59:56 -0700 (PDT)\r
21 X-AuditID: 12074422-b7ef78e000000935-5a-51fff62a96fd\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 16.8C.02357.A26FFF15; Mon,  5 Aug 2013 14:59:54 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r75IxrMW006141; \r
27         Mon, 5 Aug 2013 14:59:54 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r75Ixosb022754\r
32         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
33         Mon, 5 Aug 2013 14:59:52 -0400\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1V6Q0S-0003q6-Sa; Mon, 05 Aug 2013 14:59:49 -0400\r
37 Date: Mon, 5 Aug 2013 14:59:47 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>\r
40 Subject: Re: unread message appear `folded'\r
41 Message-ID: <20130805185947.GD7794@mit.edu>\r
42 References:\r
43  <m2iozkf26n.fsf@ramakrmu-mac.i-did-not-set--mail-host-address--so-tickle-me>\r
44         <m2fvuof1yj.fsf@ramakrmu-mac.i-did-not-set--mail-host-address--so-tickle-me>\r
45 MIME-Version: 1.0\r
46 Content-Type: text/plain; charset=us-ascii\r
47 Content-Disposition: inline\r
48 In-Reply-To:\r
49  <m2fvuof1yj.fsf@ramakrmu-mac.i-did-not-set--mail-host-address--so-tickle-me>\r
50 User-Agent: Mutt/1.5.21 (2010-09-15)\r
51 X-Brightmail-Tracker:\r
52  H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42IRYrdT19X69j/QYHqrhcX1mzOZLdZ+TXJg\r
53         8ni26hazx6I96QFMUVw2Kak5mWWpRfp2CVwZTU1TmQoeSlW8nLWDqYGxXbSLkZNDQsBE4tmE\r
54         G4wQtpjEhXvr2UBsIYF9jBJfzvt2MXIB2RsYJV7f388G4Zxikrja8JYFwlnCKPF/8z0gh4OD\r
55         RUBF4m+XMEg3m4CGxLb9y8GmiggYSVxrucIKYjMLSEt8+93MBGILC2hLXGpeAFbDC2SfW3Gc\r
56         CWLmckaJeRtWMEMkBCVOznzCAtGsJXHj30smkF0gg5b/4wAJcwpESkzf9x2sXBTohCknt7FN\r
57         YBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuma6uVmluilppRuYgSHtIvS\r
58         DsafB5UOMQpwMCrx8CZc/R8oxJpYVlyZe4hRkoNJSZR3/xegEF9SfkplRmJxRnxRaU5q8SFG\r
59         CQ5mJRHe+VuAcrwpiZVVqUX5MClpDhYlcd5nT88GCgmkJ5akZqemFqQWwWRlODiUJHh5vwI1\r
60         ChalpqdWpGXmlCCkmTg4QYbzAA1nBanhLS5IzC3OTIfIn2JUlBLn/QtykQBIIqM0D64XlnJe\r
61         MYoDvSLM+xmkigeYruC6XwENZgIabPLzL8jgkkSElFQDo++CUMGY029+bWZPYb44M+XaqxRb\r
62         9V0FzXu+n8p0/pTtxd5RujtmabnyhX8HWe5u/z4t80DGv48VczT4le/1cnTs0/5+ninAhOVv\r
63         ePWP8P3KfX8vqBmU7/qx8pxqt/lExdwcnSB17jt3Nv12jfdPDtIomrVw6nk982Vn5h+fub9O\r
64         7tUGvouqS5VYijMSDbWYi4oTAbViH3IUAwAA\r
65 Cc: notmuch@notmuchmail.org\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.13\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70         <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
72         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
77         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Mon, 05 Aug 2013 19:00:03 -0000\r
79 \r
80 Quoth Ramakrishnan Muthukrishnan on Aug 05 at 11:35 pm:\r
81 > Ramakrishnan Muthukrishnan <ram@rkrishnan.org> writes:\r
82\r
83 > > Hi,\r
84 > >\r
85 > > Pardon me for using non-standard terms here because of lack of knowledge\r
86 > > of the language used in the email world.\r
87 > >\r
88 > > I have this thread in which some messages are tagged unread. When the\r
89 > > thread is opened, I see that those unread messages are not shown in full\r
90 > > in the threaded view. Instead they appear `folded' with only the summary\r
91 > > appearing in the thread, as if they are read. \r
92 > >\r
93 > > Here is a screenshot: http://i.imgur.com/Eh8SKe6.png\r
94 > >\r
95 > > I am attaching the messages in the thread shown in the screenshot as a\r
96 > > tar.bz2 file.\r
97\r
98 > I just forgot to mention that I see this only when I do a\r
99 > notmuch-search with `*' and not when I search with a tag. \r
100 \r
101 '*' turns out to be the key.  When showing a thread,\r
102 notmuch-show-build-buffer constructs a new query from the thread ID\r
103 and the original search query of the form\r
104 \r
105   thread:X and (original query)\r
106 \r
107 If the original query is '*', this is\r
108 \r
109   thread:X and (*)\r
110 \r
111 But * isn't part of the Xapian query syntax.  Notmuch specially\r
112 handles queries that exactly match "*" before passing the query to\r
113 Xapian.  When * is embedded in a larger query, this special casing\r
114 doesn't apply.  In fact, Xapian parses this query as\r
115 \r
116   (Tmail AND (and:(pos=1) FILTER GX))\r
117 \r
118 The "and" in the query turned into a plain search term (the "AND" is a\r
119 proper boolean operator, but is unrelated to the provided query).\r
120 \r
121 This is a symptom of a general problem where we assume queries are\r
122 textually composable, when they are not.  We have the same problem at\r
123 least in notmuch-search-filter and in notmuch tag query optimization.\r
124 In this particular case, the * causes Xapian's query grammar to fail\r
125 to parse the query, which Xapian handles by re-parsing the entire\r
126 query will all query features disabled (which includes disabling\r
127 support for boolean operators).  Unfortunately, just handling * better\r
128 isn't really a solution because it's just one of many things that\r
129 violates query composability.\r
130 \r
131 Some solutions I can see are:\r
132 \r
133 1) Switch to a composable query syntax (which would include *).  This,\r
134    obviously, requires a custom query parser, but is the most\r
135    localized change I can think of and keeps queries as strings.\r
136 \r
137 2) Never construct queries by pasting strings together.  This would\r
138    require changes to both the libnotmuch and CLI interfaces and\r
139    queries could no longer be strings, but in the words of Alan\r
140    Perlis, the string is a stark data structure.  (In the case of\r
141    show, I would actually love it if we could specify separate search\r
142    and match queries because that would eliminate --entire-thread as\r
143    well as the fallback in notmuch-show-build-buffer when search\r
144    returns nothing, but I digress.)\r
145 \r
146 3) Keep queries as plain strings, but switch to some hybrid syntax\r
147    that lets us combine Xapian queries with composable operators\r
148    parsed by notmuch.  When we need to combine queries, do it using\r
149    the composable operators.  This actually may not be a bad way to\r
150    transition to a full custom query parser; I think it would be\r
151    relatively easy to take over parsing Xapian's boolean syntax, but\r
152    leave the "prob" parsing to Xapian.\r
153 \r
154 I lean towards 3 because it seems like the least disruptive and offers\r
155 a smooth transition to 1.\r