1 Return-Path: <jan@ryngle.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 97134431FAE
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:23 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id HKOQsob7QVtx for <notmuch@notmuchmail.org>;
\r
11 Sun, 22 Nov 2009 16:11:23 -0800 (PST)
\r
12 Received: from mail-fx0-f214.google.com (mail-fx0-f214.google.com
\r
14 by olra.theworths.org (Postfix) with ESMTP id C5ED7431FC0
\r
15 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:22 -0800 (PST)
\r
16 Received: by fxm6 with SMTP id 6so5354636fxm.0
\r
17 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:11:21 -0800 (PST)
\r
18 Received: by 10.103.84.30 with SMTP id m30mr1873923mul.23.1258935081351;
\r
19 Sun, 22 Nov 2009 16:11:21 -0800 (PST)
\r
20 Received: from x61s.janakj (r2c34.net.upc.cz [62.245.66.34])
\r
21 by mx.google.com with ESMTPS id 14sm14332748muo.34.2009.11.22.16.11.20
\r
22 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
23 Sun, 22 Nov 2009 16:11:20 -0800 (PST)
\r
24 Received: by x61s.janakj (Postfix, from userid 1000)
\r
25 id 0EFC4440656; Mon, 23 Nov 2009 01:10:57 +0100 (CET)
\r
26 From: Jan Janak <jan@ryngle.com>
\r
27 To: notmuch@notmuchmail.org
\r
28 Date: Mon, 23 Nov 2009 01:10:55 +0100
\r
29 Message-Id: <1258935056-9746-2-git-send-email-jan@ryngle.com>
\r
30 X-Mailer: git-send-email 1.6.3.3
\r
31 In-Reply-To: <1258935056-9746-1-git-send-email-jan@ryngle.com>
\r
32 References: <1258935056-9746-1-git-send-email-jan@ryngle.com>
\r
33 Subject: [notmuch] [PATCH 2/3] notmuch: New command 'search-tags'.
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.12
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Mon, 23 Nov 2009 00:11:23 -0000
\r
48 This is a new notmuch command that can be used to search for all tags
\r
49 found in the database. The resulting list is alphabetically sorted.
\r
51 The primary use-case for this new command is to provide the tag
\r
52 completion feature in Emacs (and other interfaces).
\r
54 Signed-off-by: Jan Janak <jan@ryngle.com>
\r
56 Makefile.local | 1 +
\r
57 notmuch-client.h | 3 ++
\r
58 notmuch-search-tags.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
60 4 files changed, 81 insertions(+), 0 deletions(-)
\r
61 create mode 100644 notmuch-search-tags.c
\r
63 diff --git a/Makefile.local b/Makefile.local
\r
64 index 2828659..d8f7906 100644
\r
65 --- a/Makefile.local
\r
66 +++ b/Makefile.local
\r
67 @@ -12,6 +12,7 @@ notmuch_client_srcs = \
\r
71 + notmuch-search-tags.c \
\r
75 diff --git a/notmuch-client.h b/notmuch-client.h
\r
76 index ea77686..c6142b5 100644
\r
77 --- a/notmuch-client.h
\r
78 +++ b/notmuch-client.h
\r
79 @@ -114,6 +114,9 @@ notmuch_show_command (void *ctx, int argc, char *argv[]);
\r
81 notmuch_tag_command (void *ctx, int argc, char *argv[]);
\r
84 +notmuch_search_tags_command (void *ctx, int argc, char *argv[]);
\r
87 notmuch_time_relative_date (const void *ctx, time_t then);
\r
89 diff --git a/notmuch-search-tags.c b/notmuch-search-tags.c
\r
90 new file mode 100644
\r
91 index 0000000..1201165
\r
93 +++ b/notmuch-search-tags.c
\r
95 +/* notmuch - Not much of an email program, (just index and search)
\r
97 + * Copyright © 2009 Carl Worth
\r
98 + * Copyright © 2009 Jan Janak
\r
100 + * This program is free software: you can redistribute it and/or modify
\r
101 + * it under the terms of the GNU General Public License as published by
\r
102 + * the Free Software Foundation, either version 3 of the License, or
\r
103 + * (at your option) any later version.
\r
105 + * This program is distributed in the hope that it will be useful,
\r
106 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
107 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
108 + * GNU General Public License for more details.
\r
110 + * You should have received a copy of the GNU General Public License
\r
111 + * along with this program. If not, see http://www.gnu.org/licenses/ .
\r
113 + * Author: Jan Janak <jan@ryngle.com>
\r
116 +#include "notmuch-client.h"
\r
119 +list_all_tags (notmuch_database_t* db)
\r
121 + notmuch_tags_t* tags;
\r
124 + if ((tags = notmuch_database_get_all_tags (db)) == NULL) {
\r
125 + fprintf (stderr, "Error while obtaining tags from the database.\n");
\r
129 + while((t = notmuch_tags_get (tags))) {
\r
130 + printf ("%s\n", t);
\r
131 + notmuch_tags_advance (tags);
\r
134 + notmuch_tags_destroy (tags);
\r
139 +notmuch_search_tags_command (void *ctx, int argc, char *argv[])
\r
141 + notmuch_config_t *config;
\r
142 + notmuch_database_t *db;
\r
147 + if ((config = notmuch_config_open (ctx, NULL, NULL)) == NULL) {
\r
151 + db = notmuch_database_open (notmuch_config_get_database_path (config),
\r
152 + NOTMUCH_DATABASE_MODE_READ_ONLY);
\r
153 + if (db == NULL) {
\r
157 + if (list_all_tags (db) != 0) goto error;
\r
159 + notmuch_database_close (db);
\r
163 + if (db) notmuch_database_close (db);
\r
166 diff --git a/notmuch.c b/notmuch.c
\r
167 index 5cc8e4c..b1d7cf9 100644
\r
170 @@ -230,6 +230,12 @@ command_t commands[] = {
\r
171 "\t\tSo if you've previously been using sup for mail, then the\n"
\r
172 "\t\t\"notmuch restore\" command provides you a way to import\n"
\r
173 "\t\tall of your tags (or labels as sup calls them)." },
\r
174 + { "search-tags", notmuch_search_tags_command,
\r
176 + "List all tags found in the database.",
\r
177 + "\t\tThis command returns an alphabetically sorted list of all tags\n"
\r
178 + "\t\tthat are present in the database. In other words, the resulting\n"
\r
179 + "\t\tlist is a collection of all tags from all messages." },
\r
180 { "help", notmuch_help_command,
\r
182 "\t\tThis message, or more detailed help for the named command.",
\r