[neomutt-devel] Types for everything

Richard Russon rich at flatcap.org
Sat Aug 4 12:42:22 CEST 2018


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.

Expanding '+mailbox' using '$folder' will be a problem, but with
account-specific config (coming soon), this problem may disappear.

Questions, thoughts?

Cheers,
    Rich / FlatCap
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20180804/7be936ca/attachment.sig>


More information about the neomutt-devel mailing list