Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 6e / 2050044a794d091cb4101705254baf987e0016
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 B758E6DE0350\r
6  for <notmuch@notmuchmail.org>; Sat,  9 Jan 2016 18:51:55 -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.31\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.31 tagged_above=-999 required=5 tests=[AWL=0.241, \r
12  RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] 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 ucYN7Dj1nb0i for <notmuch@notmuchmail.org>;\r
16  Sat,  9 Jan 2016 18:51:53 -0800 (PST)\r
17 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 806716DE02C9\r
19  for <notmuch@notmuchmail.org>; Sat,  9 Jan 2016 18:51:53 -0800 (PST)\r
20 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
21  (envelope-from <bremner@tethera.net>)\r
22  id 1aI66Z-0007DA-SG; Sat, 09 Jan 2016 21:51:43 -0500\r
23 Received: (nullmailer pid 29644 invoked by uid 1000);\r
24  Sun, 10 Jan 2016 02:51:47 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: notmuch@notmuchmail.org\r
27 Subject: [WIP patch 3/9] lib: add and test function to retrive current key\r
28 Date: Sat,  9 Jan 2016 22:51:35 -0400\r
29 Message-Id: <1452394301-29499-4-git-send-email-david@tethera.net>\r
30 X-Mailer: git-send-email 2.6.4\r
31 In-Reply-To: <1452394301-29499-1-git-send-email-david@tethera.net>\r
32 References: <1452394301-29499-1-git-send-email-david@tethera.net>\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.20\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37  <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
39  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Sun, 10 Jan 2016 02:51:55 -0000\r
46 \r
47 ---\r
48  lib/metadata.cc       | 17 +++++++++++++++++\r
49  lib/notmuch.h         |  6 ++++++\r
50  test/T590-metadata.sh |  4 +++-\r
51  3 files changed, 26 insertions(+), 1 deletion(-)\r
52 \r
53 diff --git a/lib/metadata.cc b/lib/metadata.cc\r
54 index 5d319c5..20805e5 100644\r
55 --- a/lib/metadata.cc\r
56 +++ b/lib/metadata.cc\r
57 @@ -26,6 +26,7 @@ struct _notmuch_metadata {\r
58      notmuch_database_t *notmuch;\r
59      Xapian::TermIterator *iterator;\r
60      notmuch_metadata_class_t mclass;\r
61 +    char *current_key;\r
62  };\r
63  \r
64  static int\r
65 @@ -180,6 +181,7 @@ notmuch_database_get_all_metadata (notmuch_database_t *notmuch,\r
66      list->iterator = new Xapian::TermIterator;\r
67      list->notmuch = notmuch;\r
68      list->mclass = mclass;\r
69 +    list->current_key = NULL;\r
70  \r
71      try {\r
72  \r
73 @@ -211,3 +213,18 @@ notmuch_metadata_valid (notmuch_metadata_t *metadata)\r
74  \r
75      return (strncmp((**(metadata->iterator)).c_str (), prefix, strlen (prefix)) == 0);\r
76  }\r
77 +\r
78 +const char *\r
79 +notmuch_metadata_key (notmuch_metadata_t *metadata)\r
80 +{\r
81 +    const char *prefix = _find_metadata_prefix (metadata->mclass);\r
82 +\r
83 +    if (metadata->current_key)\r
84 +       talloc_free (metadata->current_key);\r
85 +    metadata->current_key = talloc_strdup (metadata, (**(metadata->iterator)).c_str () + strlen (prefix));\r
86 +\r
87 +    return  metadata->current_key;\r
88 +}\r
89 +\r
90 +const char *\r
91 +}\r
92 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
93 index a2b7040..16d0973 100644\r
94 --- a/lib/notmuch.h\r
95 +++ b/lib/notmuch.h\r
96 @@ -1866,6 +1866,12 @@ notmuch_database_get_all_metadata (notmuch_database_t *db, notmuch_metadata_clas\r
97   */\r
98  notmuch_bool_t\r
99  notmuch_metadata_valid (notmuch_metadata_t *metadata);\r
100 +\r
101 +/**\r
102 + * return key for current metadata pair\r
103 + */\r
104 +const char *\r
105 +notmuch_metadata_key (notmuch_metadata_t *metadata);\r
106  /* @} */\r
107  \r
108  NOTMUCH_END_DECLS\r
109 diff --git a/test/T590-metadata.sh b/test/T590-metadata.sh\r
110 index c36a7d7..2c44746 100755\r
111 --- a/test/T590-metadata.sh\r
112 +++ b/test/T590-metadata.sh\r
113 @@ -55,17 +55,19 @@ testkey2 = testvalue2\r
114  EOF\r
115  test_expect_equal_file EXPECTED OUTPUT\r
116  \r
117 -test_begin_subtest "notmuch_database_get_all_metadata initially valid"\r
118 +test_begin_subtest "notmuch_database_get_all_metadata first item"\r
119  cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}\r
120  {\r
121     notmuch_metadata_t *meta;\r
122     RUN(notmuch_database_get_all_metadata (db, NOTMUCH_METADATA_CONFIG, &meta));\r
123     printf("valid = %d\n", notmuch_metadata_valid (meta));\r
124 +   printf("key = %s\n", notmuch_metadata_key (meta));\r
125  }\r
126  EOF\r
127  cat <<'EOF' >EXPECTED\r
128  == stdout ==\r
129  valid = 1\r
130 +key = testkey1\r
131  == stderr ==\r
132  EOF\r
133  test_expect_equal_file EXPECTED OUTPUT\r
134 -- \r
135 2.6.4\r
136 \r