setting NOTMUCH_CONFIG in hooks

classic Classic list List threaded Threaded
4 messages Options
Uwe Kleine-König-2 Uwe Kleine-König-2
Reply | Threaded
Open this post in threaded view
|

setting NOTMUCH_CONFIG in hooks

Hello,

when I run

        notmuch --config=$HOME/.notmuch-config-work new

NOTMUCH_CONFIG isn't set when the hooks are running. This would however
be quite useful such that e.g. afew uses the right database. Of course I
could do

        NOTMUCH_CONFIG=$HOME/.notmuch-config-work notmuch new

instead, but then it would be consequent to drop the --config option
from notmuch completely :-)

Best regards
Uwe


_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch

signature.asc (499 bytes) Download Attachment
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: setting NOTMUCH_CONFIG in hooks

Uwe Kleine-König <[hidden email]> writes:

> Hello,
>
> when I run
>
> notmuch --config=$HOME/.notmuch-config-work new
>
> NOTMUCH_CONFIG isn't set when the hooks are running. This would however
> be quite useful such that e.g. afew uses the right database. Of course I
> could do
>
> NOTMUCH_CONFIG=$HOME/.notmuch-config-work notmuch new
>
> instead, but then it would be consequent to drop the --config option
> from notmuch completely :-)

Not really opposed, but it does seem like a wishlist item to me.

Two comments

1) I have planned for some weeks now to tear open the config handling,
which might affect this.

2) It would make sense to define an explicit set of environment
variables preserved or reset in hook environment at the same time as
this proposed change.

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: setting NOTMUCH_CONFIG in hooks

In reply to this post by Uwe Kleine-König-2
Uwe Kleine-König <[hidden email]> writes:

> Hello,
>
> when I run
>
> notmuch --config=$HOME/.notmuch-config-work new
>
> NOTMUCH_CONFIG isn't set when the hooks are running. This would however
> be quite useful such that e.g. afew uses the right database. Of course I
> could do
>
> NOTMUCH_CONFIG=$HOME/.notmuch-config-work notmuch new
>
> instead, but then it would be consequent to drop the --config option
> from notmuch completely :-)
>

It's not the same thing, but seems to relate to your use case. There is
some new and mostly untested support for a "NOTMUCH_PROFILE" environment
variable that might help. Or it might have the same issue with
propagation to hooks. See notmuch-config(1) in master / 0.32~rc1.
_______________________________________________
notmuch mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]
Michael J Gruber Michael J Gruber
Reply | Threaded
Open this post in threaded view
|

Re: setting NOTMUCH_CONFIG in hooks

David Bremner venit, vidit, dixit 2021-04-27 14:34:30:

> Uwe Kleine-König <[hidden email]> writes:
>
> > Hello,
> >
> > when I run
> >
> >       notmuch --config=$HOME/.notmuch-config-work new
> >
> > NOTMUCH_CONFIG isn't set when the hooks are running. This would however
> > be quite useful such that e.g. afew uses the right database. Of course I
> > could do
> >
> >       NOTMUCH_CONFIG=$HOME/.notmuch-config-work notmuch new
> >
> > instead, but then it would be consequent to drop the --config option
> > from notmuch completely :-)
> >
>
> It's not the same thing, but seems to relate to your use case. There is
> some new and mostly untested support for a "NOTMUCH_PROFILE" environment
> variable that might help. Or it might have the same issue with
> propagation to hooks. See notmuch-config(1) in master / 0.32~rc1.

Note that a typical use case for a post hook is `notmuch tag` (not just
in the disguise of `afew`), and it is essential that it runs against the
same db and config as the notmuch which is calling the hook.

So, either notmuch should export `NOTMUCH_CONFIG` into the environment
which it runs the hooks in (if overriden by `--config`), or, as Uwe
suggests, and in the light of other variables like `NOTMUCH_PROFILE`,
`--config` could be deprecated so that users automatically do "the right
thing". Seems to be more future proof.

Regards
Michael
_______________________________________________
notmuch mailing list -- [hidden email]
To unsubscribe send an email to [hidden email]