[PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 03 / d519bb4fe678bfd504a89bb510a7a131ff3252
1 Return-Path: <todd@electricoding.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 41068429E52\r
6         for <notmuch@notmuchmail.org>; Sat, 10 Jan 2015 06:38:37 -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: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 URu+DJ9Q8apK for <notmuch@notmuchmail.org>;\r
16         Sat, 10 Jan 2015 06:38:33 -0800 (PST)\r
17 Received: from s75.web-hosting.com (s75.web-hosting.com [198.187.31.9])\r
18         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 958D6429E54\r
21         for <notmuch@notmuchmail.org>; Sat, 10 Jan 2015 06:38:33 -0800 (PST)\r
22 Received: from user-69-73-37-128.knology.net ([69.73.37.128]:33524\r
23  helo=tz-lab)   by server75.web-hosting.com with esmtpsa\r
24         (UNKNOWN:DHE-RSA-AES128-SHA:128) (Exim 4.82)    (envelope-from\r
25  <todd@electricoding.com>)      id 1Y9xBQ-0046Hr-I9; Sat, 10 Jan 2015 09:38:32\r
26  -0500\r
27 From: Todd <todd@electricoding.com>\r
28 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
29 Subject: Re: [PATCH] Index Content-Type of attachments with a contenttype\r
30         prefix\r
31 In-Reply-To: <8761ce7s16.fsf@nikula.org>\r
32 References: <1420849787-4401-1-git-send-email-todd@electricoding.com>\r
33         <8761ce7s16.fsf@nikula.org>\r
34 User-Agent: Notmuch/0.19+17~gd8b219d (http://notmuchmail.org) Emacs/24.4.1\r
35         (x86_64-unknown-linux-gnu)\r
36 Date: Sat, 10 Jan 2015 08:38:09 -0600\r
37 Message-ID: <87fvbi8zvy.fsf@electricoding.com>\r
38 MIME-Version: 1.0\r
39 Content-Type: text/plain\r
40 X-AntiAbuse: This header was added to track abuse,\r
41         please include it with any abuse report\r
42 X-AntiAbuse: Primary Hostname - server75.web-hosting.com\r
43 X-AntiAbuse: Original Domain - notmuchmail.org\r
44 X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]\r
45 X-AntiAbuse: Sender Address Domain - electricoding.com\r
46 X-Get-Message-Sender-Via: server75.web-hosting.com: authenticated_id:\r
47         todd@electricoding.com\r
48 X-Source: \r
49 X-Source-Args: \r
50 X-Source-Dir: \r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sat, 10 Jan 2015 14:38:37 -0000\r
64 \r
65 \r
66 >>>>> "Jani" == Jani Nikula <jani@nikula.org> writes:\r
67 \r
68     Jani> On Sat, 10 Jan 2015, Todd <todd@electricoding.com> wrote:\r
69     >> I wanted to tag messages with calendar invitations, but couldn't as\r
70     >> the information wasn't indexed.\r
71     >> \r
72     >> This patch allows for queries for like:\r
73     >> \r
74     >> Find calendar invites\r
75     >> - contenttype:text/calendar or contenttype:applicaton/ics\r
76     >> \r
77     >> Find any image attachments\r
78     >> - contenttype:image\r
79     >> \r
80     >> Find all patches\r
81     >> - contenttype:text/x-patch\r
82     >> \r
83     >> \r
84     >> - Todd\r
85     >> \r
86     >> ---\r
87     >> NEWS                               |  6 ++++++\r
88     >> completion/notmuch-completion.bash |  2 +-\r
89     >> doc/man7/notmuch-search-terms.rst  |  6 ++++++\r
90     >> emacs/notmuch.el                   |  2 +-\r
91     >> lib/database.cc                    |  1 +\r
92     >> lib/index.cc                       |  5 +++++\r
93     >> test/T190-multipart.sh             | 32 ++++++++++++++++++++++++++++++++\r
94 \r
95     Jani> IMO these could be split into several patches.\r
96 \r
97     No problem, I'll split them up the next time I post.\r
98 \r
99     >> 7 files changed, 52 insertions(+), 2 deletions(-)\r
100     >> \r
101     >> diff --git a/NEWS b/NEWS\r
102     >> index 44e8d05..5f4622c 100644\r
103     >> --- a/NEWS\r
104     >> +++ b/NEWS\r
105     >> @@ -15,6 +15,12 @@ keyboard shortcuts to saved searches.\r
106     >> Command-Line Interface\r
107     >> ----------------------\r
108     >> \r
109     >> +There is a new `contenttype:` search prefix\r
110     >> +\r
111     >> +  The new `contenttype:` search prefix allows searching for the\r
112     >> +  content-type of attachments, which is now indexed by `notmuch\r
113     >> +  insert`. See the `notmuch-search-terms` manual page for details.\r
114     >> +\r
115 \r
116     Jani> Admittedly I did not have the time to dig into details, but I think\r
117     Jani> "attachment" is misleading, as it's really all mime parts, right?\r
118 \r
119     Jani> Will this also index the Content-Type: header of the message itself,\r
120     Jani> regardless of whether it has mime structure or not? Maybe it\r
121     Jani> should?\r
122 \r
123     Yes, all mime-parts. It does not index the Content-Type of the\r
124     message itself.  That probably wouldn't be difficult to add if it's\r
125     a desired feature, but if there are plans for indexing other message\r
126     headers it may fit better there.\r
127 \r
128     I also wasn't too happy with a "contenttype" keyword and debated\r
129     just indexing the information under "attachment" along with the\r
130     filename.\r
131 \r
132     >> Stopped `notmuch dump` failing if someone writes to the database\r
133     >> \r
134     >> The dump command now takes the write lock when running. This\r
135     >> diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash\r
136     >> index d58dc8b..05b5969 100644\r
137     >> --- a/completion/notmuch-completion.bash\r
138     >> +++ b/completion/notmuch-completion.bash\r
139     >> @@ -61,7 +61,7 @@ _notmuch_search_terms()\r
140     >> sed "s|^$path/||" | grep -v "\(^\|/\)\(cur\|new\|tmp\)$" ) )\r
141     >> ;;\r
142     >> *)\r
143     >> -            local search_terms="from: to: subject: attachment: tag: id: thread: folder: path: date:"\r
144     >> +            local search_terms="from: to: subject: attachment: contenttype: tag: id: thread: folder: path: date:"\r
145     >> compopt -o nospace\r
146     >> COMPREPLY=( $(compgen -W "${search_terms}" -- ${cur}) )\r
147     >> ;;\r
148     >> diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst\r
149     >> index 1acdaa0..d126ce6 100644\r
150     >> --- a/doc/man7/notmuch-search-terms.rst\r
151     >> +++ b/doc/man7/notmuch-search-terms.rst\r
152     >> @@ -40,6 +40,8 @@ indicate user-supplied values):\r
153     >> \r
154     >> -  attachment:<word>\r
155     >> \r
156     >> +-  contenttype:<word>\r
157     >> +\r
158     >> -  tag:<tag> (or is:<tag>)\r
159     >> \r
160     >> -  id:<message-id>\r
161     >> @@ -66,6 +68,10 @@ by including quotation marks around the phrase, immediately following\r
162     >> The **attachment:** prefix can be used to search for specific filenames\r
163     >> (or extensions) of attachments to email messages.\r
164     >> \r
165     >> +The **contenttype:** prefix can be used to search for specific\r
166     >> +content-types of attachments to email messages (as specified by the\r
167     >> +sender).\r
168     >> +\r
169     >> For **tag:** and **is:** valid tag values include **inbox** and\r
170     >> **unread** by default for new messages added by **notmuch new** as well\r
171     >> as any other tag values added manually with **notmuch tag**.\r
172     >> diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
173     >> index 218486a..702700c 100644\r
174     >> --- a/emacs/notmuch.el\r
175     >> +++ b/emacs/notmuch.el\r
176     >> @@ -858,7 +858,7 @@ PROMPT is the string to prompt with."\r
177     >> (lexical-let\r
178     >> ((completions\r
179     >> (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:"\r
180     >> -                      "subject:" "attachment:")\r
181     >> +                      "subject:" "attachment:" "contenttype:")\r
182     >> (mapcar (lambda (tag)\r
183     >> (concat "tag:" (notmuch-escape-boolean-term tag)))\r
184     >> (process-lines notmuch-command "search" "--output=tags" "*")))))\r
185     >> diff --git a/lib/database.cc b/lib/database.cc\r
186     >> index 3601f9d..a7a64c9 100644\r
187     >> --- a/lib/database.cc\r
188     >> +++ b/lib/database.cc\r
189     >> @@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= {\r
190     >> { "from",                        "XFROM" },\r
191     >> { "to",                  "XTO" },\r
192     >> { "attachment",          "XATTACHMENT" },\r
193     >> +    { "contenttype",            "XCONTENTTYPE"},\r
194     >> { "subject",             "XSUBJECT"},\r
195 \r
196     Jani> Is the use of probabilistic prefix intentional? I think it's probably\r
197     Jani> the right thing to do, but just checking.\r
198 \r
199     I'm not familiar with Xapian and just followed the precedence of\r
200     attachment.  \r
201 \r
202     Jani> BR,\r
203     Jani> Jani.\r
204 \r
205     - Todd\r