1 Return-Path: <jrollins@finestructure.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 olra.theworths.org (Postfix) with ESMTP id 4D103431FC4
\r
6 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 13:58:33 -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 nETV2SM5CDCj for <notmuch@notmuchmail.org>;
\r
11 Sun, 22 Nov 2009 13:58:32 -0800 (PST)
\r
12 Received: from brinza.cc.columbia.edu (brinza.cc.columbia.edu [128.59.29.8])
\r
13 by olra.theworths.org (Postfix) with ESMTP id F0C5F431FBF
\r
14 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 13:58:31 -0800 (PST)
\r
15 Received: from servo.finestructure.net (cpe-72-227-128-66.nyc.res.rr.com
\r
17 (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0)
\r
18 by brinza.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id nAMLwUGZ018108
\r
19 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT)
\r
20 for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 16:58:31 -0500 (EST)
\r
21 Received: from jrollins by servo.finestructure.net with local (Exim 4.69)
\r
22 (envelope-from <jrollins@finestructure.net>)
\r
23 id 1NCKSE-0000Gy-L0; Sun, 22 Nov 2009 16:58:46 -0500
\r
24 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
25 To: notmuch@notmuchmail.org
\r
26 Date: Sun, 22 Nov 2009 16:58:36 -0500
\r
27 Message-Id: <1258927116-528-3-git-send-email-jrollins@finestructure.net>
\r
28 X-Mailer: git-send-email 1.6.5
\r
29 In-Reply-To: <1258927116-528-2-git-send-email-jrollins@finestructure.net>
\r
30 References: <1258927116-528-1-git-send-email-jrollins@finestructure.net>
\r
31 <1258927116-528-2-git-send-email-jrollins@finestructure.net>
\r
32 X-No-Spam-Score: Local
\r
33 X-Scanned-By: MIMEDefang 2.65 on 128.59.29.8
\r
34 Subject: [notmuch] [PATCH 3/3] change config file location to be
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.12
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Sun, 22 Nov 2009 21:58:33 -0000
\r
50 This change creates a ~/.notmuch config directory where the config
\r
51 file is stored when created with the "setup" command. The use of a
\r
52 ~/.notmuch config directory creates one place where all notmuch config
\r
53 files and data can be stored, which will greatly simplify managing
\r
54 notmuch, and reduce cluter of user dot files.
\r
56 notmuch-config.c | 21 ++++++++++++++++++---
\r
57 notmuch-setup.c | 2 +-
\r
60 4 files changed, 22 insertions(+), 7 deletions(-)
\r
62 diff --git a/notmuch-config.c b/notmuch-config.c
\r
63 index 7252a19..321c880 100644
\r
64 --- a/notmuch-config.c
\r
65 +++ b/notmuch-config.c
\r
70 +#include <libgen.h>
\r
71 +#include <sys/stat.h>
\r
73 static const char toplevel_config_comment[] =
\r
74 - " .notmuch-config - Configuration file for the notmuch mail system\n"
\r
75 + " .notmuch/config - Configuration file for the notmuch mail system\n"
\r
77 " For more information about notmuch, see http://notmuchmail.org";
\r
79 @@ -134,7 +136,7 @@ get_username_from_passwd_file (void *ctx)
\r
81 /* Open the named notmuch configuration file. A filename of NULL will
\r
82 * be interpreted as the default configuration file
\r
83 - * ($HOME/.notmuch-config).
\r
84 + * ($HOME/.notmuch/config).
\r
86 * If any error occurs, (out of memory, or a permission-denied error,
\r
87 * etc.), this function will print a message to stderr and return
\r
88 @@ -183,7 +185,7 @@ notmuch_config_open (void *ctx,
\r
90 config->filename = talloc_strdup (config, filename);
\r
92 - config->filename = talloc_asprintf (config, "%s/.notmuch-config",
\r
93 + config->filename = talloc_asprintf (config, "%s/.notmuch/config",
\r
96 config->key_file = g_key_file_new ();
\r
97 @@ -297,14 +299,27 @@ notmuch_config_save (notmuch_config_t *config)
\r
102 GError *error = NULL;
\r
104 + struct stat statbuf;
\r
106 data = g_key_file_to_data (config->key_file, &length, NULL);
\r
107 if (data == NULL) {
\r
108 fprintf (stderr, "Out of memory.\n");
\r
112 + /* Create config directory if it doesn't already exist */
\r
113 + snprintf(buf, sizeof buf, "%s", config->filename);
\r
115 + if (stat(buf, &statbuf) < 0) {
\r
116 + if (mkdir(buf, 0755) < 0) {
\r
117 + fprintf (stderr, "Could not create directory '%s'\n.", buf);
\r
122 if (! g_file_set_contents (config->filename, data, length, &error)) {
\r
123 fprintf (stderr, "Error saving configuration to %s: %s\n",
\r
124 config->filename, error->message);
\r
125 diff --git a/notmuch-setup.c b/notmuch-setup.c
\r
126 index 68788e1..76e104c 100644
\r
127 --- a/notmuch-setup.c
\r
128 +++ b/notmuch-setup.c
\r
129 @@ -74,7 +74,7 @@ welcome_message_post_setup (void)
\r
132 "Notmuch is now configured, and the configuration settings are saved in\n"
\r
133 -"a file in your home directory named .notmuch-config . If you'd like to\n"
\r
134 +"a file in your home directory named .notmuch/config . If you'd like to\n"
\r
135 "change the configuration in the future, you can either edit that file\n"
\r
136 "directly or run \"notmuch setup\".\n\n"
\r
138 diff --git a/notmuch.1 b/notmuch.1
\r
139 index 8a3fb40..9ea1d42 100644
\r
142 @@ -53,7 +53,7 @@ Interactively sets up notmuch for first use.
\r
143 The setup command will prompt for your full name, your primary email
\r
144 address, any alternate email addresses you use, and the directory
\r
145 containing your email archives. Your answers will be written to a
\r
146 -configuration file in ${HOME}/.notmuch-config . This configuration
\r
147 +configuration file in ${HOME}/.notmuch/config . This configuration
\r
148 file will be created with descriptive comments, making it easy to edit
\r
149 by hand later to change the configuration. Or you can run
\r
151 @@ -245,7 +245,7 @@ takes an existing set of messages and constructs a suitable mail
\r
152 template. The Reply-to header (if any, otherwise From:) is used for
\r
153 the To: address. Vales from the To: and Cc: headers are copied, but
\r
154 not including any of the current user's email addresses (as configured
\r
155 -in primary_mail or other_email in the .notmuch-config file) in the
\r
156 +in primary_mail or other_email in the .notmuch/config file) in the
\r
159 It also builds a suitable new subject, including Re: at the front (if
\r
160 diff --git a/notmuch.c b/notmuch.c
\r
161 index 5cc8e4c..2d19a91 100644
\r
164 @@ -98,7 +98,7 @@ command_t commands[] = {
\r
165 "\t\tThe setup command will prompt for your full name, your primary\n"
\r
166 "\t\temail address, any alternate email addresses you use, and the\n"
\r
167 "\t\tdirectory containing your email archives. Your answers will be\n"
\r
168 - "\t\twritten to a configuration file in ${HOME}/.notmuch-config .\n"
\r
169 + "\t\twritten to a configuration file in ${HOME}/.notmuch/config .\n"
\r
171 "\t\tThis configuration file will be created with descriptive\n"
\r
172 "\t\tcomments, making it easy to edit by hand later to change the\n"
\r