Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
On Mon, 2016-11-21 at 13:44 +0200, Jani Nikula wrote: > I wonder if there's a way to define different Execs for clicking on > the icon and handling mailto. The desktop file format specification implies you can just add an extra context entry. For reference, the full specification is here: https://specifications.freedesktop.org/desktop-entry-spec/latest/ Something like this seems like what the spec suggests: [Desktop Entry] Name=Notmuch Emacs Client GenericName=Email Client Comment=Emacs based email client Exec=emacs -f notmuch Icon=emblem-mail Terminal=false Type=Application Categories=Network;Email; [Create Message] Name=Notmuch Emacs Create Message Exec=notmuch-emacs-mua %u MimeType=x-scheme-handler/mailto; However, this did not seem to work when I tried it out in my gnome session. I'm pretty sure creating two separate desktop files (duplicating some of the fields) would work. --- Keith ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 2/4] lib/query: make query parsing lazy again, keep centralized.
This is mainly to fix the nasty error path introduced in the last commit, by moving the parsing into functions where the API is already set up to return error status. It preserves the feature of having a pre-parsed query available for further processing. --- lib/query.cc | 37 ++--- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/query.cc b/lib/query.cc index f2a95da..c356fe5 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -29,6 +29,7 @@ struct _notmuch_query { notmuch_sort_t sort; notmuch_string_list_t *exclude_terms; notmuch_exclude_t omit_excluded; +notmuch_bool_t parsed; Xapian::Query xapian_query; }; @@ -93,6 +94,7 @@ notmuch_query_create (notmuch_database_t *notmuch, return NULL; new (>xapian_query) Xapian::Query (); +query->parsed = FALSE; talloc_set_destructor (query, _notmuch_query_destructor); @@ -106,22 +108,33 @@ notmuch_query_create (notmuch_database_t *notmuch, query->omit_excluded = NOTMUCH_EXCLUDE_TRUE; +return query; +} + +static notmuch_status_t +_notmuch_query_ensure_parsed (notmuch_query_t *query) +{ +if (query->parsed) + return NOTMUCH_STATUS_SUCCESS; + try { query->xapian_query = - notmuch->query_parser->parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); + query->notmuch->query_parser-> + parse_query (query->query_string, NOTMUCH_QUERY_PARSER_FLAGS); + + query->parsed = TRUE; + } catch (const Xapian::Error ) { - _notmuch_database_log (notmuch, + _notmuch_database_log (query->notmuch, "A Xapian exception occured parsing query: %s\n", error.get_msg().c_str()); - _notmuch_database_log_append (notmuch, + _notmuch_database_log_append (query->notmuch, "Query string was: %s\n", query->query_string); - talloc_free (query); - query = NULL; + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; } - -return query; +return NOTMUCH_STATUS_SUCCESS; } const char * @@ -225,6 +238,11 @@ _notmuch_query_search_documents (notmuch_query_t *query, notmuch_database_t *notmuch = query->notmuch; const char *query_string = query->query_string; notmuch_mset_messages_t *messages; +notmuch_status_t status; + +status = _notmuch_query_ensure_parsed (query); +if (status) + return status; messages = talloc (query, notmuch_mset_messages_t); if (unlikely (messages == NULL)) @@ -591,6 +609,11 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign notmuch_database_t *notmuch = query->notmuch; const char *query_string = query->query_string; Xapian::doccount count = 0; +notmuch_status_t status; + +status = _notmuch_query_ensure_parsed (query); +if (status) + return status; try { Xapian::Enquire enquire (*notmuch->xapian_db); -- 2.10.2 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH 4/4] lib: make notmuch_query_add_tag_exclude return a status value
Since this is an ABI breaking change, bump the SONAME. --- lib/notmuch.h| 23 +++ lib/query.cc | 7 --- notmuch-count.c | 9 +++-- notmuch-search.c | 12 ++-- notmuch-show.c | 13 +++-- 5 files changed, 51 insertions(+), 13 deletions(-) diff --git a/lib/notmuch.h b/lib/notmuch.h index 18678c0..054d86a 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -55,8 +55,8 @@ NOTMUCH_BEGIN_DECLS * The library version number. This must agree with the soname * version in Makefile.local. */ -#define LIBNOTMUCH_MAJOR_VERSION 4 -#define LIBNOTMUCH_MINOR_VERSION 4 +#define LIBNOTMUCH_MAJOR_VERSION 5 +#define LIBNOTMUCH_MINOR_VERSION 0 #define LIBNOTMUCH_MICRO_VERSION 0 @@ -180,6 +180,11 @@ typedef enum _notmuch_status { */ NOTMUCH_STATUS_PATH_ERROR, /** + * The requested operation was ignored. Depending on the function, + * this may not be an actual error. + */ +NOTMUCH_STATUS_IGNORED, +/** * One of the arguments violates the preconditions for the * function, in a way not covered by a more specific argument. */ @@ -812,10 +817,20 @@ notmuch_query_get_sort (const notmuch_query_t *query); /** * Add a tag that will be excluded from the query results by default. - * This exclusion will be overridden if this tag appears explicitly in + * This exclusion will be ignored if this tag appears explicitly in * the query. + * + * @returns + * + * NOTMUCH_STATUS_SUCCESS: excluded was added successfully. + * + * NOTMUCH_STATUS_XAPIAN_EXCEPTION: a Xapian exception occured. + * Most likely a problem lazily parsing the query string. + * + * NOTMUCH_STATUS_IGNORED: tag is explicitely present in the query, so + * not excluded. */ -void +notmuch_status_t notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag); /** diff --git a/lib/query.cc b/lib/query.cc index 961cb76..fba6e07 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -174,7 +174,7 @@ notmuch_query_get_sort (const notmuch_query_t *query) return query->sort; } -void +notmuch_status_t notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag) { notmuch_status_t status; @@ -182,13 +182,14 @@ notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag) status = _notmuch_query_ensure_parsed (query); if (status) - return; /* XXX report error */ + return status; term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag); if (query->terms.count(term) != 0) - return; /* XXX report ignoring exclude? */ + return NOTMUCH_STATUS_IGNORED; _notmuch_string_list_append (query->exclude_terms, term); +return NOTMUCH_STATUS_SUCCESS; } /* We end up having to call the destructors explicitly because we had diff --git a/notmuch-count.c b/notmuch-count.c index 35a2aa7..3207c01 100644 --- a/notmuch-count.c +++ b/notmuch-count.c @@ -87,8 +87,13 @@ print_count (notmuch_database_t *notmuch, const char *query_str, return -1; } -for (i = 0; i < exclude_tags_length; i++) - notmuch_query_add_tag_exclude (query, exclude_tags[i]); +for (i = 0; i < exclude_tags_length; i++) { + status = notmuch_query_add_tag_exclude (query, exclude_tags[i]); + if (status && status != NOTMUCH_STATUS_IGNORED) { + print_status_query ("notmuch count", query, status); + return -1; + } +} switch (output) { case OUTPUT_MESSAGES: diff --git a/notmuch-search.c b/notmuch-search.c index 8c65d5a..64a9811 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -735,11 +735,19 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar if (ctx->exclude != NOTMUCH_EXCLUDE_FALSE) { const char **search_exclude_tags; size_t search_exclude_tags_length; + notmuch_status_t status; search_exclude_tags = notmuch_config_get_search_exclude_tags (config, _exclude_tags_length); - for (i = 0; i < search_exclude_tags_length; i++) - notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]); + + for (i = 0; i < search_exclude_tags_length; i++) { + status = notmuch_query_add_tag_exclude (ctx->query, search_exclude_tags[i]); + if (status && status != NOTMUCH_STATUS_IGNORED) { + print_status_query ("notmuch search", ctx->query, status); + return EXIT_FAILURE; + } + } + notmuch_query_set_omit_excluded (ctx->query, ctx->exclude); } diff --git a/notmuch-show.c b/notmuch-show.c index 22fa655..4c63959 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -1157,11 +1157,19 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[]) const char **search_exclude_tags; size_t search_exclude_tags_length; unsigned int i; + notmuch_status_t status;
[PATCH 3/4] lib: query make exclude handling non-destructive
We filter added exclude at add time, rather than modifying the query by count search. As noted in the comments, there are several ignored conditions here. Returning proper status is split into a separate commit because it is ABI breaking. --- lib/query.cc | 47 +-- test/T060-count.sh | 1 - 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/lib/query.cc b/lib/query.cc index c356fe5..961cb76 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -31,6 +31,7 @@ struct _notmuch_query { notmuch_exclude_t omit_excluded; notmuch_bool_t parsed; Xapian::Query xapian_query; +std::set terms; }; typedef struct _notmuch_mset_messages { @@ -77,6 +78,7 @@ _debug_query (void) static int _notmuch_query_destructor (notmuch_query_t *query) { query->xapian_query.~Query(); +query->terms.~set(); return 0; } @@ -94,6 +96,7 @@ notmuch_query_create (notmuch_database_t *notmuch, return NULL; new (>xapian_query) Xapian::Query (); +new (>terms) std::set (); query->parsed = FALSE; talloc_set_destructor (query, _notmuch_query_destructor); @@ -122,6 +125,15 @@ _notmuch_query_ensure_parsed (notmuch_query_t *query) query->notmuch->query_parser-> parse_query (query->query_string, NOTMUCH_QUERY_PARSER_FLAGS); + /* Xapian doesn't support skip_to on terms from a query since + * they are unordered, so cache a copy of all terms in + * something searchable. + */ + + for (Xapian::TermIterator t = query->xapian_query.get_terms_begin(); +t != query->xapian_query.get_terms_end(); ++t) + query->terms.insert(*t); + query->parsed = TRUE; } catch (const Xapian::Error ) { @@ -165,7 +177,17 @@ notmuch_query_get_sort (const notmuch_query_t *query) void notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag) { -char *term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag); +notmuch_status_t status; +char *term; + +status = _notmuch_query_ensure_parsed (query); +if (status) + return; /* XXX report error */ + +term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag); +if (query->terms.count(term) != 0) + return; /* XXX report ignoring exclude? */ + _notmuch_string_list_append (query->exclude_terms, term); } @@ -185,28 +207,17 @@ _notmuch_messages_destructor (notmuch_mset_messages_t *messages) } /* Return a query that matches messages with the excluded tags - * registered with query. Any tags that explicitly appear in xquery - * will not be excluded, and will be removed from the list of exclude - * tags. The caller of this function has to combine the returned + * registered with query. The caller of this function has to combine the returned * query appropriately.*/ static Xapian::Query -_notmuch_exclude_tags (notmuch_query_t *query, Xapian::Query xquery) +_notmuch_exclude_tags (notmuch_query_t *query) { Xapian::Query exclude_query = Xapian::Query::MatchNothing; for (notmuch_string_node_t *term = query->exclude_terms->head; term; term = term->next) { - Xapian::TermIterator it = xquery.get_terms_begin (); - Xapian::TermIterator end = xquery.get_terms_end (); - for (; it != end; it++) { - if ((*it).compare (term->string) == 0) - break; - } - if (it == end) - exclude_query = Xapian::Query (Xapian::Query::OP_OR, - exclude_query, Xapian::Query (term->string)); - else - term->string = talloc_strdup (query, ""); + exclude_query = Xapian::Query (Xapian::Query::OP_OR, + exclude_query, Xapian::Query (term->string)); } return exclude_query; } @@ -277,7 +288,7 @@ _notmuch_query_search_documents (notmuch_query_t *query, messages->base.excluded_doc_ids = NULL; if ((query->omit_excluded != NOTMUCH_EXCLUDE_FALSE) && (query->exclude_terms)) { - exclude_query = _notmuch_exclude_tags (query, final_query); + exclude_query = _notmuch_exclude_tags (query); if (query->omit_excluded == NOTMUCH_EXCLUDE_TRUE || query->omit_excluded == NOTMUCH_EXCLUDE_ALL) @@ -632,7 +643,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign mail_query, query->xapian_query); } - exclude_query = _notmuch_exclude_tags (query, final_query); + exclude_query = _notmuch_exclude_tags (query); final_query = Xapian::Query (Xapian::Query::OP_AND_NOT, final_query, exclude_query); diff --git a/test/T060-count.sh b/test/T060-count.sh index 69ab591..b82583b 100755 --- a/test/T060-count.sh +++ b/test/T060-count.sh @@ -127,7 +127,6 @@ test_expect_equal_file EXPECTED OUTPUT.clean restore_database
[PATCH 1/4] lib: eagerly parse queries
Rather than waiting for a call to count/search, parse the query string when the notmuch_query_t is created. This is a small reduction in duplicated code, and a potential efficiency improvement if many count/search operations are called on the same query (although the latter sounds a bit unusual). The main goal is to prepare the way for non-destructive (or at least less destructive) exclude tag handling. It does introduce a not-very-nice error path where running out of memory is not easily distinguishable from a query syntax error. --- lib/query.cc | 39 +++ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/query.cc b/lib/query.cc index 53efd4e..f2a95da 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -29,6 +29,7 @@ struct _notmuch_query { notmuch_sort_t sort; notmuch_string_list_t *exclude_terms; notmuch_exclude_t omit_excluded; +Xapian::Query xapian_query; }; typedef struct _notmuch_mset_messages { @@ -71,6 +72,13 @@ _debug_query (void) return (env && strcmp (env, "") != 0); } +/* Explicit destructor call for placement new */ +static int +_notmuch_query_destructor (notmuch_query_t *query) { +query->xapian_query.~Query(); +return 0; +} + notmuch_query_t * notmuch_query_create (notmuch_database_t *notmuch, const char *query_string) @@ -84,6 +92,10 @@ notmuch_query_create (notmuch_database_t *notmuch, if (unlikely (query == NULL)) return NULL; +new (>xapian_query) Xapian::Query (); + +talloc_set_destructor (query, _notmuch_query_destructor); + query->notmuch = notmuch; query->query_string = talloc_strdup (query, query_string); @@ -94,6 +106,21 @@ notmuch_query_create (notmuch_database_t *notmuch, query->omit_excluded = NOTMUCH_EXCLUDE_TRUE; +try { + query->xapian_query = + notmuch->query_parser->parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); +} catch (const Xapian::Error ) { + _notmuch_database_log (notmuch, + "A Xapian exception occured parsing query: %s\n", + error.get_msg().c_str()); + _notmuch_database_log_append (notmuch, + "Query string was: %s\n", + query->query_string); + + talloc_free (query); + query = NULL; +} + return query; } @@ -217,7 +244,7 @@ _notmuch_query_search_documents (notmuch_query_t *query, Xapian::Query mail_query (talloc_asprintf (query, "%s%s", _find_prefix ("type"), type)); - Xapian::Query string_query, final_query, exclude_query; + Xapian::Query final_query, exclude_query; Xapian::MSet mset; Xapian::MSetIterator iterator; @@ -226,10 +253,8 @@ _notmuch_query_search_documents (notmuch_query_t *query, { final_query = mail_query; } else { - string_query = notmuch->query_parser-> - parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, -mail_query, string_query); +mail_query, query->xapian_query); } messages->base.excluded_doc_ids = NULL; @@ -572,7 +597,7 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign Xapian::Query mail_query (talloc_asprintf (query, "%s%s", _find_prefix ("type"), type)); - Xapian::Query string_query, final_query, exclude_query; + Xapian::Query final_query, exclude_query; Xapian::MSet mset; if (strcmp (query_string, "") == 0 || @@ -580,10 +605,8 @@ _notmuch_query_count_documents (notmuch_query_t *query, const char *type, unsign { final_query = mail_query; } else { - string_query = notmuch->query_parser-> - parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, -mail_query, string_query); +mail_query, query->xapian_query); } exclude_query = _notmuch_exclude_tags (query, final_query); -- 2.10.2 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
V3 of non-destructive excludes patches
Obsoletes id:20161002021328.30487-1-da...@tethera.net There is only trivial whitespace changes in the final diff, but I did move several small changes / fixes farther back in the series. As before, it's a bit of an open question whether breaking the ABI is worth it to return a proper status value (see patch 4/4). d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 9/9] build: update the desktop database after installing the desktop file
This makes the option to choose Notmuch as mailto: handler show up in the desktop environment settings. --- emacs/Makefile.local | 1 + 1 file changed, 1 insertion(+) diff --git a/emacs/Makefile.local b/emacs/Makefile.local index ffa8421ebd45..de4f40d1316b 100644 --- a/emacs/Makefile.local +++ b/emacs/Makefile.local @@ -99,6 +99,7 @@ endif ifeq ($(WITH_DESKTOP),1) mkdir -p "$(DESTDIR)$(desktop_dir)" desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" $(emacs_mua_desktop) + update-desktop-database "$(DESTDIR)$(desktop_dir)" endif CLEAN := $(CLEAN) $(emacs_bytecode) $(dir)/notmuch-version.el $(dir)/notmuch-pkg.el -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 7/9] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
With the mailto: handling in notmuch-emacs-mua, we can update the desktop file to advertize we can be set as the default application to handle email. While at it, add GenericName and Comment to be more informative. With --hello, notmuch-emacs-mua will run (notmuch) if mailto: url is not given. --- emacs/notmuch-emacs-mua.desktop | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emacs/notmuch-emacs-mua.desktop b/emacs/notmuch-emacs-mua.desktop index f1600473bf60..0d9af2a4cf39 100644 --- a/emacs/notmuch-emacs-mua.desktop +++ b/emacs/notmuch-emacs-mua.desktop @@ -1,6 +1,9 @@ [Desktop Entry] Name=Notmuch (emacs interface) -Exec=emacs -f notmuch +GenericName=Email Client +Comment=Emacs based email client +Exec=notmuch-emacs-mua --hello %u +MimeType=x-scheme-handler/mailto; Icon=emblem-mail Terminal=false Type=Application -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 3/9] emacs: move notmuch-emacs-mua under emacs
While the notmuch-emacs-mua script is a sort of cli command, it is really a part of notmuch-emacs. Move it under the emacs directory. --- notmuch-emacs-mua => emacs/notmuch-emacs-mua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename notmuch-emacs-mua => emacs/notmuch-emacs-mua (100%) diff --git a/notmuch-emacs-mua b/emacs/notmuch-emacs-mua similarity index 100% rename from notmuch-emacs-mua rename to emacs/notmuch-emacs-mua -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 4/9] notmuch-emacs-mua: add --hello parameter
If the --hello parameter is given, display the notmuch hello buffer instead of the message composition buffer if no message composition parameters are given. Signed-off-by: Jani Nikula--- doc/man1/notmuch-emacs-mua.rst | 4 emacs/notmuch-emacs-mua| 8 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst index b80aa5f9b2e5..87787e20e531 100644 --- a/doc/man1/notmuch-emacs-mua.rst +++ b/doc/man1/notmuch-emacs-mua.rst @@ -33,6 +33,10 @@ Supported options for **emacs-mua** include ``-i, --body=``\ Specify a file to include into the body of the message. +``--hello`` +Go to the Notmuch hello screen instead of the message composition +window if no message composition parameters are given. + ``--no-window-system`` Even if a window system is available, use the current terminal. diff --git a/emacs/notmuch-emacs-mua b/emacs/notmuch-emacs-mua index 98103972f400..a521497784ec 100755 --- a/emacs/notmuch-emacs-mua +++ b/emacs/notmuch-emacs-mua @@ -40,6 +40,7 @@ AUTO_DAEMON= CREATE_FRAME= ELISP= MAILTO= +HELLO= # Short options compatible with mutt(1). while getopts :s:c:b:i:h opt; do @@ -63,7 +64,7 @@ while getopts :s:c:b:i:h opt; do opt=${opt%%=*} ;; # Long options without arguments. - --help|--print|--no-window-system|--client|--auto-daemon|--create-frame) + --help|--print|--no-window-system|--client|--auto-daemon|--create-frame|--hello) ;; *) echo "$0: unknown long option ${opt}, or argument mismatch." >&2 @@ -112,6 +113,9 @@ while getopts :s:c:b:i:h opt; do --create-frame) CREATE_FRAME="-c" ;; + --hello) + HELLO=1 + ;; *) # We should never end up here. echo "$0: internal error (option ${opt})." >&2 @@ -146,6 +150,8 @@ if [ -n "${MAILTO}" ]; then exit 1 fi ELISP="(browse-url-mail \"${MAILTO}\")" +elif [ -z "${ELISP}" -a -n "${HELLO}" ]; then +ELISP="(notmuch)" else ELISP="(notmuch-mua-new-mail) ${ELISP}" fi -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 5/9] build: install notmuch-emacs-mua with notmuch-emacs
notmuch-emacs-mua is good enough to be installed with notmuch-emacs. --- emacs/Makefile.local | 4 1 file changed, 4 insertions(+) diff --git a/emacs/Makefile.local b/emacs/Makefile.local index 90a57cca74ed..8ab7b1260924 100644 --- a/emacs/Makefile.local +++ b/emacs/Makefile.local @@ -36,6 +36,8 @@ $(dir)/notmuch-pkg.el: $(srcdir)/$(dir)/notmuch-pkg.el.tmpl all: $(dir)/notmuch-pkg.el install-emacs: $(dir)/notmuch-pkg.el +emacs_mua := $(dir)/notmuch-emacs-mua + emacs_images := \ $(srcdir)/$(dir)/notmuch-logo.png @@ -91,5 +93,7 @@ ifeq ($(HAVE_EMACS),1) endif mkdir -p "$(DESTDIR)$(emacsetcdir)" install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)" + mkdir -p "$(DESTDIR)$(prefix)/bin/" + install $(emacs_mua) "$(DESTDIR)$(prefix)/bin" CLEAN := $(CLEAN) $(emacs_bytecode) $(dir)/notmuch-version.el $(dir)/notmuch-pkg.el -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 0/9] improvements around notmuch-emacs-mua
v2 of id:cover.1478205331.git.j...@nikula.org, with rebase plus David's concern about .desktop opening mail composition vs. hello screen addressed. BR, Jani. Jani Nikula (9): completion: complete notmuch emacs-mua man: advertize notmuch-emacs-mua as notmuch emacs-mua subcommand emacs: move notmuch-emacs-mua under emacs notmuch-emacs-mua: add --hello parameter build: install notmuch-emacs-mua with notmuch-emacs notmuch.desktop: move under emacs as notmuch-emacs-mua.desktop emacs/desktop: update to use notmuch-emacs-mua and handle mailto build: install notmuch-emacs-mua.desktop file with emacs build: update the desktop database after installing the desktop file Makefile.local | 5 completion/notmuch-completion.bash | 34 +++- configure| 13 +++ doc/man1/notmuch-emacs-mua.rst | 8 +-- emacs/Makefile.local | 10 notmuch-emacs-mua => emacs/notmuch-emacs-mua | 8 ++- emacs/notmuch-emacs-mua.desktop | 10 notmuch.desktop | 7 -- 8 files changed, 79 insertions(+), 16 deletions(-) rename notmuch-emacs-mua => emacs/notmuch-emacs-mua (97%) create mode 100644 emacs/notmuch-emacs-mua.desktop delete mode 100644 notmuch.desktop -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 1/9] completion: complete notmuch emacs-mua
With subcommand handling for external commands we can easily complete 'notmuch emacs-mua' using the existing completion system. --- completion/notmuch-completion.bash | 34 +- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/completion/notmuch-completion.bash b/completion/notmuch-completion.bash index d44b2a2811f0..cbe59e23f772 100644 --- a/completion/notmuch-completion.bash +++ b/completion/notmuch-completion.bash @@ -236,6 +236,38 @@ _notmuch_dump() esac } +_notmuch_emacs_mua() +{ +local cur prev words cword split +_init_completion -s || return + +$split && +case "${prev}" in + --to|--cc|--bcc) + COMPREPLY=( $(compgen -W "`_notmuch_email to:${cur}`" -- ${cur}) ) + return + ;; + --body) + _filedir + return + ;; +esac + +! $split && +case "${cur}" in +-*) + local options="--subject= --to= --cc= --bcc= --body= --no-window-system --client --auto-daemon --create-frame --print --help" + + compopt -o nospace + COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) + ;; + *) + COMPREPLY=( $(compgen -W "`_notmuch_email to:${cur}`" -- ${cur}) ) + return + ;; +esac +} + _notmuch_insert() { local cur prev words cword split @@ -496,7 +528,7 @@ _notmuch_tag() _notmuch() { -local _notmuch_commands="compact config count dump help insert new reply restore search address setup show tag" +local _notmuch_commands="compact config count dump help insert new reply restore search address setup show tag emacs-mua" local arg cur prev words cword split # require bash-completion with _init_completion -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 6/9] notmuch.desktop: move under emacs as notmuch-emacs-mua.desktop
The notmuch.desktop file is part of notmuch-emacs. Move it under emacs, and rename as notmuch-emacs-mua.desktop to reflect this. --- Makefile.local | 5 - emacs/Makefile.local | 6 ++ notmuch.desktop => emacs/notmuch-emacs-mua.desktop | 0 3 files changed, 6 insertions(+), 5 deletions(-) rename notmuch.desktop => emacs/notmuch-emacs-mua.desktop (100%) diff --git a/Makefile.local b/Makefile.local index 0a122ab0e208..f90a97c4a6b7 100644 --- a/Makefile.local +++ b/Makefile.local @@ -336,11 +336,6 @@ ifeq ($(WITH_EMACS), 1) endif endif -.PHONY: install-desktop -install-desktop: - mkdir -p "$(DESTDIR)$(desktop_dir)" - desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" notmuch.desktop - SRCS := $(SRCS) $(notmuch_client_srcs) CLEAN := $(CLEAN) notmuch notmuch-shared $(notmuch_client_modules) CLEAN := $(CLEAN) version.stamp notmuch-*.tar.gz.tmp diff --git a/emacs/Makefile.local b/emacs/Makefile.local index 8ab7b1260924..b47577ac1110 100644 --- a/emacs/Makefile.local +++ b/emacs/Makefile.local @@ -37,6 +37,7 @@ all: $(dir)/notmuch-pkg.el install-emacs: $(dir)/notmuch-pkg.el emacs_mua := $(dir)/notmuch-emacs-mua +emacs_mua_desktop := $(dir)/notmuch-emacs-mua.desktop emacs_images := \ $(srcdir)/$(dir)/notmuch-logo.png @@ -96,4 +97,9 @@ endif mkdir -p "$(DESTDIR)$(prefix)/bin/" install $(emacs_mua) "$(DESTDIR)$(prefix)/bin" +.PHONY: install-desktop +install-desktop: + mkdir -p "$(DESTDIR)$(desktop_dir)" + desktop-file-install --mode 0644 --dir "$(DESTDIR)$(desktop_dir)" $(emacs_mua_desktop) + CLEAN := $(CLEAN) $(emacs_bytecode) $(dir)/notmuch-version.el $(dir)/notmuch-pkg.el diff --git a/notmuch.desktop b/emacs/notmuch-emacs-mua.desktop similarity index 100% rename from notmuch.desktop rename to emacs/notmuch-emacs-mua.desktop -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2 2/9] man: advertize notmuch-emacs-mua as notmuch emacs-mua subcommand
With subcommand handling for external commands we can now hide the implementation detail of emacs-mua being a separate notmuch-emacs-mua script. --- doc/man1/notmuch-emacs-mua.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst index 651d00fa4eb8..b80aa5f9b2e5 100644 --- a/doc/man1/notmuch-emacs-mua.rst +++ b/doc/man1/notmuch-emacs-mua.rst @@ -5,7 +5,7 @@ notmuch-emacs-mua SYNOPSIS -**notmuch-emacs-mua** [options ...] [ ... | ] +**notmuch** **emacs-mua** [options ...] [ ... | ] DESCRIPTION === @@ -13,7 +13,7 @@ DESCRIPTION Start composing an email in the Notmuch Emacs UI with the specified subject, recipients, and message body, or mailto: URL. -Supported options for **notmuch-emacs-mua** include +Supported options for **emacs-mua** include ``-h, --help`` Display help. -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
On Mon, 21 Nov 2016, Jani Nikulawrote: > On Mon, 21 Nov 2016, Keith Amidon wrote: >> However, this did not seem to work when I tried it out in my gnome >> session. I'm pretty sure creating two separate desktop files >> (duplicating some of the fields) would work. > > I see three options here: > > 1) Just always go to message composition directly (meh) > > 2) Add two desktop files (meh) > > 3) Have notmuch-emacs-mua call (notmuch-hello) if there are no arguments >(Tomi's suggestion). I like this because notmuch-emacs-mua also does >(require 'notmuch). > > 4) Same as 3) but only do it if a new --hello parameter is given but >there are no other arguments. This is to not change notmuch-emacs-mua >default behaviour. > > I'd go for either 3 or 4. This is what 4) would look like: diff --git a/emacs/notmuch-emacs-mua b/emacs/notmuch-emacs-mua index 98103972f400..a521497784ec 100755 --- a/emacs/notmuch-emacs-mua +++ b/emacs/notmuch-emacs-mua @@ -40,6 +40,7 @@ AUTO_DAEMON= CREATE_FRAME= ELISP= MAILTO= +HELLO= # Short options compatible with mutt(1). while getopts :s:c:b:i:h opt; do @@ -63,7 +64,7 @@ while getopts :s:c:b:i:h opt; do opt=${opt%%=*} ;; # Long options without arguments. - --help|--print|--no-window-system|--client|--auto-daemon|--create-frame) + --help|--print|--no-window-system|--client|--auto-daemon|--create-frame|--hello) ;; *) echo "$0: unknown long option ${opt}, or argument mismatch." >&2 @@ -112,6 +113,9 @@ while getopts :s:c:b:i:h opt; do --create-frame) CREATE_FRAME="-c" ;; + --hello) + HELLO=1 + ;; *) # We should never end up here. echo "$0: internal error (option ${opt})." >&2 @@ -146,6 +150,8 @@ if [ -n "${MAILTO}" ]; then exit 1 fi ELISP="(browse-url-mail \"${MAILTO}\")" +elif [ -z "${ELISP}" -a -n "${HELLO}" ]; then +ELISP="(notmuch)" else ELISP="(notmuch-mua-new-mail) ${ELISP}" fi ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
On Mon, 21 Nov 2016, Keith Amidonwrote: > However, this did not seem to work when I tried it out in my gnome > session. I'm pretty sure creating two separate desktop files > (duplicating some of the fields) would work. I see three options here: 1) Just always go to message composition directly (meh) 2) Add two desktop files (meh) 3) Have notmuch-emacs-mua call (notmuch-hello) if there are no arguments (Tomi's suggestion). I like this because notmuch-emacs-mua also does (require 'notmuch). 4) Same as 3) but only do it if a new --hello parameter is given but there are no other arguments. This is to not change notmuch-emacs-mua default behaviour. I'd go for either 3 or 4. BR, Jani. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] gzclose_r() and gzclose_w() are not available in older...
On Mon, 21 Nov 2016, Tomi Ollilawrote: > On Mon, Nov 21 2016, David Bremner wrote: > >> I take the submitters word for the first version supporting gzclose > > I tried this patch on Scientific Linux 6.2 -- after applied it I changed > the check to >= 1.2.3 (to the one used in sl62). > > This compiles fine but tests fails miserably. zlib 1.2.5.2 (the version we currently require) was released 2011-12-17. I wouldn't put any effort into supporting an even older version of zlib. We've dropped support for newer stuff (and we're still pretty conservative). BR, Jani. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH v2] cli: consider files vanishing during notmuch new non-fatal
If some software other than notmuch new renames or removes files during the notmuch new scan (specifically after scandir but before indexing the file), keep going instead of bailing out. Failing to index the file is just a race condition between notmuch and the other software; the rename could happen after the notmuch new scan anyway. It's not fatal, and we'll catch the renamed files on the next scan. Add a new exit code for when files vanished, so the caller has a chance to detect the race and re-run notmuch new to recover. Reported by Paul Wiseat http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=843127 --- v2: use EX_TEMPFAIL status code --- notmuch-client.h | 11 +++ notmuch-new.c| 15 --- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 9ce2aef17431..793f32ecc55a 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -25,6 +25,7 @@ #define _GNU_SOURCE /* for getline */ #endif #include +#include #include "compat.h" @@ -114,6 +115,16 @@ chomp_newline (char *str) str[strlen(str)-1] = '\0'; } +/* Exit status code indicating temporary failure; user is invited to + * retry. + * + * For example, file(s) in the mail store were removed or renamed + * after notmuch new scanned the directories but before indexing the + * file(s). If the file was renamed, the indexing might not be + * complete, and the user is advised to re-run notmuch new. + */ +#define NOTMUCH_EXIT_TEMPFAIL EX_TEMPFAIL + /* Exit status code indicating the requested format version is too old * (support for that version has been dropped). CLI code should use * notmuch_exit_if_unsupported_format rather than directly exiting diff --git a/notmuch-new.c b/notmuch-new.c index c55dea7bc1b7..cc680b412a45 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -53,6 +53,7 @@ typedef struct { int total_files; int processed_files; int added_messages, removed_messages, renamed_messages; +int vanished_files; struct timeval tv_start; _filename_list_t *removed_files; @@ -280,11 +281,13 @@ add_file (notmuch_database_t *notmuch, const char *filename, case NOTMUCH_STATUS_FILE_NOT_EMAIL: fprintf (stderr, "Note: Ignoring non-mail file: %s\n", filename); break; -/* Fatal issues. Don't process anymore. */ case NOTMUCH_STATUS_FILE_ERROR: + /* Someone renamed/removed the file between scandir and now. */ + state->vanished_files++; fprintf (stderr, "Unexpected error with file %s\n", filename); (void) print_status_database ("add_file", notmuch, status); - goto DONE; + break; +/* Fatal issues. Don't process anymore. */ case NOTMUCH_STATUS_READ_ONLY_DATABASE: case NOTMUCH_STATUS_XAPIAN_EXCEPTION: case NOTMUCH_STATUS_OUT_OF_MEMORY: @@ -1151,5 +1154,11 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[]) if (!no_hooks && !ret && !interrupted) ret = notmuch_run_hook (db_path, "post-new"); -return ret || interrupted ? EXIT_FAILURE : EXIT_SUCCESS; +if (ret || interrupted) + return EXIT_FAILURE; + +if (add_files_state.vanished_files) + return NOTMUCH_EXIT_TEMPFAIL; + +return EXIT_SUCCESS; } -- 2.1.4 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] gzclose_r() and gzclose_w() are not available in older...
On Mon, Nov 21 2016, David Bremnerwrote: > I take the submitters word for the first version supporting gzclose I tried this patch on Scientific Linux 6.2 -- after applied it I changed the check to >= 1.2.3 (to the one used in sl62). This compiles fine but tests fails miserably. According to http://packages.ubuntu.com/hu/source/precise/zlib it uses zlib 1.2.3.4... ... I created container based on ubuntu:12.04 ... and ... the tests fail there as bad as with 1.2.3. SO, it looks to me that (unfortunately) just doing this is not enough (knowing that one needs to test dump/restore for this patch to be feasible may not be obvious to everyone ;/). My supportive patch: id:1397809386-23356-1-git-send-email-tomi.oll...@iki.fi -- http://article.gmane.org/gmane.mail.notmuch.general/17916 still applies to many systems with older zlib versions; probably to precise as well. test output examples: Warning: cannot parse query: EqÀ2ýA1?çr"9h nV)VC[æ'c¤LÔs£eM NJV>.https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH] gzclose_r() and gzclose_w() are not available in older versions of zlib such as the version on Ubuntu LTS 12.04. Changing to gzclose() allows notmuch to work on older versions as well
Ico Doornekampwrites: > --- > configure |4 ++-- > notmuch-dump.c|4 ++-- > notmuch-restore.c |2 +- > 3 files changed, 5 insertions(+), 5 deletions(-) Looking at the docs, this looks sensible. , | Same as gzclose(), but gzclose_r() is only for use when reading, and | gzclose_w() is only for use when writing or appending. The advantage to | using these instead of gzclose() is that they avoid linking in zlib | compression or decompression code that is not used when only reading or | only writing respectively. If gzclose() is used, then both compression | and decompression code will be included the application when linking to | a static zlib library. ` Probably the commit message could include a paraphrase/quote of the above. I take the submitters word for the first version supporting gzclose ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
[PATCH] gzclose_r() and gzclose_w() are not available in older versions of zlib such as the version on Ubuntu LTS 12.04. Changing to gzclose() allows notmuch to work on older versions as well
--- configure |4 ++-- notmuch-dump.c|4 ++-- notmuch-restore.c |2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/configure b/configure index f0fc466..dc3256b 100755 --- a/configure +++ b/configure @@ -491,9 +491,9 @@ if ! pkg-config --exists zlib; then rm -f compat/gen_zlib_pc fi -printf "Checking for zlib (>= 1.2.5.2)... " +printf "Checking for zlib (>= 1.2.3.4)... " have_zlib=0 -if pkg-config --atleast-version=1.2.5.2 zlib; then +if pkg-config --atleast-version=1.2.3.4 zlib; then printf "Yes.\n" have_zlib=1 zlib_cflags=$(pkg-config --cflags zlib) diff --git a/notmuch-dump.c b/notmuch-dump.c index e7965ce..637d93f 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -328,7 +328,7 @@ notmuch_database_dump (notmuch_database_t *notmuch, } } -if (gzclose_w (output) != Z_OK) { +if (gzclose (output) != Z_OK) { fprintf (stderr, "Error closing %s: %s\n", name_for_error, gzerror (output, NULL)); ret = EXIT_FAILURE; @@ -347,7 +347,7 @@ notmuch_database_dump (notmuch_database_t *notmuch, } DONE: if (ret != EXIT_SUCCESS && output) - (void) gzclose_w (output); + (void) gzclose (output); if (ret != EXIT_SUCCESS && output_file_name) (void) unlink (tempname); diff --git a/notmuch-restore.c b/notmuch-restore.c index d6429ef..b37cfe2 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -449,7 +449,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[]) if (notmuch) notmuch_database_destroy (notmuch); -if (input && gzclose_r (input)) { +if (input && gzclose (input)) { fprintf (stderr, "Error closing %s: %s\n", name_for_error, gzerror (input, NULL)); ret = EXIT_FAILURE; -- 1.7.9.5 ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
On Mon, Nov 21 2016, Jani Nikulawrote: > On Mon, Nov 21, 2016 at 1:34 PM, David Bremner wrote: >> Jani Nikula writes: >> >>> -Exec=emacs -f notmuch >>> +GenericName=Email Client >>> +Comment=Emacs based email client >>> +Exec=notmuch-emacs-mua %u >> >> This seems like a fairly substantial change in functionality. Previously >> people could click on the icon fire up a mail reader; now they get a >> mail composition window. I probably won't use either, but it seems like >> the change merits some discussion. > > I wonder if there's a way to define different Execs for clicking on > the icon and handling mailto. What if notmuch-emacs-mua started (notmuch-hello) in case there are no arguments given ... ? Tomi > > BR, > Jani. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
On Mon, Nov 21, 2016 at 1:34 PM, David Bremnerwrote: > Jani Nikula writes: > >> -Exec=emacs -f notmuch >> +GenericName=Email Client >> +Comment=Emacs based email client >> +Exec=notmuch-emacs-mua %u > > This seems like a fairly substantial change in functionality. Previously > people could click on the icon fire up a mail reader; now they get a > mail composition window. I probably won't use either, but it seems like > the change merits some discussion. I wonder if there's a way to define different Execs for clicking on the icon and handling mailto. BR, Jani. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [PATCH 6/8] emacs/desktop: update to use notmuch-emacs-mua and handle mailto
Jani Nikulawrites: > -Exec=emacs -f notmuch > +GenericName=Email Client > +Comment=Emacs based email client > +Exec=notmuch-emacs-mua %u This seems like a fairly substantial change in functionality. Previously people could click on the icon fire up a mail reader; now they get a mail composition window. I probably won't use either, but it seems like the change merits some discussion. ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch
Re: [emacs] thread view is showing all messages
Mark Walterswrites: > Hi > >>> -- >>> By default, various components of email messages, (citations, >>> signatures, already-read messages), are hidden. >>> -- > > I wonder if this text should be changed -- I am not sure what is meant > by already-read messages (maybe completely cited messages?) but it does > seem misleading. Having said that, I don't have a good suggestion -- the > best I can come up with is "quoted messages" > > Interestingly the wording above dates back to 2009 so maybe it isn't > that big a problem. I'd guess quoted messages also. But this discussion mainly seemed to me like something where having an actual manual (and installing it) would help. Doc strings are not really ideal for getting started. d ___ notmuch mailing list notmuch@notmuchmail.org https://notmuchmail.org/mailman/listinfo/notmuch