]> git.cworth.org Git - notmuch/blobdiff - notmuch.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / notmuch.c
index 68a785e25bf0b826a17071bc8162edefe30fb87b..814b9e42a59f46ae675f24f688005ec22ab58914 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -429,11 +429,18 @@ notmuch_command (notmuch_database_t *notmuch,
  * false on errors.
  */
 static bool
  * false on errors.
  */
 static bool
-try_external_command (char *argv[])
+try_external_command (const char *config_file_name, char *argv[])
 {
     char *old_argv0 = argv[0];
     bool ret = true;
 
 {
     char *old_argv0 = argv[0];
     bool ret = true;
 
+    if (config_file_name) {
+       if (setenv ("NOTMUCH_CONFIG", config_file_name, 1)) {
+           perror ("setenv");
+           exit (1);
+       }
+    }
+
     argv[0] = talloc_asprintf (NULL, "notmuch-%s", old_argv0);
 
     /*
     argv[0] = talloc_asprintf (NULL, "notmuch-%s", old_argv0);
 
     /*
@@ -493,7 +500,7 @@ main (int argc, char *argv[])
     /* if command->function is NULL, try external command */
     if (! command || ! command->function) {
        /* This won't return if the external command is found. */
     /* if command->function is NULL, try external command */
     if (! command || ! command->function) {
        /* This won't return if the external command is found. */
-       if (try_external_command (argv + opt_index))
+       if (try_external_command (config_file_name, argv + opt_index))
            fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
                     command_name);
        ret = EXIT_FAILURE;
            fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
                     command_name);
        ret = EXIT_FAILURE;
@@ -524,7 +531,7 @@ main (int argc, char *argv[])
                }
 
                if (status == NOTMUCH_STATUS_NO_CONFIG)
                }
 
                if (status == NOTMUCH_STATUS_NO_CONFIG)
-                   fputs ("Try running 'notmuch setup' to create a configuration.", stderr);
+                   fputs ("Try running 'notmuch setup' to create a configuration.\n", stderr);
 
                return EXIT_FAILURE;
            }
 
                return EXIT_FAILURE;
            }
@@ -556,15 +563,16 @@ main (int argc, char *argv[])
                                               NULL,
                                               &notmuch,
                                               &status_string);
                                               NULL,
                                               &notmuch,
                                               &status_string);
-
-       if (status == NOTMUCH_STATUS_NO_CONFIG && ! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) {
-           fputs ("Try running 'notmuch setup' to create a configuration.", stderr);
-           goto DONE;
+       if (status_string) {
+           fputs (status_string, stderr);
+           free (status_string);
+           status_string = NULL;
        }
        }
+
        switch (status) {
        case NOTMUCH_STATUS_NO_CONFIG:
            if (! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) {
        switch (status) {
        case NOTMUCH_STATUS_NO_CONFIG:
            if (! (command->mode & NOTMUCH_COMMAND_CONFIG_CREATE)) {
-               fputs ("Try running 'notmuch setup' to create a configuration.", stderr);
+               fputs ("Try running 'notmuch setup' to create a configuration.\n", stderr);
                goto DONE;
            }
            break;
                goto DONE;
            }
            break;
@@ -582,6 +590,8 @@ main (int argc, char *argv[])
        case NOTMUCH_STATUS_SUCCESS:
            break;
        default:
        case NOTMUCH_STATUS_SUCCESS:
            break;
        default:
+           fputs ("Error: unable to load config file.\n", stderr);
+           ret = 1;
            goto DONE;
        }
 
            goto DONE;
        }