Allow my_var assignments to reference the $my_var in the value.
This is important for MuttLisp, where the current value could be used
to determine the new assignment.
Fix MuttLisp extract_token() call to remove trailing whitespace.
MoreArgs() doesn't look for whitespace, and so assumes
mutt_extract_token() will remove trailing whitespace too.
Add first version of MuttLisp.
This is somewhat simple enhancement to muttrc processing, not a
full-blown embedded scripting language. There are no variables,
functions, types, or abilities that compete with macros.
MuttLisp can be invoked using the "run" command. If
$muttlisp_inline_eval is set, it can also be invoked with a bare
parenthesis expression as a command argument.
$muttlisp_inline_eval defaults unset, to avoid breaking existing
configurations, which might have bare parenthesis arguments for
Ensure a blackslash inside backquotes doesn't skip past eos.
I'm not sure if this is possible because of the way the input is read
by the muttrc parser, but fix the logic to ensure it can't happen.
Disable hook "command" argument expansion of config variables.
From my email to mutt-dev:
I've been thinking about this a *lot* more, and digging into past
commits. It looks like the escaping has pretty consistently been
intended for value completion and queries. See commits 3c00eb7a and
I don't believe the escaping is useful for variable expansion as
part of mutt_extract_token() - even for the hook "command" argument
case. The escaping is targeted only for an expression surrounded by
double quotes (as is generated by completion and queries). It
doesn't escape single quotes or spaces, for instance.
Thanks also to Oswald Buddenhagen and Cameron Simpson for their
Escape config vars when expanding hook "command" argument.
The "command" parameter of folder, send, send2, account, reply, and
message hooks is run through mutt_extract_token() twice. Once when
parsing the hook command initially, and once via mutt_parse_rc_line()
when the actual hook fires.
In theory, Mutt users should be aware of this, and should place all
their command strings with configuration variables in single-quotes,
to delay expansion until execution.
But in reality Mutt has been escaping configuration variables as part
of mutt_extract_token() for many years.
The previous commit turned the escaping off, because it damages
"backup" assignments to a $my_ variable, and I believe is confusing
But for hooks, users now expect the escaping behavior (for
double-quoted or unquoted command strings).
Note that mutt_parse_hook() also passed the MUTT_TOKEN_SPACE flag, but
neglected to do so for message-hook. Since all other "command"
argument hooks were included, and were added to the list over the
years, I believe this was an accidental oversight.
Convert var_to_string() to use a buffer, and disable auto-escaping.
Inside mutt_extract_token(), expanding a configuration variable used a
fixed size LONG_STRING. This would truncate long values, such as
oauth_refresh, which may have a large token embedded in them.
Convert var_to_string() to use a BUFFER parameter instead.
var_to_string() also performed escaping, which is not always helpful.
Disable the escaping inside. Add it back in
mutt_var_value_complete(), via the pretty_var() call.
The escaping may also be useful for hook "command" parameters. Since
Mutt has had the escaping behavior there for years, removing it will
likely break configurations. This will be added back in the next
Allow tagging string config vars as L10N.
Translate them once in mutt_set_default().
Modify makedoc.pl to remove the N_() tag, and to also note the type as
The makedoc.pl already will ignore L10N comment so add a basic comment
above each config var in init.h.
I'm not tagging $crypt_protected_headers_subject because the spec now
says this should be "...". I plan on implementing that change along
with other fixes before the next release.
Fix buffer pool buffer truncation with my_hdr and score commands.
The buffer pool is now used for command invocation, but unfortunately
a couple cases of mutt_buffer_init() were hidden in the my_hdr and
score command processors.
This would result in a shortened buffer being returned to the pool and
used later for something like the prompt - which expects LONG_STRING
Fix up the two places to instead copy the string over. They don't
need to grab a large buffer pool sized hunk of memory.
Also, fix the mutt_buffer_pool_release() to resize upwards in case
future code does this. I should have done this originally, but was
afraid it would paper over more serious issues. :-/
Thanks to Armin Wolfermann for reporting the problem.
Add cd command to change the current working directory.
Original Author: Christoph Berg <email@example.com>
Use cases are saving attachments to some other place and others.
Modified by Kevin McCarthy:
- Fix up documentation to use cmdsynopsis/command/arg.
- Add muttrc.man entry.
- Fix compilation error.
- Clean up the parse_cd() function to use buffers and remove new
Add "root" disposition to attachments command.
An initial inline part was previously always skipped, for the good
reasons outlined by @dgc in #217.
Unfortunately, some mail clients have started sending "attachments" as
the root (and only) part, more and more lately. Although this may be
bad practice, Mutt should support counting these as "attachments".
To do so without breaking existing configs, add a "root" disposition
argument to the attachments command. This will count an initial
inline part in a message or multipart container.
The existing code skipped counting for the "top-level" and recursive
calls, so group both of these cases under "root".
Convert mutt_init() to use buffer pool for path operations.
Convert getdnsdomainname(), called by mutt_init(), to accept a BUFFER
Fix backtick processing to append to tok instead of allocating and
assigning to tok->data directly.
Convert mutt_parse_rc_line() to use real buffer to hold the line.
Previously, the parameter converted into a kind of read-only buffer,
pointing to the char *line passed in. The problem is that
mutt_extract_token() backtick processing allocates and assigns a new
As a result, buffer->destroy was added, whose sole purpose is to keep
track of the read-only token buffer being reallocated so that it can
be properly freed inside mutt_parse_rc_line(). (The char *line is
allocated and freed in source_rc()).
Remove the token parameter, and convert line to a const char *. Copy
that into a buffer-pool buffer, so the buffer can be modified
Create a mutt_buffer_rc_buffer() function taking the line buffer
parameter. To make the source_rc() just a tiny bit faster, have it
directly manage and call mutt_parse_rc_buffer() itself.
Other callers likely don't need the speed, so remove their cumbersome
creation/free of that parameter.
The next commit will deal with removing buffer->destroy and fixing up
Add $fcc_delimiter, to allow multiple Fcc mailboxes.
The variable defaults unset, to prevent breaking anyone's
If set to a value, such as ",", $record and fcc-hook may list multiple
mailboxes separated by the delimiter. Mutt will tokenize and
expand/prettify each separate mailbox. At Fcc time, it will loop
through trying to save to each mailbox.
This patch introduces a bit more uglyness into init.c, which has to
special-process for $record in a few places. I don't like that, but I
believe the feature is important enough to allow for the one-off
behavior hack, because we are constrained by backwards compatibility.
Add documentation notes about the resulting issues with '<' mailbox
shortcut expansion, and with fcc-save-hook processing. It is
recommended to use fcc-hook to set multiple mailboxes in those cases
Convert start_debug() to use buffer pool.
Convert set/reset and source_rc to use buffers for paths.
Convert parse_path_(un)list to use buffer pool for path.
Don't use the buf parameter to avoid stretching it out, as it's used
for the entire rc parsing, and typically just holds command names.
Added * option to unattachments command
The * option clears all previous attachments settings. A
list_free_generic method is added to muttlib to enable generic freeing
of specific LIST structures. free_attachments_data is used with
list_free_generic to clear four LISTs which manage allowed and excluded
inline and attached "attachments"