]> git.notmuchmail.org Git - notmuch/commitdiff
notmuch: Implement search-tags as an alias for "search --output=tags *"
authorCarl Worth <cworth@cworth.org>
Tue, 24 May 2011 19:09:53 +0000 (12:09 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 24 May 2011 19:19:18 +0000 (12:19 -0700)
Ever since we added support for "notmuch search --output=tags" the
"notmuch search-tags" command has been redundant. The recent addition
of alias support makes it easy to drop the explicit search-tags
command in favor of a simple alias that runs "notmuch search
--output=tags *".

So there's no longer any documentation of the search-tags command, but
existing scripts will not break at all.

Makefile.local
notmuch-search-tags.c [deleted file]
notmuch.c

index 50bba640aa66bbfdce01099ee75ff20d58f6bb6e..8a8832da992722c61d8a58cb7a4d738fae2f401d 100644 (file)
@@ -242,7 +242,6 @@ notmuch_client_srcs =               \
        notmuch-reply.c         \
        notmuch-restore.c       \
        notmuch-search.c        \
        notmuch-reply.c         \
        notmuch-restore.c       \
        notmuch-search.c        \
-       notmuch-search-tags.c   \
        notmuch-setup.c         \
        notmuch-show.c          \
        notmuch-tag.c           \
        notmuch-setup.c         \
        notmuch-show.c          \
        notmuch-tag.c           \
diff --git a/notmuch-search-tags.c b/notmuch-search-tags.c
deleted file mode 100644 (file)
index 6f3cfcc..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* notmuch - Not much of an email program, (just index and search)
- *
- * Copyright © 2009 Carl Worth
- * Copyright © 2009 Jan Janak
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see http://www.gnu.org/licenses/ .
- *
- * Author: Jan Janak <jan@ryngle.com>
- */
-
-#include "notmuch-client.h"
-
-static void
-print_tags (notmuch_tags_t *tags)
-{
-    const char *t;
-
-    while ((t = notmuch_tags_get (tags))) {
-       printf ("%s\n", t);
-       notmuch_tags_move_to_next (tags);
-    }
-}
-
-int
-notmuch_search_tags_command (void *ctx, int argc, char *argv[])
-{
-    notmuch_messages_t *msgs;
-    notmuch_tags_t *tags;
-    notmuch_config_t *config;
-    notmuch_database_t *db;
-    notmuch_query_t *query;
-    char *query_str;
-
-    tags = NULL;
-    config = NULL;
-    db = NULL;
-    query = NULL;
-
-    if ((config = notmuch_config_open (ctx, NULL, NULL)) == NULL) {
-       goto error;
-    }
-
-    db = notmuch_database_open (notmuch_config_get_database_path (config),
-                               NOTMUCH_DATABASE_MODE_READ_ONLY);
-    if (db == NULL) {
-       goto error;
-    }
-
-    if (argc > 0) {
-       if ((query_str = query_string_from_args (ctx, argc, argv)) == NULL) {
-           fprintf (stderr, "Out of memory.\n");
-           goto error;
-       }
-
-       if (*query_str == '\0') {
-           fprintf (stderr, "Error: Invalid search string.\n");
-           goto error;
-       }
-
-       if ((query = notmuch_query_create (db, query_str)) == NULL) {
-           fprintf (stderr, "Out of memory\n");
-           goto error;
-       }
-
-
-       msgs = notmuch_query_search_messages (query);
-       if ((tags = notmuch_messages_collect_tags (msgs)) == NULL) goto error;
-    } else {
-       if ((tags = notmuch_database_get_all_tags (db)) == NULL) {
-           fprintf (stderr, "Error while getting tags from the database.\n");
-           goto error;
-       }
-    }
-
-    print_tags (tags);
-
-    notmuch_tags_destroy (tags);
-    if (query) notmuch_query_destroy (query);
-    notmuch_database_close (db);
-    return 0;
-
-error:
-    if (tags) notmuch_tags_destroy (tags);
-    if (query) notmuch_query_destroy (query);
-    if (db) notmuch_database_close (db);
-    return 1;
-}
index 9bb884712dbb86a6dc245219f2d4495dc3faf464..262d677c5b4d700277c5e4521382cce2de0b7bc0 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -32,7 +32,7 @@ typedef struct command {
     const char *documentation;
 } command_t;
 
     const char *documentation;
 } command_t;
 
-#define MAX_ALIAS_SUBSTITUTIONS 2
+#define MAX_ALIAS_SUBSTITUTIONS 3
 
 typedef struct alias {
     const char *name;
 
 typedef struct alias {
     const char *name;
@@ -40,7 +40,8 @@ typedef struct alias {
 } alias_t;
 
 alias_t aliases[] = {
 } alias_t;
 
 alias_t aliases[] = {
-    { "part", { "show", "--format=raw"}}
+    { "part", { "show", "--format=raw"}},
+    { "search-tags", {"search", "--output=tags", "*"}}
 };
 
 static int
 };
 
 static int
@@ -374,15 +375,6 @@ static command_t commands[] = {
       "\tSo if you've previously been using sup for mail, then the\n"
       "\t\"notmuch restore\" command provides you a way to import\n"
       "\tall of your tags (or labels as sup calls them)." },
       "\tSo if you've previously been using sup for mail, then the\n"
       "\t\"notmuch restore\" command provides you a way to import\n"
       "\tall of your tags (or labels as sup calls them)." },
-    { "search-tags", notmuch_search_tags_command,
-      "[<search-terms> [...] ]",
-      "List all tags found in the database or matching messages.",
-      "\tRun this command without any search-term(s) to obtain a list\n"
-      "\tof all tags found in the database. If you provide one or more\n"
-      "\tsearch-terms as argument(s) then the resulting list will\n"
-      "\tcontain tags only from messages that match the search-term(s).\n"
-      "\n"
-      "\tIn both cases the list will be alphabetically sorted." },
     { "config", notmuch_config_command,
       "[get|set] <section>.<item> [value ...]",
       "Get or set settings in the notmuch configuration file.",
     { "config", notmuch_config_command,
       "[get|set] <section>.<item> [value ...]",
       "Get or set settings in the notmuch configuration file.",