From: patrick brisbin Date: Wed, 5 Sep 2012 11:27:23 +0000 (+0200) Subject: use the Maildir if NotmuchDefaultUri is unset X-Git-Tag: neomutt-20160404~13^2~55 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e13787e769544e8489895f5726d6de5391e639f5;p=neomutt use the Maildir if NotmuchDefaultUri is unset [kzak@redhat.com: - cleanup code, add note to README.notmuch] Signed-off-by: Karel Zak --- diff --git a/README.notmuch b/README.notmuch index eb6fd2b42..1183bf06f 100644 --- a/README.notmuch +++ b/README.notmuch @@ -33,7 +33,8 @@ notmuch support for mutt is found as returned by 'notmuch config get database.path' command. Note that the should NOT include .notmuch directory name. - If the "" is not defined then $nm_default_uri is used, for example: + If the "" is not defined then $nm_default_uri or $folder is used, + for example: set nm_default_uri = "notmuch:///home/foo/maildir" virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox" @@ -131,8 +132,9 @@ notmuch support for mutt nm_default_uri = This variable specifies the default Notmuch database in format - notmuch://, the URI is used for notmuch queries (ESC+X) when - the current folder is not based on notmuch. + notmuch://, the URI is used for notmuch queries (ESC+X) when the + current folder is not based on notmuch. If the default URI is not specified + then mutt will try to use $folder variable (see mutt manual for more details). nm_hidden_tags = diff --git a/mutt_notmuch.c b/mutt_notmuch.c index bfbc59d8d..4b824a704 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -358,6 +358,8 @@ static const char *get_db_filename(struct nm_ctxdata *data) return NULL; db_filename = data->db_filename ? data->db_filename : NotmuchDefaultUri; + if (!db_filename) + db_filename = Maildir; if (!db_filename) return NULL; if (strncmp(db_filename, "notmuch://", 10) == 0) @@ -876,6 +878,8 @@ char *nm_uri_from_query(CONTEXT *ctx, char *buf, size_t bufsz) get_db_filename(data), buf); else if (NotmuchDefaultUri) snprintf(uri, sizeof(uri), "%s?query=%s", NotmuchDefaultUri, buf); + else if (Maildir) + snprintf(uri, sizeof(uri), "notmuch://%s?query=%s", Maildir, buf); else return NULL; @@ -1186,11 +1190,15 @@ int nm_nonctx_get_count(char *path, int *all, int *new) if (!db_query) goto done; - if (!db_filename && NotmuchDefaultUri) { - if (strncmp(NotmuchDefaultUri, "notmuch://", 10) == 0) - db_filename = NotmuchDefaultUri + 10; - else - db_filename = NotmuchDefaultUri; + + if (!db_filename) { + if (NotmuchDefaultUri) { + if (strncmp(NotmuchDefaultUri, "notmuch://", 10) == 0) + db_filename = NotmuchDefaultUri + 10; + else + db_filename = NotmuchDefaultUri; + } else if (Maildir) + db_filename = Maildir; dflt = 1; }