unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: Erik Rybakken <erik.rybakken@math.ntnu.no>
Cc: Jani Nikula <jani@nikula.org>,
	notmuch@notmuchmail.org, David Bremner <david@tethera.net>
Subject: Re: [PATCH] Add option `hooks.path` for setting the directory of hooks.
Date: Tue, 30 Aug 2016 20:51:27 +0300	[thread overview]
Message-ID: <m2twe2ywkg.fsf@guru.guru-group.fi> (raw)
In-Reply-To: <m237lmcrbi.fsf@guru.guru-group.fi>

On Tue, Aug 30 2016, Tomi Ollila <tomi.ollila@iki.fi> wrote:

> On Tue, Aug 30 2016, Tomi Ollila <tomi.ollila@iki.fi> wrote:
>
>> On Sat, Aug 27 2016, Erik Rybakken <erik.rybakken@math.ntnu.no> wrote:
>>
>>> Hi,
>>>
>>> Thanks Tomi and David for the feedback!
>>>
>>> On Fri, Aug 26, 2016 at 02:32:19PM +0300, Tomi Ollila wrote:
>>>
>>>> ... but I can think of one problem there (if my memory server correctly)
>>>
>>> Yeah, I didn't think of that. I have been thinking about how to make the
>>> generated configuration show only the options that differ from the
>>> default, and have the default options commented out, but it got a bit too
>>> involved for me.
>>>
>>> However, I think I have another solution, and I included a updated patch
>>> for this. There is only one (*) difference from the first patch:
>>>
>>> When reading the configuration file and "hooks.path" is either unset or
>>> set to an empty string, we set config->hooks_path to be the expanded
>>> path "database.path/.notmuch/hooks", but we set the value of hooks.path in
>>> config->key_file to be an empty string. That way, when calling
>>> "notmuch_config_get_hooks_path", the expanded path gets returned, but when
>>> saving the config file, either from "notmuch setup" or "notmuch config set",
>>> the value will still be an empty string, given that it wasn't changed.
>>>
>>> I believe this is the easiest fix, and if this sounds good, I will start
>>> working on the tests.
>>
>> I kinda like how this would work...
>>
>> The code looked pretty good -- when did I git am to the email content
>> I got all from the beginning of this email to the commit message --
>> so before next patches use git-format-patch and git-am... Check
>>
>> https://notmuchmail.org/contributing/ for more information...
>>
>> 2 things that came up after quick view
>>
>> 2) I wonder whether calling notmuch_config_get_hooks_path() could
>> be "lazier".... ARGH no :( -- it would make notmuch_config_get_hooks_path()
>> have different code than others and ... (**)
>
> That said, perhaps 
>
> const char *
> notmuch_config_get_hooks_path (notmuch_config_t *config)
> {
>      const char * hooks_path =
>          _config_get (config, &config->hooks_path, "hooks", "path");
>      if (hooks_path == NULL || hooks_path[0] == '\0') {
>         hooks_path = talloc_asprintf (config, "%s/.notmuch/hooks",
>                                       notmuch_config_get_database_path (config));
>         _config_set(config, &config->hooks_path, "hooks", "path", hooks_path);
>      }
>      return hooks_path;
> }
>
> But, it takes quite a bit of careful examination to check whether that works
> as expected, and I always think whether some accidental fragileness there
> causes that stored value to be dumped to the configuration file (now, or
> in later changes).

I forgot that this risk can be mitigated by a set of suitable tests...

>
> But, the above may be useless crap -- just I don't have more time to check
> that out now...

      reply	other threads:[~2016-08-30 17:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24 16:30 Feature request: Finer control of paths Erik Rybakken
2016-08-24 17:45 ` Jani Nikula
2016-08-24 21:55   ` [PATCH] Add option `hooks.path` for setting the directory of hooks Erik Rybakken
2016-08-26 10:57     ` David Bremner
2016-08-26 11:32     ` Tomi Ollila
2016-08-27 13:28       ` Erik Rybakken
2016-08-30  5:43         ` Tomi Ollila
2016-08-30  8:49           ` Erik Rybakken
2016-08-30 11:43             ` David Bremner
2016-08-30 13:35           ` Tomi Ollila
2016-08-30 17:51             ` Tomi Ollila [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2twe2ywkg.fsf@guru.guru-group.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=erik.rybakken@math.ntnu.no \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).