[PATCH v3] emacs: wrap current search in parens when filtering
[notmuch-archives.git] / f0 / 17a24c41106f72711a52abdcd0ef385d46d2b2
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 C9E5C6DE15C9\r
6  for <notmuch@notmuchmail.org>; Sun,  7 Jun 2015 08:04:26 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.223\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.223 tagged_above=-999 required=5 tests=[AWL=0.213, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id dI5h3XPQr1ie for <notmuch@notmuchmail.org>;\r
16  Sun,  7 Jun 2015 08:04:25 -0700 (PDT)\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
18  [87.98.215.224])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 1B0096DE1557\r
20  for <notmuch@notmuchmail.org>; Sun,  7 Jun 2015 08:04:25 -0700 (PDT)\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
22  4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
23  id 1Z1c6x-0004oy-EG; Sun, 07 Jun 2015 15:03:43 +0000\r
24 Received: (nullmailer pid 7866 invoked by uid 1000); Sun, 07 Jun 2015\r
25  15:02:11 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [PATCH 09/10] cli/count: update to use\r
29  notmuch_query_search_messages_st\r
30 Date: Sun,  7 Jun 2015 17:02:02 +0200\r
31 Message-Id: <1433689323-7520-10-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 2.1.4\r
33 In-Reply-To: <1433689323-7520-1-git-send-email-david@tethera.net>\r
34 References: <1433689323-7520-1-git-send-email-david@tethera.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.18\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Sun, 07 Jun 2015 15:04:26 -0000\r
48 \r
49 This brings back status information that may have been hidden by the\r
50 great library logging conversion.\r
51 ---\r
52  notmuch-count.c    | 16 ++++++++++------\r
53  test/T060-count.sh | 30 ++++++++++++++++++++++++++++++\r
54  2 files changed, 40 insertions(+), 6 deletions(-)\r
55 \r
56 diff --git a/notmuch-count.c b/notmuch-count.c\r
57 index 57a88a8..25b05df 100644\r
58 --- a/notmuch-count.c\r
59 +++ b/notmuch-count.c\r
60 @@ -33,17 +33,18 @@ enum {\r
61      EXCLUDE_FALSE,\r
62  };\r
63  \r
64 -static unsigned int\r
65 +static int\r
66  count_files (notmuch_query_t *query)\r
67  {\r
68      notmuch_messages_t *messages;\r
69      notmuch_message_t *message;\r
70      notmuch_filenames_t *filenames;\r
71 -    unsigned int count = 0;\r
72 +    notmuch_status_t status;\r
73 +    int count = 0;\r
74  \r
75 -    messages = notmuch_query_search_messages (query);\r
76 -    if (messages == NULL)\r
77 -       return 0;\r
78 +    status = notmuch_query_search_messages_st (query, &messages);\r
79 +    if (print_status_query ("notmuch count", query, status))\r
80 +       return -1;\r
81  \r
82      for (;\r
83          notmuch_messages_valid (messages);\r
84 @@ -71,6 +72,7 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
85  {\r
86      notmuch_query_t *query;\r
87      size_t i;\r
88 +    int count;\r
89  \r
90      query = notmuch_query_create (notmuch, query_str);\r
91      if (query == NULL) {\r
92 @@ -89,7 +91,9 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
93         printf ("%u\n", notmuch_query_count_threads (query));\r
94         break;\r
95      case OUTPUT_FILES:\r
96 -       printf ("%u\n", count_files (query));\r
97 +       count = count_files (query);\r
98 +       if (count >= 0)\r
99 +           printf ("%u\n", count);\r
100         break;\r
101      }\r
102  \r
103 diff --git a/test/T060-count.sh b/test/T060-count.sh\r
104 index da86c8c..973a42d 100755\r
105 --- a/test/T060-count.sh\r
106 +++ b/test/T060-count.sh\r
107 @@ -93,5 +93,35 @@ notmuch count --output=messages >>EXPECTED\r
108  notmuch count --output=messages tag:inbox >>EXPECTED\r
109  test_expect_equal_file EXPECTED OUTPUT\r
110  \r
111 +backup_database\r
112 +test_begin_subtest "error message for database open"\r
113 +dd if=/dev/zero of="${MAIL_DIR}/.notmuch/xapian/postlist.DB" count=3\r
114 +notmuch count '*' 2>OUTPUT 1>/dev/null\r
115 +output=$(sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' OUTPUT)\r
116 +test_expect_equal "${output}" "A Xapian exception occurred opening database"\r
117 +restore_database\r
118 +\r
119 +cat <<EOF > count-files.gdb\r
120 +set breakpoint pending on\r
121 +break count_files\r
122 +commands\r
123 +shell cp /dev/null ${MAIL_DIR}/.notmuch/xapian/postlist.DB\r
124 +continue\r
125 +end\r
126 +run\r
127 +EOF\r
128 +\r
129 +backup_database\r
130 +test_begin_subtest "error message from query_search_messages"\r
131 +gdb --batch-silent --return-child-result -x count-files.gdb \\r
132 +    --args notmuch count --output=files '*' 2>OUTPUT 1>/dev/null\r
133 +cat <<EOF > EXPECTED\r
134 +notmuch count: A Xapian exception occurred\r
135 +A Xapian exception occurred performing query\r
136 +Query string was: *\r
137 +EOF\r
138 +sed 's/^\(A Xapian exception [^:]*\):.*$/\1/' < OUTPUT > OUTPUT.clean\r
139 +test_expect_equal_file EXPECTED OUTPUT.clean\r
140 +restore_database\r
141  \r
142  test_done\r
143 -- \r
144 2.1.4\r
145 \r