[neomutt-devel] Types for everything

Stefan Kropp stefan at debxwoody.de
Tue Aug 7 07:47:20 CEST 2018


Am Samstag, den 04.08.2018 um 11:42:22 +0100 schrieb rich at flatcap.org:
> NeoMutt's config comes in a variety of types, most of which are simple.
> There are two that are tricky, so I'm going to add a new one to clear
> things up.
> 
> # DT_PATH - Filesystem path
> 
> This represents a file or directory.
> The path may be relative and have elements that need expanding, e.g.
> 
> - '~/' or '~user/'
> - '$conf' NeoMutt config variables
> - '$ENV' environment variables
> - '%x' Config-specific expandos
> - Relative path
> - 'cmd.sh|' external command
> - `cmd` external command
> 
> In which order should the be evaluated?
> 
> # DT_COMMAND - External command
> 
> This represents an external command and its arguments.
> 
> It may have elements that need expanding, e.g.
> 
> - '~/' or '~user/'
> - '$conf' NeoMutt config variables
> - '$ENV' environment variables
> - '%x' Config-specific expandos
> 
> Currently, this is stored as a string, but it may be a better idea to
> store the elements as a list.  If it were a list, it would be easier for
> the code to perform expansions on each element individually.  They could
> be escaped and concatenated just before executing the command.
> 
> # DT_MAILBOX - Mailbox
> 
> This is the missing type.  It would be used for:
> - folder
> - mbox
> - postponed
> - record
> - spoolfile
> - trash
> 
> Currently, the path expansion code also looks for leading '+' or '^'
> characters, etc, to perform mailbox expansion.  This bloats the code and
> creates a lot of dependencies.
> 
> The "mailbox" type would be a string (opaque to NeoMutt).  We would add some new
> functions to the Mailbox API.  Candidates are:
> 
> - probe()
>   Does this backend understand this mailbox path
>   (move the logic from mx.c into the backend)
> 
> - canonical()
>   Create the canonical path for this mailbox
> 
> - pretty()
>   Abbreviate the path, relative to "$folder"
> 
> - parent()
>   Get the parent of a nested folder
> 
> - children()
>   Get the children of a folder
> 
> - exists()
>   Does this mailbox path exist?
> 
> For some mailbox backends, a DT_MAILBOX would actually be a DT_PATH, but that
> distinction should be hidden from NeoMutt.
> 
> # Evaluation Time
> 
> The final questions concern who evaluates these config items and when.
> 
> Currently, most config items are expanded when they are set, "~/dir" will be
> stored as "/home/user/dir".  In many cases it doesn't matter.  But...
> 
> I _think_ that the config system shouldn't be doing the expansions, just storing
> the text exactly.  Later, the code would expand the variables at time-of-use.

Is it possible to have an own syntax to make sure that it
will be expanded at time-of-use? Just an example

 * `cmd` - when the variable is set
 * ``cmd`` - when the variable is used

Maybe we should try to finde some use cases to check which
is the "best" solution. The only risk I see on
'time-of-use', the user doesn't have the control to decide
when it will be executed.

Will it be just for filesystem path or are there changes on
hooks, etc as well?

To be honest, I don't use this a lot. What will happen, when
I have an save-hook like `date +'%Y-%m`.

> Expanding '+mailbox' using '$folder' will be a problem, but with
> account-specific config (coming soon), this problem may disappear.
> 
> Questions, thoughts?
> 
> Cheers,
>     Rich / FlatCap



-- 
Mit freundlichen Grüßen,
Stefan
Virtuelle Linux User Group
http://www.devlug.de
Linux User #277252
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <http://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20180807/f2efafdc/attachment.sig>


More information about the neomutt-devel mailing list