Re: [PATCH] lib: reword comment about XFOLDER: prefix
[notmuch-archives.git] / 6d / 00ccdc88b6846a0254f6a765b4c7eac160dbda
1 Return-Path: <bremner@tethera.net>\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 arlo.cworth.org (Postfix) with ESMTP id 3BBD76DE1348\r
6  for <notmuch@notmuchmail.org>; Sun,  6 Mar 2016 03:56:43 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.034\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.034 tagged_above=-999 required=5\r
12  tests=[AWL=-0.023, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id zT9V4IXtKhI3 for <notmuch@notmuchmail.org>;\r
17  Sun,  6 Mar 2016 03:56:40 -0800 (PST)\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id AE3156DE021D\r
20  for <notmuch@notmuchmail.org>; Sun,  6 Mar 2016 03:56:40 -0800 (PST)\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
22  (envelope-from <bremner@tethera.net>)\r
23  id 1acXJD-0000tn-BY; Sun, 06 Mar 2016 06:57:15 -0500\r
24 Received: (nullmailer pid 3486 invoked by uid 1000);\r
25  Sun, 06 Mar 2016 11:56:35 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: Ludovic LANGE <ll-notmuchmail@lange.nom.fr>, notmuch@notmuchmail.org\r
28 Subject: [PATCH] ruby: add bindings for `notmuch_database_get_all_tags`\r
29 Date: Sun,  6 Mar 2016 07:56:28 -0400\r
30 Message-Id: <1457265388-3434-1-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.7.0\r
32 In-Reply-To: <1416167892-15686-1-git-send-email-ll-notmuchmail@lange.nom.fr>\r
33 References: <1416167892-15686-1-git-send-email-ll-notmuchmail@lange.nom.fr>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sun, 06 Mar 2016 11:56:43 -0000\r
47 \r
48 From: Ludovic LANGE <ll-notmuchmail@lange.nom.fr>\r
49 \r
50 The Ruby bindings were missing a way to get all the tags of the\r
51 database. Now you should be able to access this with the public\r
52 instance method `all_tags` of your database object.\r
53 \r
54 Example of use:\r
55     notmuchdb = Notmuch::Database.new path, { :create => false,\r
56         :mode => Notmuch::MODE_READ_ONLY }\r
57 \r
58     my_tags = notmuchdb.all_tags\r
59 \r
60     my_tags.each { |tag|\r
61       print tag\r
62     }\r
63 \r
64     my_tags.destroy!\r
65 \r
66 Amended by db: improve error reporting, add test\r
67 ---\r
68 \r
69 I'm not super happy with the "%s", but apparently the compiler is not smart enough to accept just "msg" there.\r
70 \r
71  NEWS                     |  5 +++++\r
72  bindings/ruby/database.c | 24 ++++++++++++++++++++++++\r
73  bindings/ruby/defs.h     |  3 +++\r
74  bindings/ruby/init.c     |  1 +\r
75  test/T395-ruby.sh        | 16 ++++++++++++++++\r
76  5 files changed, 49 insertions(+)\r
77 \r
78 diff --git a/NEWS b/NEWS\r
79 index 613fdfe..43dc5e0 100644\r
80 --- a/NEWS\r
81 +++ b/NEWS\r
82 @@ -1,6 +1,11 @@\r
83  Notmuch 0.22 (UNRELEASED)\r
84  =========================\r
85  \r
86 +Ruby Bindings\r
87 +-------------\r
88 +\r
89 +Add support for `notmuch_database_get_all_tags`\r
90 +\r
91  Emacs Interface\r
92  ---------------\r
93  \r
94 diff --git a/bindings/ruby/database.c b/bindings/ruby/database.c\r
95 index c03d701..6deda57 100644\r
96 --- a/bindings/ruby/database.c\r
97 +++ b/bindings/ruby/database.c\r
98 @@ -375,6 +375,30 @@ notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv)\r
99  }\r
100  \r
101  /*\r
102 + * call-seq: DB.get_all_tags() => TAGS\r
103 + *\r
104 + * Returns a list of all tags found in the database.\r
105 + */\r
106 +VALUE\r
107 +notmuch_rb_database_get_all_tags (VALUE self)\r
108 +{\r
109 +    notmuch_database_t *db;\r
110 +    notmuch_tags_t *tags;\r
111 +\r
112 +    Data_Get_Notmuch_Database (self, db);\r
113 +\r
114 +    tags = notmuch_database_get_all_tags (db);\r
115 +    if (!tags) {\r
116 +       const char *msg = notmuch_database_status_string (db);\r
117 +       if (!msg)\r
118 +           msg = "Unknown notmuch error";\r
119 +\r
120 +       rb_raise (notmuch_rb_eBaseError, "%s", msg);\r
121 +    }\r
122 +    return Data_Wrap_Struct (notmuch_rb_cTags, NULL, NULL, tags);\r
123 +}\r
124 +\r
125 +/*\r
126   * call-seq: DB.query(query) => QUERY\r
127   *\r
128   * Retrieve a query object for the query string 'query'\r
129 diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h\r
130 index f4901a0..167250e 100644\r
131 --- a/bindings/ruby/defs.h\r
132 +++ b/bindings/ruby/defs.h\r
133 @@ -178,6 +178,9 @@ VALUE\r
134  notmuch_rb_database_find_message_by_filename (VALUE self, VALUE pathv);\r
135  \r
136  VALUE\r
137 +notmuch_rb_database_get_all_tags (VALUE self);\r
138 +\r
139 +VALUE\r
140  notmuch_rb_database_query_create (VALUE self, VALUE qstrv);\r
141  \r
142  /* directory.c */\r
143 diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c\r
144 index ab3f22d..865d6bf 100644\r
145 --- a/bindings/ruby/init.c\r
146 +++ b/bindings/ruby/init.c\r
147 @@ -229,6 +229,7 @@ Init_notmuch (void)\r
148                       notmuch_rb_database_find_message, 1); /* in database.c */\r
149      rb_define_method (notmuch_rb_cDatabase, "find_message_by_filename",\r
150                       notmuch_rb_database_find_message_by_filename, 1); /* in database.c */\r
151 +    rb_define_method (notmuch_rb_cDatabase, "all_tags", notmuch_rb_database_get_all_tags, 0); /* in database.c */\r
152      rb_define_method (notmuch_rb_cDatabase, "query", notmuch_rb_database_query_create, 1); /* in database.c */\r
153  \r
154      /*\r
155 diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh\r
156 index d5cade8..20e0691 100755\r
157 --- a/test/T395-ruby.sh\r
158 +++ b/test/T395-ruby.sh\r
159 @@ -83,4 +83,20 @@ EOF\r
160  notmuch count --output=threads tag:inbox > EXPECTED\r
161  test_expect_equal_file OUTPUT EXPECTED\r
162  \r
163 +test_begin_subtest "get all tags"\r
164 +test_ruby <<"EOF"\r
165 +require 'notmuch'\r
166 +$maildir = ENV['MAIL_DIR']\r
167 +if not $maildir then\r
168 +  abort('environment variable MAIL_DIR must be set')\r
169 +end\r
170 +@db = Notmuch::Database.new($maildir)\r
171 +@t = @db.all_tags()\r
172 +for tag in @t do\r
173 +   print tag,"\n"\r
174 +end\r
175 +EOF\r
176 +notmuch search --output=tags '*' > EXPECTED\r
177 +test_expect_equal_file OUTPUT EXPECTED\r
178 +\r
179  test_done\r
180 -- \r
181 2.7.0\r
182 \r