Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1487D431FBC for ; Sun, 22 Nov 2009 14:15:09 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id boAmWp69TsEK for ; Sun, 22 Nov 2009 14:15:08 -0800 (PST) Received: from tarap.cc.columbia.edu (tarap.cc.columbia.edu [128.59.29.7]) by olra.theworths.org (Postfix) with ESMTP id 1D685431FAE for ; Sun, 22 Nov 2009 14:15:08 -0800 (PST) Received: from servo.finestructure.net (cpe-72-227-128-66.nyc.res.rr.com [72.227.128.66]) (user=jgr2110 author=jrollins@finestructure.net mech=PLAIN bits=0) by tarap.cc.columbia.edu (8.14.3/8.14.3) with ESMTP id nAMMF75B011840 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 22 Nov 2009 17:15:07 -0500 (EST) Received: from jrollins by servo.finestructure.net with local (Exim 4.69) (envelope-from ) id 1NCKiJ-0004jG-5H for notmuch@notmuchmail.org; Sun, 22 Nov 2009 17:15:23 -0500 Date: Sun, 22 Nov 2009 17:15:23 -0500 From: Jameson Graef Rollins To: notmuch@notmuchmail.org Message-ID: <20091122221523.GA8703@finestructure.net> References: <1258927116-528-1-git-send-email-jrollins@finestructure.net> <1258927116-528-2-git-send-email-jrollins@finestructure.net> <1258927116-528-3-git-send-email-jrollins@finestructure.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="uAKRQypu60I7Lcqm" Content-Disposition: inline In-Reply-To: <1258927116-528-3-git-send-email-jrollins@finestructure.net> User-Agent: Mutt/1.5.20 (2009-06-14) X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.65 on 128.59.29.7 Subject: Re: [notmuch] [PATCH 3/3] change config file location to be ~/.notmuch/config X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Nov 2009 22:15:09 -0000 --uAKRQypu60I7Lcqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, folks. I wanted to comment on this patch request. I personally think it makes a lot of sense to use config directories. This makes things much neater, since all config files can be kept in one place without clutter the config name space. I can imagine down the line that there may be more notmuch config files, and it would be nicer to have a config directory rather than a bunch of ~/.notmuch-* files in the user dot file config space. I also imagine this config directory as a place to store the notmuch database files. I would rather keep all the notmuch data and config files together in one place, and keep my mail directories completely untouched (only read) by notmuch, if possible. I realize, however, there is a transition problem associated with moving the config file, which is why I propose it be moved sooner rather than later. If folks are interested in this change, and are worried about transition even at this early stage, we can try to come up with some smoother transition code. Finally, I am (maybe clearly) *not* particularly adept at c programming. I'm still learning. I think I already have better ways to improve this patch. I will try to make some improvements and send those along as well. jamie. PS. I'm sure this has already been discussed on the list, but if this is not the best way to send patches, please let me know. I would be happy to send a pointer to my notmuch git repo if it would be preferable to just pull from it directly. On Sun, Nov 22, 2009 at 04:58:36PM -0500, Jameson Graef Rollins wrote: > This change creates a ~/.notmuch config directory where the config > file is stored when created with the "setup" command. The use of a > ~/.notmuch config directory creates one place where all notmuch config > files and data can be stored, which will greatly simplify managing > notmuch, and reduce cluter of user dot files. > --- > notmuch-config.c | 21 ++++++++++++++++++--- > notmuch-setup.c | 2 +- > notmuch.1 | 4 ++-- > notmuch.c | 2 +- > 4 files changed, 22 insertions(+), 7 deletions(-) >=20 > diff --git a/notmuch-config.c b/notmuch-config.c > index 7252a19..321c880 100644 > --- a/notmuch-config.c > +++ b/notmuch-config.c > @@ -22,9 +22,11 @@ > =20 > #include > #include > +#include > +#include > =20 > static const char toplevel_config_comment[] =3D > - " .notmuch-config - Configuration file for the notmuch mail system\n" > + " .notmuch/config - Configuration file for the notmuch mail system\n" > "\n" > " For more information about notmuch, see http://notmuchmail.org"; > =20 > @@ -134,7 +136,7 @@ get_username_from_passwd_file (void *ctx) > =20 > /* Open the named notmuch configuration file. A filename of NULL will > * be interpreted as the default configuration file > - * ($HOME/.notmuch-config). > + * ($HOME/.notmuch/config). > * > * If any error occurs, (out of memory, or a permission-denied error, > * etc.), this function will print a message to stderr and return > @@ -183,7 +185,7 @@ notmuch_config_open (void *ctx, > if (filename) > config->filename =3D talloc_strdup (config, filename); > else > - config->filename =3D talloc_asprintf (config, "%s/.notmuch-config", > + config->filename =3D talloc_asprintf (config, "%s/.notmuch/config", > getenv ("HOME")); > =20 > config->key_file =3D g_key_file_new (); > @@ -297,14 +299,27 @@ notmuch_config_save (notmuch_config_t *config) > { > size_t length; > char *data; > + char buf[256]; > GError *error =3D NULL; > =20 > + struct stat statbuf; > + > data =3D g_key_file_to_data (config->key_file, &length, NULL); > if (data =3D=3D NULL) { > fprintf (stderr, "Out of memory.\n"); > return 1; > } > =20 > + /* Create config directory if it doesn't already exist */ > + snprintf(buf, sizeof buf, "%s", config->filename); > + dirname(buf); > + if (stat(buf, &statbuf) < 0) { > + if (mkdir(buf, 0755) < 0) { > + fprintf (stderr, "Could not create directory '%s'\n.", buf); > + return 1; > + } > + } > + > if (! g_file_set_contents (config->filename, data, length, &error)) { > fprintf (stderr, "Error saving configuration to %s: %s\n", > config->filename, error->message); > diff --git a/notmuch-setup.c b/notmuch-setup.c > index 68788e1..76e104c 100644 > --- a/notmuch-setup.c > +++ b/notmuch-setup.c > @@ -74,7 +74,7 @@ welcome_message_post_setup (void) > { > printf ("\n" > "Notmuch is now configured, and the configuration settings are saved in\= n" > -"a file in your home directory named .notmuch-config . If you'd like to\= n" > +"a file in your home directory named .notmuch/config . If you'd like to\= n" > "change the configuration in the future, you can either edit that file\n" > "directly or run \"notmuch setup\".\n\n" > =20 > diff --git a/notmuch.1 b/notmuch.1 > index 8a3fb40..9ea1d42 100644 > --- a/notmuch.1 > +++ b/notmuch.1 > @@ -53,7 +53,7 @@ Interactively sets up notmuch for first use. > The setup command will prompt for your full name, your primary email > address, any alternate email addresses you use, and the directory > containing your email archives. Your answers will be written to a > -configuration file in ${HOME}/.notmuch-config . This configuration > +configuration file in ${HOME}/.notmuch/config . This configuration > file will be created with descriptive comments, making it easy to edit > by hand later to change the configuration. Or you can run > .B "notmuch setup" > @@ -245,7 +245,7 @@ takes an existing set of messages and constructs a su= itable mail > template. The Reply-to header (if any, otherwise From:) is used for > the To: address. Vales from the To: and Cc: headers are copied, but > not including any of the current user's email addresses (as configured > -in primary_mail or other_email in the .notmuch-config file) in the > +in primary_mail or other_email in the .notmuch/config file) in the > recipient list > =20 > It also builds a suitable new subject, including Re: at the front (if > diff --git a/notmuch.c b/notmuch.c > index 5cc8e4c..2d19a91 100644 > --- a/notmuch.c > +++ b/notmuch.c > @@ -98,7 +98,7 @@ command_t commands[] =3D { > "\t\tThe setup command will prompt for your full name, your primar= y\n" > "\t\temail address, any alternate email addresses you use, and the= \n" > "\t\tdirectory containing your email archives. Your answers will b= e\n" > - "\t\twritten to a configuration file in ${HOME}/.notmuch-config .\= n" > + "\t\twritten to a configuration file in ${HOME}/.notmuch/config .\= n" > "\n" > "\t\tThis configuration file will be created with descriptive\n" > "\t\tcomments, making it easy to edit by hand later to change the\= n" > --=20 > 1.6.5 >=20 --uAKRQypu60I7Lcqm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: attachment -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBCAAGBQJLCbf4AAoJEO00zqvie6q8gl4QAIUeXQmy6Eu4bc5+rV48Svuy OodWNGV4huvUQA3TM4DEBift95Pm6gcnULbvr7u7frwNXYcbn4DgFgWuze7QpBhD apBe7W90Mrkm6rCOU1z4TUbhHQpl1OTc/Yz9dK8HWSdZwB2EG15D1MwdCrVudrNd LSaZGoZZyhMoCH/ztgvCH9IGaqBCrIUZ6dutaa0IVb23DH0u44A8XqEHbBudQdGV OwrknJH8SAv2JiHq74goN+AtblLhMUdltoBZTr9bZJ/t50/s9syG2uEi1wTrqcfN /DAOmKk26WG2gI/IqSlcQSQodVO493OLNwkxNsPB2KuXf28m81kFiL4vVYgRPj6s 5V8mJGLXtfJvrYVUGBpDj0BeYODaXI0NpXZ6PgE3vIYLGF+zI2TDePvEcOpfn8ZF Gx/OOHWlty/2YReQqmYs4lVKA+JB5f+K7EaGyH2mbg6g/D2D9suWk5wpNbYBrxEp DpUBxQO5G70TqVwJJxBRDp9gDKjrU1Ug25xu45+LmEYbRlA90x9tQJezcJPTOY/F VU592vxaosYMfm+xl4YlX6V7d7SZbGhiYq2rGgwqR/5rTLwroq+4nIU1Y0jcyAwp dHGrJhJSfB9CjmPHrmWswM8SpA3Vzg80EgBFMWjjp87d9FJgPpT9vAfXZb2LZhhW pVdclc4G7qnZO3BoCgQI =8STB -----END PGP SIGNATURE----- --uAKRQypu60I7Lcqm--