unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* setting NOTMUCH_CONFIG in hooks
@ 2020-06-03  6:24 Uwe Kleine-König
  2020-06-03 14:12 ` David Bremner
  2021-04-27 12:34 ` David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2020-06-03  6:24 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1.1: Type: text/plain, Size: 415 bytes --]

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


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting NOTMUCH_CONFIG in hooks
  2020-06-03  6:24 setting NOTMUCH_CONFIG in hooks Uwe Kleine-König
@ 2020-06-03 14:12 ` David Bremner
  2021-04-27 12:34 ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2020-06-03 14:12 UTC (permalink / raw)
  To: Uwe Kleine-König, notmuch

Uwe Kleine-König <uwe@kleine-koenig.org> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting NOTMUCH_CONFIG in hooks
  2020-06-03  6:24 setting NOTMUCH_CONFIG in hooks Uwe Kleine-König
  2020-06-03 14:12 ` David Bremner
@ 2021-04-27 12:34 ` David Bremner
  2021-04-27 13:03   ` Michael J Gruber
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2021-04-27 12:34 UTC (permalink / raw)
  To: Uwe Kleine-König, notmuch

Uwe Kleine-König <uwe@kleine-koenig.org> 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.\r

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting NOTMUCH_CONFIG in hooks
  2021-04-27 12:34 ` David Bremner
@ 2021-04-27 13:03   ` Michael J Gruber
  2021-08-28 14:49     ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Michael J Gruber @ 2021-04-27 13:03 UTC (permalink / raw)
  To: David Bremner, Uwe Kleine-König, notmuch

David Bremner venit, vidit, dixit 2021-04-27 14:34:30:
> Uwe Kleine-König <uwe@kleine-koenig.org> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: setting NOTMUCH_CONFIG in hooks
  2021-04-27 13:03   ` Michael J Gruber
@ 2021-08-28 14:49     ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2021-08-28 14:49 UTC (permalink / raw)
  To: Michael J Gruber, Uwe Kleine-König, notmuch

Michael J Gruber <git@grubix.eu> writes:

>
> 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.
>

The --config argument is pretty useful (for me) when debugging, so I
don't support its removal (at least that's what we usually mean by
deprecation, a precursor to removal).

Until someone (TM) is inspired to work through what variables to
propagate, and how to populate them (whether it suffices just to
preserve the environment, or whether values have to be synthesised), we
could certainly update the docs for --config to direct people to use
environment vars if they need propagation.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-28 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  6:24 setting NOTMUCH_CONFIG in hooks Uwe Kleine-König
2020-06-03 14:12 ` David Bremner
2021-04-27 12:34 ` David Bremner
2021-04-27 13:03   ` Michael J Gruber
2021-08-28 14:49     ` David Bremner

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).