notmuch-emacs: Fcc to top-level directory given by database.path

classic Classic list List threaded Threaded
13 messages Options
Arun Isaac Arun Isaac
Reply | Threaded
Open this post in threaded view
|

notmuch-emacs: Fcc to top-level directory given by database.path


I am using notmuch-emacs, and I would like to Fcc my sent mail to the
top-level directory given by database.path, instead of using a folder
like "sent" relative to the top-level directory.

The function `notmuch-maildir-notmuch-insert-current-buffer' in
notmuch-maildir-fcc.el calls `notmuch insert' with the `--folder='
argument. I would like it to not do this.

For my immediate purposes, I have overridden
`notmuch-maildir-notmuch-insert-current-buffer' with the following
advice. But, it would be nice if this feature existed out of the box.

(define-advice notmuch-maildir-notmuch-insert-current-buffer
      (:override (folder &optional create tags)
                 insert-into-root)
    (apply 'notmuch-call-notmuch-process
           :stdin-string (buffer-string)
           "insert" tags))
_______________________________________________
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: notmuch-emacs: Fcc to top-level directory given by database.path

Arun Isaac <[hidden email]> writes:

> I am using notmuch-emacs, and I would like to Fcc my sent mail to the
> top-level directory given by database.path, instead of using a folder
> like "sent" relative to the top-level directory.
>
> The function `notmuch-maildir-notmuch-insert-current-buffer' in
> notmuch-maildir-fcc.el calls `notmuch insert' with the `--folder='
> argument. I would like it to not do this.

Do you happen to know if it calls with an empty string as the folder
name? It would be consistent with searching for that to insert at the
top level.

In any case I've noted your feature request/bug-report. It doesn't sound
terribly difficult to change, but it will need someone motivated to
think about all of the related details like updating the test suite and
changing docstrings.

d


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

Re: notmuch-emacs: Fcc to top-level directory given by database.path


On Sat, 23 Sep 2017, David Bremner <[hidden email]> wrote:

> Arun Isaac <[hidden email]> writes:
>
>> I am using notmuch-emacs, and I would like to Fcc my sent mail to the
>> top-level directory given by database.path, instead of using a folder
>> like "sent" relative to the top-level directory.
>>
>> The function `notmuch-maildir-notmuch-insert-current-buffer' in
>> notmuch-maildir-fcc.el calls `notmuch insert' with the `--folder='
>> argument. I would like it to not do this.
>
> Do you happen to know if it calls with an empty string as the folder
> name? It would be consistent with searching for that to insert at the
> top level.
>
> In any case I've noted your feature request/bug-report. It doesn't sound
> terribly difficult to change, but it will need someone motivated to
> think about all of the related details like updating the test suite and
> changing docstrings.

Alternatively, does just using / as the folder work?

Best wishes

Mark

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

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by David Bremner-2

Mark Walters <[hidden email]> writes:

> Alternatively, does just using / as the folder work?

notmuch complains about absolute paths if / is used as the folder. Look
at function `notmuch-maildir-add-notmuch-insert-style-fcc-header' in
notmuch-maildir-fcc.el.

David Bremner <[hidden email]> writes:

> Do you happen to know if it calls with an empty string as the folder
> name? It would be consistent with searching for that to insert at the
> top level.

Setting notmuch-fcc-dirs to "\"\"" fails, if that's what you are asking.

I also tried "." as the folder. This works, but if I search using
`notmuch search --output=files ...', the filename is of the form
"database.path/./cur/some.mail.file". This is not so clean.

> In any case I've noted your feature request/bug-report. It doesn't sound
> terribly difficult to change, but it will need someone motivated to
> think about all of the related details like updating the test suite and
> changing docstrings.

I can contribute this patch. Shall I make it such that if the folder
part of `notmuch-fcc-dirs' is an empty string, then `notmuch insert' is
called without a `--folder=' argument?
_______________________________________________
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: notmuch-emacs: Fcc to top-level directory given by database.path

Arun Isaac <[hidden email]> writes:

>> In any case I've noted your feature request/bug-report. It doesn't sound
>> terribly difficult to change, but it will need someone motivated to
>> think about all of the related details like updating the test suite and
>> changing docstrings.
>
> I can contribute this patch. Shall I make it such that if the folder
> part of `notmuch-fcc-dirs' is an empty string, then `notmuch insert' is
> called without a `--folder=' argument?

Sounds reasonable to me. Any objections Mark?

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

Re: notmuch-emacs: Fcc to top-level directory given by database.path

On Sun, Sep 24 2017, David Bremner wrote:

> Arun Isaac <[hidden email]> writes:
>
>>> In any case I've noted your feature request/bug-report. It doesn't sound
>>> terribly difficult to change, but it will need someone motivated to
>>> think about all of the related details like updating the test suite and
>>> changing docstrings.
>>
>> I can contribute this patch. Shall I make it such that if the folder
>> part of `notmuch-fcc-dirs' is an empty string, then `notmuch insert' is
>> called without a `--folder=' argument?
>
> Sounds reasonable to me. Any objections Mark?

Will the eventual fate of the --folder argument be decided based on the

Fcc:

header string in Message[Notmuch] mode: buffer ?

i.e. if it is empty, then call notmuch insert w/o --folder argument,
and is absent, don't do fcc  (and e.g. './' would save directly...?)

> d

Tomi
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by David Bremner-2
On Sun, 24 Sep 2017, David Bremner <[hidden email]> wrote:

> Arun Isaac <[hidden email]> writes:
>
>>> In any case I've noted your feature request/bug-report. It doesn't sound
>>> terribly difficult to change, but it will need someone motivated to
>>> think about all of the related details like updating the test suite and
>>> changing docstrings.
>>
>> I can contribute this patch. Shall I make it such that if the folder
>> part of `notmuch-fcc-dirs' is an empty string, then `notmuch insert' is
>> called without a `--folder=' argument?
>
> Sounds reasonable to me. Any objections Mark?

I am not sure: do we want an empty Fcc header to save the message to the
root folder? (At the moment the insert fails for an empty Fcc header
which isn't good either) In general though are suggesting Fcc header
lines of the form

""

or

"" +sent

save to the root folder?

Apart from the empty header case that sounds fine. I am not sure about
the documentation for it -- the variable is already a little
complicated, so I wouldn't want to clutter it further.

Incidentally, I think "/" is an alternative for the fcc line which
already works, which is "\"/\" in notmuch-fcc-dirs.

Best wishes

Mark



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

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by David Bremner-2
On Sat, 23 Sep 2017, David Bremner <[hidden email]> wrote:
> Do you happen to know if it calls with an empty string as the folder
> name? It would be consistent with searching for that to insert at the
> top level.

notmuch insert --folder= or --folder="" does not work:

String argument for option "folder" must be non-empty.
Unrecognized option: --folder=

It seems that our argument parser doesn't accept empty strings at all,
which is a bit of a limitation. It would be logical for the empty string
to work here, and AFAICT the notmuch insert code would handle this if
the argument was let through the parsing.

BR,
Jani.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Arun Isaac Arun Isaac
Reply | Threaded
Open this post in threaded view
|

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by Mark Walters
Mark Walters <[hidden email]> writes:

> Incidentally, I think "/" is an alternative for the fcc line which
> already works, which is "\"/\" in notmuch-fcc-dirs.

Perhaps, notmuch should be made to tolerate a "/" at the beginning of the
Fcc folder argument. That is, notmuch should not complain about absolute
paths, and it should interpret these as relative to the root. To
maintain backward compatibility, we could add a "/" at the beginning if
it is not already there.

So,

"/" => database.path
"/sent" => database.path/sent
"sent" => database.path/sent

etc.

Is this a better idea?
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

Re: notmuch-emacs: Fcc to top-level directory given by database.path


Hi

On Sun, 01 Oct 2017, Arun Isaac <[hidden email]> wrote:

> Mark Walters <[hidden email]> writes:
>
>> Incidentally, I think "/" is an alternative for the fcc line which
>> already works, which is "\"/\" in notmuch-fcc-dirs.
>
> Perhaps, notmuch should be made to tolerate a "/" at the beginning of the
> Fcc folder argument. That is, notmuch should not complain about absolute
> paths, and it should interpret these as relative to the root. To
> maintain backward compatibility, we could add a "/" at the beginning if
> it is not already there.
>
> So,
>
> "/" => database.path
> "/sent" => database.path/sent
> "sent" => database.path/sent
>
> etc.
>
> Is this a better idea?

The reason for the warning is that this behaviour is completely
different from what you would get with normal file fcc. Given that, I am
a little reluctant to drop the warning.

Best wishes

Mark

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

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by Arun Isaac
On Mon, 02 Oct 2017, Arun Isaac <[hidden email]> wrote:

> Mark Walters <[hidden email]> writes:
>
>> Incidentally, I think "/" is an alternative for the fcc line which
>> already works, which is "\"/\" in notmuch-fcc-dirs.
>
> Perhaps, notmuch should be made to tolerate a "/" at the beginning of the
> Fcc folder argument. That is, notmuch should not complain about absolute
> paths, and it should interpret these as relative to the root. To
> maintain backward compatibility, we could add a "/" at the beginning if
> it is not already there.
>
> So,
>
> "/" => database.path
> "/sent" => database.path/sent
> "sent" => database.path/sent
>
> etc.
>
> Is this a better idea?

At the cli notmuch insert level, I'd actually rather do the opposite and
be even stricter about folder being relative. I just had to look at the
code for other reasons, and it seems to accept all sorts of weird combos
with "/" and "." that I think should be rejected. Or at the very least
sanitized. Otherwise we end up with filenames with "//" or "/./" in
them, probably confusing notmuch later on.

I'd argue notmuch insert --folder="" should Fcc to the mail store root,
but alas that doesn't work at the cli level. It doesn't appear to work
at the emacs level either, but perhaps notmuch-emacs could translate ""
to dropping the --folder argument? Could even add that as a choice
option in notmuch-fcc-dirs customization. Mark?

BR,
Jani.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Jani Nikula Jani Nikula
Reply | Threaded
Open this post in threaded view
|

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by Jani Nikula
On Sat, 30 Sep 2017, Jani Nikula <[hidden email]> wrote:

> On Sat, 23 Sep 2017, David Bremner <[hidden email]> wrote:
>> Do you happen to know if it calls with an empty string as the folder
>> name? It would be consistent with searching for that to insert at the
>> top level.
>
> notmuch insert --folder= or --folder="" does not work:
>
> String argument for option "folder" must be non-empty.
> Unrecognized option: --folder=
>
> It seems that our argument parser doesn't accept empty strings at all,
> which is a bit of a limitation. It would be logical for the empty string
> to work here, and AFAICT the notmuch insert code would handle this if
> the argument was let through the parsing.

Turns out this is trivial to address on top of the arg parsing series:
id:[hidden email].

BR,
Jani.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Arun Isaac Arun Isaac
Reply | Threaded
Open this post in threaded view
|

Re: notmuch-emacs: Fcc to top-level directory given by database.path

In reply to this post by Jani Nikula
Jani Nikula <[hidden email]> writes:

> On Sat, 23 Sep 2017, David Bremner <[hidden email]> wrote:
>> Do you happen to know if it calls with an empty string as the folder
>> name? It would be consistent with searching for that to insert at the
>> top level.
>
> notmuch insert --folder= or --folder="" does not work:
>
> String argument for option "folder" must be non-empty.
> Unrecognized option: --folder=
>
> It seems that our argument parser doesn't accept empty strings at all,
> which is a bit of a limitation. It would be logical for the empty string
> to work here, and AFAICT the notmuch insert code would handle this if
> the argument was let through the parsing.

I agree. Fixing this in the `notmuch insert' argument parser is a better
solution.
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch