]> granicus.if.org Git - neomutt/commitdiff
use the Maildir if NotmuchDefaultUri is unset
authorpatrick brisbin <pbrisbin@gmail.com>
Wed, 5 Sep 2012 11:27:23 +0000 (13:27 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:06 +0000 (16:30 +0100)
[kzak@redhat.com: - cleanup code, add note to README.notmuch]

Signed-off-by: Karel Zak <kzak@redhat.com>
README.notmuch
mutt_notmuch.c

index eb6fd2b4293a2a2e5df130228cc10886f5084172..1183bf06f67e3a7c97de4a10f8f9264b181ee778 100644 (file)
@@ -33,7 +33,8 @@ notmuch support for mutt
    is found as returned by 'notmuch config get database.path' command. Note that
    the <path> should NOT include .notmuch directory name.
 
-   If the "<path>" is not defined then $nm_default_uri is used, for example:
+   If the "<path>" 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 = <uri>
 
       This variable specifies the default Notmuch database in format
-      notmuch://<absolute path>, the URI is used for notmuch queries (ESC+X) when
-      the current folder is not based on notmuch.
+      notmuch://<absolute path>, 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 = <comma delimited list>
 
index bfbc59d8d17aecfe1f38ed1cf7daf830df91f61d..4b824a70480141d04f3b91de042db15e632a2486 100644 (file)
@@ -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;
        }