[Joerg Jaspert] Bug#922536: notmuch-emacs: notmuch breaks on directory removal

Matt Armstrong marmstrong at google.com
Wed Feb 20 10:12:37 PST 2019

Tomi Ollila <tomi.ollila at iki.fi> writes:

> On Sun, Feb 17 2019, David Bremner wrote:
>> Seems like reasonable complaint. It should be possible to change to
>> the maildir root, but probably requires shelling out to notmuch
>> config get the value.
> Hmm. what does other emacs software do in that case ?
> Since OTOH I can think of a situation where I run emacs when located
> on a directory. from *scratch* buffer I launch notmuch-hello, then I
> press 'm' to compose new mail and c-x i (insert-file) ... Now I'd
> expect to be located on the same directory instead of my mail buffer
> is suddenly cd'd to totally different location (*)
> Tomi
> (*) that would be comparable annoying like my experience when using
>     ultimaker cura: have to run it with 
>     $ HOME=$PWD /path/to/cura $PWD/file.stl
>     to have it working as i'd expect software to locate input and
>     output directories/files (it sure never default to current dir)

I think David's original message was not specific about exactly how the
directory might be changed.  There are two separable questions here:

a) should notmuch-lib.el use whatever `default-directory' was in effect
when, say, M-x notmuch was run when running notmuch sub-commands
(i.e. when executing `call-process').

b) if (a) is "no", then in what way should `default-directory' be

I think (a) is probably "yes" -- it is possible to run M-x notmuch while
under any directory, but it makes little sense to run the notmuch
sub-commands from the same directory.

I think (b) has multiple answers.

1) The `default-directory' could be set to something predictable each
notmuch mode (hello, etc.).

2) The `default-directory' could be let-bound to something reasonable,
like (expand-file-name "~"), around each call to `call-proccess'.

3) Notmuch could limit option (2) to those cases where the current
diretory seems inaccessible.

I think (2) is probably the best option.

Emacs itself sets a bit of a precedent here.  If `default-directory' is
a remote file system (I suppose this is tramp?) then `call-process' runs
the command under "~" instead.

More information about the notmuch mailing list