Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / ea / df0582fce5ae1e75f74dd6083429616a397a17
1 Return-Path: <amdragon@mit.edu>\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 7DAF0429E26\r
6         for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:54 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id Q5RtEdegnuzs for <notmuch@notmuchmail.org>;\r
16         Thu, 17 May 2012 21:13:53 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU\r
18         [18.7.68.34])\r
19         by olra.theworths.org (Postfix) with ESMTP id DDBED431FC2\r
20         for <notmuch@notmuchmail.org>; Thu, 17 May 2012 21:13:52 -0700 (PDT)\r
21 X-AuditID: 12074422-b7fd66d0000008f9-89-4fb5cc801be8\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
23         by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 83.DF.02297.08CC5BF4; Fri, 18 May 2012 00:13:52 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
26         by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q4I4DpwB021451; \r
27         Fri, 18 May 2012 00:13:51 -0400\r
28 Received: from drake.mit.edu\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q4I4DoVJ026786\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Fri, 18 May 2012 00:13:51 -0400 (EDT)\r
35 Received: from amthrax by drake.mit.edu with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1SVEZa-0000z3-3l; Fri, 18 May 2012 00:13:50 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 3/9] lib: Perform the same transformation to\r
41         _notmuch_database_filename_to_direntry\r
42 Date: Fri, 18 May 2012 00:13:36 -0400\r
43 Message-Id: <1337314423-3702-4-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
46 References: <1337314423-3702-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrAIsWRmVeSWpSXmKPExsUixG6nottwZqu/wcvlEhbXb85kdmD0eLbq\r
49         FnMAYxSXTUpqTmZZapG+XQJXxpXTdQVTZSqm3bBpYDwo1sXIySEhYCKxef8WRghbTOLCvfVs\r
50         XYxcHEIC+xglrr/awAjhbGCUmND6iAnCuc8ksWP7dhYIZxajxI+Xh1lB+tkENCS27V8ONktE\r
51         QFpi593ZQHEODmYBNYk/XSogYWGBFIkjPS1g5SwCqhLXt+1gArF5BewlfrdeZoI4Q17i6f0+\r
52         NpBWTgEHiWnHo0HCQkAl/y40s0xg5F/AyLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI11QvN7NE\r
53         LzWldBMjOGBclHYw/jyodIhRgINRiYd3x5yt/kKsiWXFlbmHGCU5mJREeb+fBArxJeWnVGYk\r
54         FmfEF5XmpBYfYpTgYFYS4ZXtBsrxpiRWVqUW5cOkpDlYlMR51bXe+QkJpCeWpGanphakFsFk\r
55         ZTg4lCR4LU4DNQoWpaanVqRl5pQgpJk4OEGG8wANzwSp4S0uSMwtzkyHyJ9iVJQS5y0DSQiA\r
56         JDJK8+B6YRH9ilEc6BVh3lCQKh5gMoDrfgU0mAlocFnuJpDBJYkIKakGRov0Vt+yvY/lexeH\r
57         NtZosjbc+Z9korJn152sjX05q/QMGXedXP3Wc8Wirh8qoWkW7cXzzXQlBI2Noy02MtfquBvy\r
58         JrAf2FRy85bnpZWGr+uOcDntdPt8XW1Bsf30qJSztit8OrZcPCa+MfT9r4dC5bfYdN79y9ad\r
59         36MRJaDLxVXLepPNdxeXEktxRqKhFnNRcSIA5wWB0MMCAAA=\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Fri, 18 May 2012 04:13:54 -0000\r
73 \r
74 Now _notmuch_database_filename_to_direntry takes a flags argument and\r
75 can indicate if the necessary directory documents do not exist.\r
76 Again, callers have been updated, but retain their original behavior.\r
77 ---\r
78  lib/database.cc       |   17 +++++++++++------\r
79  lib/message.cc        |    9 ++++-----\r
80  lib/notmuch-private.h |    1 +\r
81  3 files changed, 16 insertions(+), 11 deletions(-)\r
82 \r
83 diff --git a/lib/database.cc b/lib/database.cc\r
84 index 716982d..b4c76b4 100644\r
85 --- a/lib/database.cc\r
86 +++ b/lib/database.cc\r
87 @@ -1248,13 +1248,16 @@ _notmuch_database_get_directory_path (void *ctx,\r
88   * database path), return a new string (with 'ctx' as the talloc\r
89   * owner) suitable for use as a direntry term value.\r
90   *\r
91 - * The necessary directory documents will be created in the database\r
92 - * as needed.\r
93 + * If (flags & NOTMUCH_FIND_CREATE), the necessary directory documents\r
94 + * will be created in the database as needed.  Otherwise, if the\r
95 + * necessary directory documents do not exist, this sets\r
96 + * *direntry to NULL and returns NOTMUCH_STATUS_SUCCESS.\r
97   */\r
98  notmuch_status_t\r
99  _notmuch_database_filename_to_direntry (void *ctx,\r
100                                         notmuch_database_t *notmuch,\r
101                                         const char *filename,\r
102 +                                       notmuch_find_flags_t flags,\r
103                                         char **direntry)\r
104  {\r
105      const char *relative, *directory, *basename;\r
106 @@ -1268,10 +1271,12 @@ _notmuch_database_filename_to_direntry (void *ctx,\r
107      if (status)\r
108         return status;\r
109  \r
110 -    status = _notmuch_database_find_directory_id (notmuch, directory, NOTMUCH_FIND_CREATE,\r
111 +    status = _notmuch_database_find_directory_id (notmuch, directory, flags,\r
112                                                   &directory_id);\r
113 -    if (status)\r
114 +    if (status || directory_id == (unsigned int)-1) {\r
115 +       *direntry = NULL;\r
116         return status;\r
117 +    }\r
118  \r
119      *direntry = talloc_asprintf (ctx, "%u:%s", directory_id, basename);\r
120  \r
121 @@ -1892,8 +1897,8 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,\r
122      local = talloc_new (notmuch);\r
123  \r
124      try {\r
125 -       status = _notmuch_database_filename_to_direntry (local, notmuch,\r
126 -                                                        filename, &direntry);\r
127 +       status = _notmuch_database_filename_to_direntry (\r
128 +           local, notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);\r
129         if (status)\r
130             goto DONE;\r
131  \r
132 diff --git a/lib/message.cc b/lib/message.cc\r
133 index 0075425..8d552f1 100644\r
134 --- a/lib/message.cc\r
135 +++ b/lib/message.cc\r
136 @@ -495,9 +495,8 @@ _notmuch_message_add_filename (notmuch_message_t *message,\r
137      if (status)\r
138         return status;\r
139  \r
140 -    status = _notmuch_database_filename_to_direntry (local,\r
141 -                                                    message->notmuch,\r
142 -                                                    filename, &direntry);\r
143 +    status = _notmuch_database_filename_to_direntry (\r
144 +       local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);\r
145      if (status)\r
146         return status;\r
147  \r
148 @@ -541,8 +540,8 @@ _notmuch_message_remove_filename (notmuch_message_t *message,\r
149      notmuch_status_t status;\r
150      Xapian::TermIterator i, last;\r
151  \r
152 -    status = _notmuch_database_filename_to_direntry (local, message->notmuch,\r
153 -                                                    filename, &direntry);\r
154 +    status = _notmuch_database_filename_to_direntry (\r
155 +       local, message->notmuch, filename, NOTMUCH_FIND_CREATE, &direntry);\r
156      if (status)\r
157         return status;\r
158  \r
159 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
160 index a36549d..34f7ac7 100644\r
161 --- a/lib/notmuch-private.h\r
162 +++ b/lib/notmuch-private.h\r
163 @@ -207,6 +207,7 @@ notmuch_status_t\r
164  _notmuch_database_filename_to_direntry (void *ctx,\r
165                                         notmuch_database_t *notmuch,\r
166                                         const char *filename,\r
167 +                                       notmuch_find_flags_t flags,\r
168                                         char **direntry);\r
169  \r
170  /* directory.cc */\r
171 -- \r
172 1.7.10\r
173 \r