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 3394F431FBD
\r
6 for <notmuch@notmuchmail.org>; Fri, 9 Jan 2015 16:30:17 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 gVjugoKF6U32 for <notmuch@notmuchmail.org>;
\r
16 Fri, 9 Jan 2015 16:30:14 -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 EB3A5431FBC
\r
21 for <notmuch@notmuchmail.org>; Fri, 9 Jan 2015 16:30:13 -0800 (PST)
\r
22 Received: from user-69-73-37-128.knology.net ([69.73.37.128]:59809
\r
23 helo=localhost.localdomain)
\r
24 by server75.web-hosting.com with esmtpsa (UNKNOWN:AES128-SHA256:128)
\r
25 (Exim 4.82) (envelope-from <todd@electricoding.com>)
\r
26 id 1Y9jwS-000xx0-Re; Fri, 09 Jan 2015 19:30:13 -0500
\r
27 From: Todd <todd@electricoding.com>
\r
28 To: notmuch@notmuchmail.org
\r
29 Subject: [PATCH] Index Content-Type of attachments with a contenttype prefix
\r
30 Date: Fri, 9 Jan 2015 18:29:47 -0600
\r
31 Message-Id: <1420849787-4401-1-git-send-email-todd@electricoding.com>
\r
32 X-Mailer: git-send-email 1.9.1
\r
33 X-AntiAbuse: This header was added to track abuse,
\r
34 please include it with any abuse report
\r
35 X-AntiAbuse: Primary Hostname - server75.web-hosting.com
\r
36 X-AntiAbuse: Original Domain - notmuchmail.org
\r
37 X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
\r
38 X-AntiAbuse: Sender Address Domain - electricoding.com
\r
39 X-Get-Message-Sender-Via: server75.web-hosting.com: authenticated_id:
\r
40 todd@electricoding.com
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Sat, 10 Jan 2015 00:30:17 -0000
\r
58 I wanted to tag messages with calendar invitations, but couldn't as
\r
59 the information wasn't indexed.
\r
61 This patch allows for queries for like:
\r
63 Find calendar invites
\r
64 - contenttype:text/calendar or contenttype:applicaton/ics
\r
66 Find any image attachments
\r
70 - contenttype:text/x-patch
\r
77 completion/notmuch-completion.bash | 2 +-
\r
78 doc/man7/notmuch-search-terms.rst | 6 ++++++
\r
79 emacs/notmuch.el | 2 +-
\r
80 lib/database.cc | 1 +
\r
81 lib/index.cc | 5 +++++
\r
82 test/T190-multipart.sh | 32 ++++++++++++++++++++++++++++++++
\r
83 7 files changed, 52 insertions(+), 2 deletions(-)
\r
85 diff --git a/NEWS b/NEWS
\r
86 index 44e8d05..5f4622c 100644
\r
89 @@ -15,6 +15,12 @@ keyboard shortcuts to saved searches.
\r
90 Command-Line Interface
\r
91 ----------------------
\r
93 +There is a new `contenttype:` search prefix
\r
95 + The new `contenttype:` search prefix allows searching for the
\r
96 + content-type of attachments, which is now indexed by `notmuch
\r
97 + insert`. See the `notmuch-search-terms` manual page for details.
\r
99 Stopped `notmuch dump` failing if someone writes to the database
\r
101 The dump command now takes the write lock when running. This
\r
102 diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash
\r
103 index d58dc8b..05b5969 100644
\r
104 --- a/completion/notmuch-completion.bash
\r
105 +++ b/completion/notmuch-completion.bash
\r
106 @@ -61,7 +61,7 @@ _notmuch_search_terms()
\r
107 sed "s|^$path/||" | grep -v "\(^\|/\)\(cur\|new\|tmp\)$" ) )
\r
110 - local search_terms="from: to: subject: attachment: tag: id: thread: folder: path: date:"
\r
111 + local search_terms="from: to: subject: attachment: contenttype: tag: id: thread: folder: path: date:"
\r
113 COMPREPLY=( $(compgen -W "${search_terms}" -- ${cur}) )
\r
115 diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst
\r
116 index 1acdaa0..d126ce6 100644
\r
117 --- a/doc/man7/notmuch-search-terms.rst
\r
118 +++ b/doc/man7/notmuch-search-terms.rst
\r
119 @@ -40,6 +40,8 @@ indicate user-supplied values):
\r
121 - attachment:<word>
\r
123 +- contenttype:<word>
\r
125 - tag:<tag> (or is:<tag>)
\r
128 @@ -66,6 +68,10 @@ by including quotation marks around the phrase, immediately following
\r
129 The **attachment:** prefix can be used to search for specific filenames
\r
130 (or extensions) of attachments to email messages.
\r
132 +The **contenttype:** prefix can be used to search for specific
\r
133 +content-types of attachments to email messages (as specified by the
\r
136 For **tag:** and **is:** valid tag values include **inbox** and
\r
137 **unread** by default for new messages added by **notmuch new** as well
\r
138 as any other tag values added manually with **notmuch tag**.
\r
139 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
140 index 218486a..702700c 100644
\r
141 --- a/emacs/notmuch.el
\r
142 +++ b/emacs/notmuch.el
\r
143 @@ -858,7 +858,7 @@ PROMPT is the string to prompt with."
\r
146 (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:"
\r
147 - "subject:" "attachment:")
\r
148 + "subject:" "attachment:" "contenttype:")
\r
149 (mapcar (lambda (tag)
\r
150 (concat "tag:" (notmuch-escape-boolean-term tag)))
\r
151 (process-lines notmuch-command "search" "--output=tags" "*")))))
\r
152 diff --git a/lib/database.cc b/lib/database.cc
\r
153 index 3601f9d..a7a64c9 100644
\r
154 --- a/lib/database.cc
\r
155 +++ b/lib/database.cc
\r
156 @@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= {
\r
157 { "from", "XFROM" },
\r
159 { "attachment", "XATTACHMENT" },
\r
160 + { "contenttype", "XCONTENTTYPE"},
\r
161 { "subject", "XSUBJECT"},
\r
164 diff --git a/lib/index.cc b/lib/index.cc
\r
165 index 1a2e63d..c3f7c6b 100644
\r
168 @@ -346,6 +346,11 @@ _index_mime_part (notmuch_message_t *message,
\r
172 + GMimeContentType* content_type = g_mime_object_get_content_type(part);
\r
173 + if (content_type) {
\r
174 + _notmuch_message_gen_terms (message, "contenttype", g_mime_content_type_to_string(content_type));
\r
177 if (GMIME_IS_MESSAGE_PART (part)) {
\r
178 GMimeMessage *mime_message;
\r
180 diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
\r
181 index 85cbf67..e3270a7 100755
\r
182 --- a/test/T190-multipart.sh
\r
183 +++ b/test/T190-multipart.sh
\r
184 @@ -104,6 +104,30 @@ Content-Transfer-Encoding: base64
\r
189 +cat <<EOF > content_types
\r
190 +From: Todd <todd@electricoding.com>
\r
191 +To: todd@electricoding.com
\r
192 +Subject: odd content types
\r
193 +Date: Fri, 05 Jan 2001 15:42:57 +0000
\r
194 +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
\r
195 +Message-ID: <87liy5ap01.fsf@yoom.home.cworth.org>
\r
197 +Content-Type: multipart/alternative; boundary="==-=-=="
\r
200 +Content-Type: application/unique_identifier
\r
202 +<p>This is an embedded message, with a multipart/alternative part.</p>
\r
205 +Content-Type: text/some_other_identifier
\r
207 +This is an embedded message, with a multipart/alternative part.
\r
211 +cat content_types >> ${MAIL_DIR}/odd_content_type
\r
212 notmuch new > /dev/null
\r
214 test_begin_subtest "--format=text --part=0, full message"
\r
215 @@ -727,4 +751,12 @@ test_begin_subtest "html parts included"
\r
216 notmuch show --format=json --include-html id:htmlmessage > OUTPUT
\r
217 test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)"
\r
219 +test_begin_subtest "indexes content-type"
\r
220 +output=$(notmuch search contenttype:application/unique_identifier | notmuch_search_sanitize)
\r
221 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Todd; odd content types (inbox unread)"
\r
223 +output=$(notmuch search contenttype:text/some_other_identifier | notmuch_search_sanitize)
\r
224 +test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Todd; odd content types (inbox unread)"
\r