Re: [PATCH] VIM: Make an option to save sent mail locally
Great work! Yeah, I can add it so the folder can be changed. I figured this was just the start of things. Really we should be able to fcc it to our upstream provider sent mailbox too. I would appreciate an option to configure the sent box per provider. I implemented this feature in this patch: id:1420891384-992-4-git-send-email-telenc...@unic.cnrs-gif.fr The way it works is that it reads a mapping between the email-addresses and sent dirs from .notmuch-config. Then it parses the from header of the sent message and notmuch inserts the message into the directory associated with the from address. It is not a fully polished patch. Perhaps we could merge the two to get something more final. Bartosz ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
RE: [PATCH v3] VIM: Improve moving between messages in a thread
Hi Ian, The patch looks good. I tested it on my system and it works fine. I just have one suggestion regarding coding style. +function! s:show_prev_msg() function! s:show_next_msg() Since these functions are almost the same, you could avoid code repetition by replacing them by a function which takes (positive or negative) increment as an argument. Cheers, Bartosz ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 1/5] Add a failing unit test for indexed mime types
--- test/T190-multipart.sh | 32 1 file changed, 32 insertions(+) diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh index 85cbf67..26f7c7a 100755 --- a/test/T190-multipart.sh +++ b/test/T190-multipart.sh @@ -104,6 +104,30 @@ Content-Transfer-Encoding: base64 7w0K --==-=-=-- EOF + +cat EOF content_types +From: Todd t...@example.com +To: t...@example.com +Subject: odd content types +Date: Mon, 12 Jan 2014 18:12:32 + +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) +Message-ID: kfjfo2wjbw2hrv2p0...@example.com +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary===-=-== + +--==-=-== +Content-Type: application/unique_identifier + +pThis is an embedded message, with a multipart/alternative part./p + +--==-=-== +Content-Type: text/some_other_identifier + +This is an embedded message, with a multipart/alternative part. + +--==-=-==-- +EOF +cat content_types ${MAIL_DIR}/odd_content_type notmuch new /dev/null test_begin_subtest --format=text --part=0, full message @@ -727,4 +751,12 @@ test_begin_subtest html parts included notmuch show --format=json --include-html id:htmlmessage OUTPUT test_expect_equal_json $(cat OUTPUT) $(cat EXPECTED.withhtml) +test_begin_subtest indexes mime-type +output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize) +test_expect_equal $output thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread) + +output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize) +test_expect_equal $output thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread) + + test_done -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 0/5] Index the content-type of MIME parts
This set of patches allows for queries for like: Find calendar invites - mimetype:text/calendar or mimetype:application/ics Find any image attachments - mimetype:image Find all patches - mimetype:text/x-patch It is a rework of a previous set of patches that now adds a new database feature, only available in newly created databases, which indicates that all of the mime parts are indexed. Indexing of new messages on an existing database should work fine as well, but the feature won't be enabled via upgrade. Code reviews welcome, I'm not familiar with this code base. Todd (5): Add a failing unit test for indexed mime types Add the NOTMUCH_FEATURE_INDEXED_MIMETYPES database feature Add indexing for the mimetype term Update completions for Emacs and bash Update documentation NEWS | 16 completion/notmuch-completion.bash | 2 +- doc/man7/notmuch-search-terms.rst | 6 ++ emacs/notmuch.el | 2 +- lib/database-private.h | 15 --- lib/database.cc| 11 +-- lib/index.cc | 6 ++ test/T190-multipart.sh | 32 8 files changed, 83 insertions(+), 7 deletions(-) -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 3/5] Add indexing for the mimetype term
--- lib/database.cc | 1 + lib/index.cc| 6 ++ 2 files changed, 7 insertions(+) diff --git a/lib/database.cc b/lib/database.cc index 2de60f8..7c7a267 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= { { from, XFROM }, { to,XTO }, { attachment,XATTACHMENT }, +{ mimetype, XMIMETYPE}, { subject, XSUBJECT}, }; diff --git a/lib/index.cc b/lib/index.cc index 1a2e63d..2e27558 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -318,6 +318,12 @@ _index_mime_part (notmuch_message_t *message, return; } + +GMimeContentType* content_type = g_mime_object_get_content_type(part); +if (content_type) { + _notmuch_message_gen_terms (message, mimetype, g_mime_content_type_to_string(content_type)); +} + if (GMIME_IS_MULTIPART (part)) { GMimeMultipart *multipart = GMIME_MULTIPART (part); int i; -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 5/5] Update documentation
--- NEWS | 16 doc/man7/notmuch-search-terms.rst | 6 ++ 2 files changed, 22 insertions(+) diff --git a/NEWS b/NEWS index 44e8d05..0df7977 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,19 @@ +Notmuch 0.20 (TBD) += + +Overview + + +Command-Line Interface +-- + +There is a new `mimetype:` search prefix + + The new `mimetype:` search prefix allows searching for the + content-type of attachments, which is now indexed by `notmuch + insert`. See the `notmuch-search-terms` manual page for details. + + Notmuch 0.19 (2014-11-14) = diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst index 1acdaa0..8d1acfc 100644 --- a/doc/man7/notmuch-search-terms.rst +++ b/doc/man7/notmuch-search-terms.rst @@ -40,6 +40,8 @@ indicate user-supplied values): - attachment:word +- mimetype:word + - tag:tag (or is:tag) - id:message-id @@ -66,6 +68,10 @@ by including quotation marks around the phrase, immediately following The **attachment:** prefix can be used to search for specific filenames (or extensions) of attachments to email messages. +The **mimetype:** prefix can be used to search for the specific +content-types of mime parts within email messages (as specified by the +sender). + For **tag:** and **is:** valid tag values include **inbox** and **unread** by default for new messages added by **notmuch new** as well as any other tag values added manually with **notmuch tag**. -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 2/5] Add the NOTMUCH_FEATURE_INDEXED_MIMETYPES database feature
--- lib/database-private.h | 15 --- lib/database.cc| 10 -- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 15e03cc..6d6fa2c 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -92,6 +92,14 @@ enum _notmuch_features { * * Introduced: version 3. */ NOTMUCH_FEATURE_GHOSTS = 1 4, + + +/* If set, then the database was created after the introduction of + * indexed mime types. If unset, then the database may contain a + * mixture of messages with indexed and non-indexed mime types. + * + * Introduced: version 3. */ +NOTMUCH_FEATURE_INDEXED_MIMETYPES = 1 5, }; /* In C++, a named enum is its own type, so define bitwise operators @@ -161,9 +169,10 @@ struct _notmuch_database { /* Current database features. If any of these are missing from a * database, request an upgrade. - * NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES is not included because - * upgrade doesn't currently introduce the feature (though brand new - * databases will have it). */ + * NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES and + * NOTMUCH_FEATURE_INDEXED_MIMETYPES are not included because upgrade + * doesn't currently introduce the features (though brand new databases + * will have it). */ #define NOTMUCH_FEATURES_CURRENT \ (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_DIRECTORY_DOCS | \ NOTMUCH_FEATURE_BOOL_FOLDER | NOTMUCH_FEATURE_GHOSTS) diff --git a/lib/database.cc b/lib/database.cc index 3601f9d..2de60f8 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -304,6 +304,11 @@ static const struct { exact folder:/path: search, rw }, { NOTMUCH_FEATURE_GHOSTS, mail documents for missing messages, w}, +/* Knowledge of the index mime-types are not required for reading + * a database because a reader will just be unable to query + * them. */ +{ NOTMUCH_FEATURE_INDEXED_MIMETYPES, + mime-types in database, w}, }; const char * @@ -646,9 +651,10 @@ notmuch_database_create (const char *path, notmuch_database_t **database) if (status) goto DONE; -/* Upgrade doesn't add this feature to existing databases, but new - * databases have it. */ +/* Upgrade doesn't add these feature to existing databases, but + * new databases have them. */ notmuch-features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES; +notmuch-features |= NOTMUCH_FEATURE_INDEXED_MIMETYPES; status = notmuch_database_upgrade (notmuch, NULL, NULL); if (status) { -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 4/5] Update completions for Emacs and bash
This adds completions for Emacs and bash, ZSH does not appear to have completions for search terms. --- completion/notmuch-completion.bash | 2 +- emacs/notmuch.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index d58dc8b..05b5969 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -61,7 +61,7 @@ _notmuch_search_terms() sed s|^$path/|| | grep -v \(^\|/\)\(cur\|new\|tmp\)$ ) ) ;; *) - local search_terms=from: to: subject: attachment: tag: id: thread: folder: path: date: + local search_terms=from: to: subject: attachment: contenttype: tag: id: thread: folder: path: date: compopt -o nospace COMPREPLY=( $(compgen -W ${search_terms} -- ${cur}) ) ;; diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 218486a..ab00454 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -858,7 +858,7 @@ PROMPT is the string to prompt with. (lexical-let ((completions (append (list folder: path: thread: id: date: from: to: - subject: attachment:) + subject: attachment: mimetype:) (mapcar (lambda (tag) (concat tag: (notmuch-escape-boolean-term tag))) (process-lines notmuch-command search --output=tags *) -- 1.9.1 ___ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v3] VIM: Improve moving between messages in a thread
Hi Ian, The patch looks good. I tested it on my system and it works fine. I just have one suggestion regarding coding style. > +function! s:show_prev_msg() > function! s:show_next_msg() Since these functions are almost the same, you could avoid code repetition by replacing them by a function which takes (positive or negative) increment as an argument. Cheers, Bartosz
[PATCH] VIM: Make an option to save sent mail locally
Great work! > Yeah, I can add it so the folder can be changed. I figured this was just the > start of things. Really we should be able to fcc it to our upstream provider > sent mailbox too. I would appreciate an option to configure the "sent" box per provider. I implemented this feature in this patch: id:1420891384-992-4-git-send-email-telenczuk at unic.cnrs-gif.fr The way it works is that it reads a mapping between the email-addresses and sent dirs from .notmuch-config. Then it parses the "from" header of the sent message and "notmuch inserts" the message into the directory associated with the "from" address. It is not a fully polished patch. Perhaps we could merge the two to get something more final. Bartosz
[PATCH v2 0/5] Index the content-type of MIME parts
This set of patches allows for queries for like: Find calendar invites - mimetype:text/calendar or mimetype:application/ics Find any image attachments - mimetype:image Find all patches - mimetype:text/x-patch It is a rework of a previous set of patches that now adds a new database feature, only available in newly created databases, which indicates that all of the mime parts are indexed. Indexing of new messages on an existing database should work fine as well, but the feature won't be enabled via upgrade. Code reviews welcome, I'm not familiar with this code base. Todd (5): Add a failing unit test for indexed mime types Add the NOTMUCH_FEATURE_INDEXED_MIMETYPES database feature Add indexing for the mimetype term Update completions for Emacs and bash Update documentation NEWS | 16 completion/notmuch-completion.bash | 2 +- doc/man7/notmuch-search-terms.rst | 6 ++ emacs/notmuch.el | 2 +- lib/database-private.h | 15 --- lib/database.cc| 11 +-- lib/index.cc | 6 ++ test/T190-multipart.sh | 32 8 files changed, 83 insertions(+), 7 deletions(-) -- 1.9.1
[PATCH v2 1/5] Add a failing unit test for indexed mime types
--- test/T190-multipart.sh | 32 1 file changed, 32 insertions(+) diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh index 85cbf67..26f7c7a 100755 --- a/test/T190-multipart.sh +++ b/test/T190-multipart.sh @@ -104,6 +104,30 @@ Content-Transfer-Encoding: base64 7w0K --==-=-=-- EOF + +cat < content_types +From: Todd +To: todd at example.com +Subject: odd content types +Date: Mon, 12 Jan 2014 18:12:32 + +User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu) +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="==-=-==" + +--==-=-== +Content-Type: application/unique_identifier + +This is an embedded message, with a multipart/alternative part. + +--==-=-== +Content-Type: text/some_other_identifier + +This is an embedded message, with a multipart/alternative part. + +--==-=-==-- +EOF +cat content_types >> ${MAIL_DIR}/odd_content_type notmuch new > /dev/null test_begin_subtest "--format=text --part=0, full message" @@ -727,4 +751,12 @@ test_begin_subtest "html parts included" notmuch show --format=json --include-html id:htmlmessage > OUTPUT test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)" +test_begin_subtest "indexes mime-type" +output=$(notmuch search mimetype:application/unique_identifier | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)" + +output=$(notmuch search mimetype:text/some_other_identifier | notmuch_search_sanitize) +test_expect_equal "$output" "thread:XXX 2014-01-12 [1/1] Todd; odd content types (inbox unread)" + + test_done -- 1.9.1
[PATCH v2 2/5] Add the NOTMUCH_FEATURE_INDEXED_MIMETYPES database feature
--- lib/database-private.h | 15 --- lib/database.cc| 10 -- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 15e03cc..6d6fa2c 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -92,6 +92,14 @@ enum _notmuch_features { * * Introduced: version 3. */ NOTMUCH_FEATURE_GHOSTS = 1 << 4, + + +/* If set, then the database was created after the introduction of + * indexed mime types. If unset, then the database may contain a + * mixture of messages with indexed and non-indexed mime types. + * + * Introduced: version 3. */ +NOTMUCH_FEATURE_INDEXED_MIMETYPES = 1 << 5, }; /* In C++, a named enum is its own type, so define bitwise operators @@ -161,9 +169,10 @@ struct _notmuch_database { /* Current database features. If any of these are missing from a * database, request an upgrade. - * NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES is not included because - * upgrade doesn't currently introduce the feature (though brand new - * databases will have it). */ + * NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES and + * NOTMUCH_FEATURE_INDEXED_MIMETYPES are not included because upgrade + * doesn't currently introduce the features (though brand new databases + * will have it). */ #define NOTMUCH_FEATURES_CURRENT \ (NOTMUCH_FEATURE_FILE_TERMS | NOTMUCH_FEATURE_DIRECTORY_DOCS | \ NOTMUCH_FEATURE_BOOL_FOLDER | NOTMUCH_FEATURE_GHOSTS) diff --git a/lib/database.cc b/lib/database.cc index 3601f9d..2de60f8 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -304,6 +304,11 @@ static const struct { "exact folder:/path: search", "rw" }, { NOTMUCH_FEATURE_GHOSTS, "mail documents for missing messages", "w"}, +/* Knowledge of the index mime-types are not required for reading + * a database because a reader will just be unable to query + * them. */ +{ NOTMUCH_FEATURE_INDEXED_MIMETYPES, + "mime-types in database", "w"}, }; const char * @@ -646,9 +651,10 @@ notmuch_database_create (const char *path, notmuch_database_t **database) if (status) goto DONE; -/* Upgrade doesn't add this feature to existing databases, but new - * databases have it. */ +/* Upgrade doesn't add these feature to existing databases, but + * new databases have them. */ notmuch->features |= NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES; +notmuch->features |= NOTMUCH_FEATURE_INDEXED_MIMETYPES; status = notmuch_database_upgrade (notmuch, NULL, NULL); if (status) { -- 1.9.1
[PATCH v2 4/5] Update completions for Emacs and bash
This adds completions for Emacs and bash, ZSH does not appear to have completions for search terms. --- completion/notmuch-completion.bash | 2 +- emacs/notmuch.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index d58dc8b..05b5969 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -61,7 +61,7 @@ _notmuch_search_terms() sed "s|^$path/||" | grep -v "\(^\|/\)\(cur\|new\|tmp\)$" ) ) ;; *) - local search_terms="from: to: subject: attachment: tag: id: thread: folder: path: date:" + local search_terms="from: to: subject: attachment: contenttype: tag: id: thread: folder: path: date:" compopt -o nospace COMPREPLY=( $(compgen -W "${search_terms}" -- ${cur}) ) ;; diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 218486a..ab00454 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -858,7 +858,7 @@ PROMPT is the string to prompt with." (lexical-let ((completions (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:" - "subject:" "attachment:") + "subject:" "attachment:" "mimetype:") (mapcar (lambda (tag) (concat "tag:" (notmuch-escape-boolean-term tag))) (process-lines notmuch-command "search" "--output=tags" "*") -- 1.9.1
[PATCH v2 3/5] Add indexing for the mimetype term
--- lib/database.cc | 1 + lib/index.cc| 6 ++ 2 files changed, 7 insertions(+) diff --git a/lib/database.cc b/lib/database.cc index 2de60f8..7c7a267 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -254,6 +254,7 @@ static prefix_t PROBABILISTIC_PREFIX[]= { { "from", "XFROM" }, { "to","XTO" }, { "attachment","XATTACHMENT" }, +{ "mimetype", "XMIMETYPE"}, { "subject", "XSUBJECT"}, }; diff --git a/lib/index.cc b/lib/index.cc index 1a2e63d..2e27558 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -318,6 +318,12 @@ _index_mime_part (notmuch_message_t *message, return; } + +GMimeContentType* content_type = g_mime_object_get_content_type(part); +if (content_type) { + _notmuch_message_gen_terms (message, "mimetype", g_mime_content_type_to_string(content_type)); +} + if (GMIME_IS_MULTIPART (part)) { GMimeMultipart *multipart = GMIME_MULTIPART (part); int i; -- 1.9.1
[PATCH v2 5/5] Update documentation
--- NEWS | 16 doc/man7/notmuch-search-terms.rst | 6 ++ 2 files changed, 22 insertions(+) diff --git a/NEWS b/NEWS index 44e8d05..0df7977 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,19 @@ +Notmuch 0.20 (TBD) += + +Overview + + +Command-Line Interface +-- + +There is a new `mimetype:` search prefix + + The new `mimetype:` search prefix allows searching for the + content-type of attachments, which is now indexed by `notmuch + insert`. See the `notmuch-search-terms` manual page for details. + + Notmuch 0.19 (2014-11-14) = diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst index 1acdaa0..8d1acfc 100644 --- a/doc/man7/notmuch-search-terms.rst +++ b/doc/man7/notmuch-search-terms.rst @@ -40,6 +40,8 @@ indicate user-supplied values): - attachment: +- mimetype: + - tag: (or is:) - id: @@ -66,6 +68,10 @@ by including quotation marks around the phrase, immediately following The **attachment:** prefix can be used to search for specific filenames (or extensions) of attachments to email messages. +The **mimetype:** prefix can be used to search for the specific +content-types of mime parts within email messages (as specified by the +sender). + For **tag:** and **is:** valid tag values include **inbox** and **unread** by default for new messages added by **notmuch new** as well as any other tag values added manually with **notmuch tag**. -- 1.9.1