Software: Apache. PHP/8.3.27 uname -a: Linux pdx1-shared-a4-04 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64 uid=6659440(dh_z2jmpm) gid=2086089(pg10499364) groups=2086089(pg10499364) Safe-mode: OFF (not secure) /usr/share/doc/mutt/html/ drwxr-xr-x | |
| Viewing file: Select action/file-type: Table of Contents
A “character set” is basically a mapping between bytes and glyphs and implies a certain character encoding scheme. For example, for the ISO 8859 family of character sets, an encoding of 8bit per character is used. For the Unicode character set, different character encodings may be used, UTF-8 being the most popular. In UTF-8, a character is represented using a variable number of bytes ranging from 1 to 4.
Since Mutt is a command-line tool run from a shell, and delegates
certain tasks to external tools (such as an editor for composing/editing
messages), all of these tools need to agree on a character set and
encoding. There exists no way to reliably deduce the character set a
plain text file has. Interoperability is gained by the use of
well-defined environment variables. The full set can be printed by
issuing
Upon startup, Mutt determines the character set on its own using
routines that inspect locale-specific environment variables. Therefore,
it is generally not necessary to set the If you happen to work with several character sets on a regular basis, it's highly advisable to use Unicode and an UTF-8 locale. Unicode can represent nearly all characters in a message at the same time. When not using a Unicode locale, it may happen that you receive messages with characters not representable in your locale. When displaying such a message, or replying to or forwarding it, information may get lost possibly rendering the message unusable (not only for you but also for the recipient, this breakage is not reversible as lost information cannot be guessed). A Unicode locale makes all conversions superfluous which eliminates the risk of conversion errors. It also eliminates potentially wrong expectations about the character set between Mutt and external programs. The terminal emulator used also must be properly configured for the current locale. Terminal emulators usually do not derive the locale from environment variables, they need to be configured separately. If the terminal is incorrectly configured, Mutt may display random and unexpected characters (question marks, octal codes, or just random glyphs), format strings may not work as expected, you may not be abled to enter non-ascii characters, and possible more. Data is always represented using bytes and so a correct setup is very important as to the machine, all character sets “look” the same.
Warning: A mismatch between what system and library functions think the
locale is and what Mutt was told what the locale is may make it behave
badly with non-ascii input: it will fail at seemingly random places.
This warning is to be taken seriously since not only local mail handling
may suffer: sent messages may carry wrong character set information the
receiver has too deal with. The need to set
A list of officially assigned and known character sets can be found at
IANA,
a list of locally supported locales can be obtained by running
All string patterns in Mutt including those in more complex patterns must be specified using regular expressions (regexp) in the “POSIX extended” syntax (which is more or less the syntax used by egrep and GNU awk). For your convenience, we have included below a brief description of this syntax. The search is case sensitive if the pattern contains at least one upper case letter, and case insensitive otherwise. Note“\” must be quoted if used for a regular expression in an initialization command: “\\”. A regular expression is a pattern that describes a set of strings. Regular expressions are constructed analogously to arithmetic expressions, by using various operators to combine smaller expressions. NoteThe regular expression can be enclosed/delimited by either " or ' which is useful if the regular expression includes a white-space character. See Syntax of Initialization Files for more information on " and ' delimiter processing. To match a literal " or ' you must preface it with \ (backslash). The fundamental building blocks are the regular expressions that match a single character. Most characters, including all letters and digits, are regular expressions that match themselves. Any metacharacter with special meaning may be quoted by preceding it with a backslash. The period “.” matches any single character. The caret “^” and the dollar sign “$” are metacharacters that respectively match the empty string at the beginning and end of a line. A list of characters enclosed by “[” and “]” matches any single character in that list; if the first character of the list is a caret “^” then it matches any character not in the list. For example, the regular expression [0123456789] matches any single digit. A range of ASCII characters may be specified by giving the first and last characters, separated by a hyphen “-”. Most metacharacters lose their special meaning inside lists. To include a literal “]” place it first in the list. Similarly, to include a literal “^” place it anywhere but first. Finally, to include a literal hyphen “-” place it last. Certain named classes of characters are predefined. Character classes consist of “[:”, a keyword denoting the class, and “:]”. The following classes are defined by the POSIX standard in Table 4.1, “POSIX regular expression character classes” Table 4.1. POSIX regular expression character classes
A character class is only valid in a regular expression inside the brackets of a character list. NoteNote that the brackets in these class names are part of the symbolic names, and must be included in addition to the brackets delimiting the bracket list. For example, [[:digit:]] is equivalent to [0-9]. Two additional special sequences can appear in character lists. These apply to non-ASCII character sets, which can have single symbols (called collating elements) that are represented with more than one character, as well as several characters that are equivalent for collating or sorting purposes:
A regular expression matching a single character may be followed by one of several repetition operators described in Table 4.2, “Regular expression repetition operators”. Table 4.2. Regular expression repetition operators
Two regular expressions may be concatenated; the resulting regular expression matches any string formed by concatenating two substrings that respectively match the concatenated subexpressions. Two regular expressions may be joined by the infix operator “|”; the resulting regular expression matches any string matching either subexpression. Repetition takes precedence over concatenation, which in turn takes precedence over alternation. A whole subexpression may be enclosed in parentheses to override these precedence rules. NoteIf you compile Mutt with the included regular expression engine, the following operators may also be used in regular expressions as described in Table 4.3, “GNU regular expression extensions”. Table 4.3. GNU regular expression extensions
Please note however that these operators are not defined by POSIX, so they may or may not be available in stock libraries on various systems.
Many of Mutt's commands allow you to specify a pattern to match
( Table 4.4. Pattern modifiers
Where EXPR is a regular expression, and GROUP is an address group. *) The forms “<[MAX]”, “>[MIN]”, “[MIN]-” and “-[MAX]” are allowed, too. **) The suffixes “K” and “M” are allowed to specify kilobyte and megabyte respectively. ***) These patterns read each message in, and can therefore be much slower. Over IMAP this will entail downloading each message. They can not be used for message scoring, and it is recommended to avoid using them for index coloring. Special attention has to be paid when using regular expressions inside of patterns. Specifically, Mutt's parser for these patterns will strip one level of backslash (“\”), which is normally used for quoting. If it is your intention to use a backslash in the regular expression, you will need to use two backslashes instead (“\\”).
You can force Mutt to treat
EXPR as a simple string instead of a regular
expression by using = instead of ~ in the pattern name. For example,
For IMAP folders, string matches Patterns matching lists of addresses (notably c, C, p, P and t) match if there is at least one match in the whole list. If you want to make sure that all elements of that list match, you need to prefix your pattern with “^”. This example matches all mails which only has recipients from Germany. You can restrict address pattern matching to aliases that you have defined with the "@" modifier. This example matches messages whose recipients are all from Germany, and who are known to your alias list. To match any defined alias, use a regular expression that matches any string. This example matches messages whose senders are known aliases. Mutt supports two versions of so called “simple searches”. These are issued if the query entered for searching, limiting and similar operations does not seem to contain a valid pattern modifier (i.e. it does not contain one of these characters: “~”, “=” or “%”). If the query is supposed to contain one of these special characters, they must be escaped by prepending a backslash (“\”).
The first type is by checking whether the query string equals
a keyword case-insensitively from Table 4.5, “Simple search keywords”:
If that is the case, Mutt will use the shown pattern modifier instead.
If a keyword would conflict with your search keyword, you need to turn
it into a regular expression to avoid matching the keyword table. For
example, if you want to find all messages matching “flag”
(using $simple_search)
but don't want to match flagged messages, simply search for
“ Table 4.5. Simple search keywords
The second type of simple search is to build a complex search pattern using $simple_search as a template. Mutt will insert your query properly quoted and search for the composed complex query. Logical AND is performed by specifying more than one criterion. For example: ~t mutt ~f elkins would select messages which contain the word “mutt” in the list of recipients and that have the word “elkins” in the “From” header field. Mutt also recognizes the following operators to create more complex search patterns:
Here is an example illustrating a complex search pattern. This pattern will select all messages which do not contain “mutt” in the “To” or “Cc” field and which are from “elkins”. Here is an example using white space in the regular expression (note the “'” and “"” delimiters). For this to match, the mail's subject must match the “^Junk +From +Me$” and it must be from either “Jim +Somebody” or “Ed +SomeoneElse”:
'~s "^Junk +From +Me$" ~f ("Jim +Somebody"|"Ed +SomeoneElse")'
Note
If a regular expression contains parenthesis, or a vertical bar ("|"),
you must enclose the expression in double or single
quotes since those characters are also used to separate different parts
of Mutt's pattern language. For example: Mutt supports two types of dates, absolute and relative. Dates must be in DD/MM/YY format (month and year are optional, defaulting to the current month and year) or YYYYMMDD. An example of a valid range of dates is: Limit to messages matching: ~d 20/1/95-31/10 Limit to messages matching: ~d 19950120-19951031 If you omit the minimum (first) date, and just specify “-DD/MM/YY” or “-YYYYMMDD”, all messages before the given date will be selected. If you omit the maximum (second) date, and specify “DD/MM/YY-”, all messages after the given date will be selected. If you specify a single date with no dash (“-”), only messages sent on the given date will be selected. You can add error margins to absolute dates. An error margin is a sign (+ or -), followed by a digit, followed by one of the units in Table 4.6, “Date units”. As a special case, you can replace the sign by a “*” character, which is equivalent to giving identical plus and minus error margins. Example: To select any messages two weeks around January 15, 2001, you'd use the following pattern: Limit to messages matching: ~d 15/1/2001*2w This type of date is relative to the current date, and may be specified as:
offset is specified as a positive number with one of the units from Table 4.7, “Relative date units”. Example: to select messages less than 1 month old, you would use Limit to messages matching: ~d <1m Note
All dates used when searching are relative to the
local time zone, so unless you change the setting
of your $index_format to include a
There are times that it's useful to ask Mutt to "remember" which message you're currently looking at, while you move elsewhere in your mailbox. You can do this with the “mark-message” operator, which is bound to the “~” key by default. Press this key to enter an identifier for the marked message. When you want to return to this message, press “'” and the name that you previously entered. (Message marking is really just a shortcut for defining a macro that returns you to the current message by searching for its Message-ID. You can choose a different prefix by setting the $mark_macro_prefix variable.)
Sometimes it is desirable to perform an operation on a group of messages
all at once rather than one at a time. An example might be to save
messages to a mailing list to a separate folder, or to delete all
messages with a given subject. To tag all messages matching a pattern,
use the Once you have tagged the desired messages, you can use the “tag-prefix” operator, which is the “;” (semicolon) key by default. When the “tag-prefix” operator is used, the next operation will be applied to all tagged messages if that operation can be used in that manner. If the $auto_tag variable is set, the next operation applies to the tagged messages automatically, without requiring the “tag-prefix”.
In macros or push commands, you can use the
A hook is a concept found in many other programs which allows you to execute arbitrary commands before performing some operation. For example, you may wish to tailor your configuration based upon which mailbox you are reading, or to whom you are sending mail. In the Mutt world, a hook consists of a regular expression or pattern along with a configuration option/command. See: for specific details on each type of hook available. Also see Message Composition Flow for an overview of the composition process. NoteIf a hook changes configuration settings, these changes remain effective until the end of the current Mutt session. As this is generally not desired, a “default” hook needs to be added before all other hooks of that type to restore configuration defaults. Example 4.5. Specifying a “default” hook send-hook . 'unmy_hdr From:' send-hook ~C'^b@b\.b$' my_hdr from: [email protected]
In Example 4.5, “Specifying a “default” hook”, by default the value of $from and $realname is not overridden. When sending
messages either To: or Cc: to Hooks that act upon messages (message-hook, reply-hook, send-hook, send2-hook, save-hook, fcc-hook, index-format-hook) are evaluated in a slightly different manner. For the other types of hooks, a regular expression is sufficient. But in dealing with messages a finer grain of control is needed for matching since for different purposes you want to match different criteria. Mutt allows the use of the search pattern language for matching messages in hook commands. This works in exactly the same way as it would when limiting or searching the mailbox, except that you are restricted to those operators which match information Mutt extracts from the header of the message (i.e., from, to, cc, date, subject, etc.). For example, if you wanted to set your return address based upon sending mail to a specific address, you could do something like: send-hook '~t ^me@cs\.hmc\.edu$' 'my_hdr From: Mutt User <user@host>' which would execute the given command when sending mail to [email protected]. However, it is not required that you write the pattern to match using the full searching language. You can still specify a simple regular expression like the other hooks, in which case Mutt will translate your pattern into the full language, using the translation specified by the $default_hook variable. The pattern is translated at the time the hook is declared, so the value of $default_hook that is in effect at that time will be used. Hooks that match against mailboxes (folder-hook, mbox-hook) apply both regular expression syntax as well as mailbox shortcut expansion on the regexp parameter. There is some overlap between these, so special attention should be paid to the first character of the regexp. # Here, ^ will expand to "the current mailbox" not "beginning of string": folder-hook ^/home/user/Mail/bar "set sort=threads" # If you want ^ to be interpreted as "beginning of string", one workaround # is to enclose the regexp in parenthesis: folder-hook (^/home/user/Mail/bar) "set sort=threads" # This will expand to the default save folder for the alias "imap.example.com", which # is probably not what you want: folder-hook @imap.example.com "set sort=threads" # A workaround is to use parenthesis or a backslash: folder-hook (@imap.example.com) "set sort=threads" folder-hook '\@imap.example.com' "set sort=threads" Keep in mind that mailbox shortcut expansion on the regexp parameter takes place when the hook is initially parsed, not when the hook is matching against a mailbox. When Mutt starts up and is reading the .muttrc, some mailbox shortcuts may not be usable. For example, the "current mailbox" shortcut, ^, will expand to an empty string because no mailbox has been opened yet. Mutt will issue an error for this case or if the mailbox shortcut results in an empty regexp. You can alter the environment that Mutt passes on to its child processes using the “setenv” and “unsetenv” operators. (N.B. These follow Mutt-style syntax, not shell-style!) You can also query current environment values by prefixing a “?” character. setenv TERM vt100 setenv ORGANIZATION "The Mutt Development Team" unsetenv DISPLAY setenv ?LESS Mutt supports connecting to external directory databases such as LDAP, ph/qi, bbdb, or NIS through a wrapper script which connects to Mutt using a simple interface. Using the $query_command variable, you specify the wrapper command to use. For example: set query_command = "mutt_ldap_query.pl %s" The wrapper script should accept the query on the command-line. It should return a one line message, then each matching response on a single line, each line containing a tab separated address then name then some other optional information. On error, or if there are no matching addresses, return a non-zero exit code and a one line error message. An example multiple response output: Searching database ... 20 entries ... 3 matching: [email protected] Michael Elkins mutt dude [email protected] Brandon Long mutt and more [email protected] Thomas Roessler mutt pgp
There are two mechanisms for accessing the query function of Mutt. One
is to do a query from the index menu using the
The other mechanism for accessing the query function is for address
completion, similar to the alias completion. In any prompt for address
entry, you can use the Mutt supports reading and writing of four different local mailbox formats: mbox, MMDF, MH and Maildir. The mailbox type is auto detected, so there is no need to use a flag for different mailbox types. When creating new mailboxes, Mutt uses the default specified with the $mbox_type variable. A short description of the formats follows. mbox. This is a widely used mailbox format for UNIX. All messages are stored in a single file. Each message has a line of the form: From [email protected] Fri, 11 Apr 1997 11:44:56 PST to denote the start of a new message (this is often referred to as the “From_” line). The mbox format requires mailbox locking, is prone to mailbox corruption with concurrently writing clients or misinterpreted From_ lines. Depending on the environment, new mail detection can be unreliable. Mbox folders are fast to open and easy to archive. MMDF. This is a variant of the mbox format. Each message is surrounded by lines containing “^A^A^A^A” (four times control-A's). The same problems as for mbox apply (also with finding the right message separator as four control-A's may appear in message bodies).
MH. A radical departure from
mbox and MMDF, a mailbox
consists of a directory and each message is stored in a separate file.
The filename indicates the message number (however, this is may not
correspond to the message number Mutt displays). Deleted messages are
renamed with a comma (“,”) prepended to the filename. Mutt
detects this type of mailbox by looking for either
Maildir. The newest of the mailbox formats, used by the Qmail MTA (a replacement for sendmail). Similar to MH, except that it adds three subdirectories of the mailbox: tmp, new and cur. Filenames for the messages are chosen in such a way they are unique, even when two programs are writing the mailbox over NFS, which means that no file locking is needed and corruption is very unlikely. Maildir maybe slower to open without caching in Mutt, it too is not very disk-space efficient depending on the environment. Since no additional files are used for metadata (which is embedded in the message filenames) and Maildir is locking-free, it's easy to sync across different machines using file-level synchronization tools. There are a number of built in shortcuts which refer to specific mailboxes. These shortcuts can be used anywhere you are prompted for a file or mailbox path or in path-related configuration variables. Note that these only work at the beginning of a string. Table 4.8. Mailbox shortcuts
For example, to store a copy of outgoing messages in the folder they were composed in, a folder-hook can be used to set $record: folder-hook . 'set record=^'
Note: the current mailbox shortcut,
“
Note: the $record shortcut
“
Mutt has a few configuration options that make dealing with large
amounts of mail easier. The first thing you must do is to let Mutt know
what addresses you consider to be mailing lists (technically this does
not have to be a mailing list, but that is what it is most often used
for), and what lists you are subscribed to. This is accomplished
through the use of the lists
and subscribe commands in your
Now that Mutt knows what your mailing lists are, it can do several things, the first of which is the ability to show the name of a list through which you received a message (i.e., of a subscribed list) in the index menu display. This is useful to distinguish between personal and list mail in the same mailbox. In the $index_format variable, the expando “%L” will print the string “To <list>” when “list” appears in the “To” field, and “Cc <list>” when it appears in the “Cc” field (otherwise it prints the name of the author).
Often times the “To” and “Cc” fields in
mailing list messages tend to get quite large. Most people do not bother
to remove the author of the message they reply to from the list,
resulting in two or more copies being sent to that person. The
Mutt also supports the
Conversely, when group-replying or list-replying to a message which has
a Note
When header editing is enabled, you can create a
The other method some mailing list admins use is to generate a “Reply-To” field which points back to the mailing list address rather than the author of the message. This can create problems when trying to reply directly to the author in private, since most mail clients will automatically reply to the address given in the “Reply-To” field. Mutt uses the $reply_to variable to help decide which address to use. If set to ask-yes or ask-no, you will be prompted as to whether or not you would like to use the address given in the “Reply-To” field, or reply directly to the address given in the “From” field. When set to yes, the “Reply-To” field will be used when present. While looking at an email message from a mailing list in the index or pager, you can interact with the list server in the ways defined by RFC 2369, provided the email message specifies how to do so. Invoke the list menu (bound to "ESC L" by default) to see what options are available for a given message. Common options are:
Note that many list servers only specify some of these options. The “X-Label:” header field can be used to further identify mailing lists or list subject matter (or just to annotate messages individually). The $index_format variable's “%y” and “%Y” expandos can be used to expand “X-Label:” fields in the index, and Mutt's pattern-matcher can match regular expressions to “X-Label:” fields with the “~y” selector. “X-Label:” is not a standard message header field, but it can easily be inserted by procmail and other mail filtering agents. You can change or delete the “X-Label:” field within Mutt using the “edit-label” command, bound to the “y” key by default. This works for tagged messages, too. While in the edit-label function, pressing the <complete> binding (TAB, by default) will perform completion against all labels currently in use. Lastly, Mutt has the ability to sort the mailbox into threads. A thread is a group of messages which all relate to the same subject. This is usually organized into a tree-like structure where a message and all of its replies are represented graphically. If you've ever used a threaded news client, this is the same concept. It makes dealing with large volume mailing lists easier because you can easily delete uninteresting threads and quickly find topics of value. Working within the confines of a console or terminal window, it is often useful to be able to modify certain information elements in a non-destructive way -- to change how they display, without changing the stored value of the information itself. This is especially so of message subjects, which may often be polluted with extraneous metadata that either is reproduced elsewhere, or is of secondary interest.
Note this well: the “replacement” value replaces the entire subject, not just the match!
Example 4.6. Subject Munging # Erase [rt #12345] tags from Request Tracker (RT) e-mails subjectrx '\[rt #[0-9]+\] *' '%L%R' # Servicedesk is another RT that sends more complex subjects. # Keep the ticket number. subjectrx '\[servicedesk #([0-9]+)\] ([^.]+)\.([^.]+) - (new|open|pending|update) - ' '%L[#%1] %R' # Strip out annoying [listname] prefixes in subjects subjectrx '\[[^]]*\]:? *' '%L%R' Mutt supports setups with multiple folders, allowing all of them to be monitored for new mail (see Section 16, “Monitoring Incoming Mail” for details).
For Mbox and Mmdf folders, new mail is detected by comparing access
and/or modification times of files: Mutt assumes a folder has new mail
if it wasn't accessed after it was last modified. Utilities like
NoteContrary to older Mutt releases, it now maintains the new mail status of a folder by properly resetting the access time if the folder contains at least one message which is neither read, nor deleted, nor marked as old. In cases where new mail detection for Mbox or Mmdf folders appears to be unreliable, the $check_mbox_size option can be used to make Mutt track and consult file sizes for new mail detection instead which won't work for size-neutral changes.
New mail for Maildir is assumed if there is one message in the
Mutt does not poll POP3 folders for new mail, it only periodically checks the currently opened folder (if it's a POP3 folder). For IMAP, by default Mutt uses recent message counts provided by the server to detect new mail. If the $imap_idle option is set, it'll use the IMAP IDLE extension if advertised by the server. The $mail_check_recent option changes whether Mutt will notify you of new mail in an already visited mailbox. When set (the default) it will only notify you of new mail received since the last time you opened the mailbox. When unset, Mutt will notify you of any new mail in the mailbox.
When in the index menu and being idle (also see $timeout), Mutt periodically checks for new
mail in all folders which have been configured via the
mailboxes command (excepting those specified with
the
Outside the index menu the directory browser supports checking for new
mail using the
For the pager, index and directory browser menus, Mutt contains the
For the index, by default Mutt displays the number of mailboxes with new mail in the status bar, please refer to the $status_format variable for details.
When changing folders, Mutt fills the prompt with the first folder from
the mailboxes list containing new mail (if any), pressing
When the Inotify mechanism for monitoring of
files is supported (Linux only) and not disabled at compilation time,
Mutt immediately notifies about new mail for all folders configured
via the mailboxes
command (excepting those specified with the
No configuration variables are available. Trace output is given when
debugging is enabled via command
line option NoteGetting events about new mail is limited to the capabilities of the underlying mechanism. Inotify only reports local changes, i. e. new mail notification works for mails delivered by an agent on the same machine as Mutt, but not when delivered remotely on a network file system as NFS. Also the monitoring handles might fail in rare conditions, so you better don't completely rely on this feature. If $mail_check_stats is set, Mutt will periodically calculate the unread, flagged, and total message counts for each mailbox watched by the mailboxes command. This calculation takes place at the same time as new mail polling, but is controlled by a separate timer: $mail_check_stats_interval. The sidebar can display these message counts. See $sidebar_format. Mutt has the ability to dynamically restructure threads that are broken either by misconfigured software or bad behavior from some correspondents. This allows to clean your mailboxes from these annoyances which make it hard to follow a discussion.
Some mailers tend to “forget” to correctly set the
“In-Reply-To:” and “References:” headers when
replying to a message. This results in broken discussions because Mutt
has not enough information to guess the correct threading. You can fix
this by tagging the reply, then moving to the parent message and using
the
You can also connect multiple children at once, tagging them and using
the
On mailing lists, some people are in the bad habit of starting a new
discussion by hitting “reply” to any message from the list
and changing the subject to a totally unrelated one. You can fix such
threads by using the RFC1894 defines a set of MIME content types for relaying information about the status of electronic mail messages. These can be thought of as “return receipts.” To support DSN, there are two variables. $dsn_notify is used to request receipts for different results (such as failed message, message delivered, etc.). $dsn_return requests how much of your message should be returned with the receipt (headers or full message). When using $sendmail for mail delivery, you need to use either Berkeley sendmail 8.8.x (or greater) a MTA supporting DSN command line options compatible to Sendmail: The -N and -R options can be used by the mail client to make requests as to what type of status messages should be returned. Please consider your MTA documentation whether DSN is supported. For SMTP delivery using $smtp_url, it depends on the capabilities announced by the server whether Mutt will attempt to request DSN or not. If a message contains URLs, it is efficient to get a menu with all the URLs and start a WWW browser on one of them. This functionality is provided by the external urlview program which can be retrieved at https://github.com/sigpipe/urlview and the configuration commands: macro index \cb |urlview\n macro pager \cb |urlview\n Usage:
You can print messages to the message window using the "echo" command. This might be useful after a macro finishes executing. After printing the message, echo will pause for the number of seconds specified by $sleep_time. echo "Sourcing muttrc file" unset confirmappend macro index ,a "<save-message>=archive<enter><enter-command>echo 'Saved to archive'<enter>" This is a brief overview of the steps Mutt takes during message composition. It also shows the order and timing of hook execution.
In batch mode, Mutt performs less steps than interactive mode. Encryption and Signing are not supported. Fcc'ing to an IMAP mailbox is not supported.
MuttLisp is a Lisp-like enhancement for the Mutt configuration file. It is currently experimental, meaning new releases may change or break syntax. MuttLisp is not a real language, and is not meant to be an alternative to macros. The features are purposely minimal, with the actual work still being done by Mutt commands.
There are two ways to invoke MuttLisp: via the
Usage:
The
run (concat "set my_name = '" \
(or $ENV_NAME "Test User") "'")
==> generates and runs the line:
set my_name = 'Test User'
This will set the Mutt User-Defined Variable
The second way of running is directly as a command argument. An unquoted parenthesis expression will be evaluated, and the result substituted as the argument. To avoid breaking existing configurations, this is disabled by default. It can be enabled by setting $muttlisp_inline_eval. Before doing so, you should review your Mutt configuration to ensure you don't have any bare parenthesis expressions elsewhere, such as the regexp parameter of a folder-hook. These can typically be surrounded by single or double-quotes to prevent being evaluated as MuttLisp. set my_name = (or $ENV_NAME "Test User") The result of the MuttLisp is directly assigned as the argument. It isn't reinterpreted, so there is no need for the outer quotes. This is in contrast with the run command, where the output is reinterpreted by the muttrc parser. MuttLisp was inspired by Lisp, and so follows the same basic syntax. All statements are surrounded by parenthesis. The first argument inside the parenthesis is a function to invoke. The remaining arguments are passed as parameters. The arguments to functions are read and evaluated using muttrc syntax. This means Mutt variables or environment variables can be passed directly, or interpolated inside a double-quoted string. Although the arguments to a function are evaluated, the result of the function call is not. echo (concat '$' 'spoolfile') ==> $spoolfile MuttLisp has no types - everything is stored and evaluated as a string, just as with the muttrc. True is defined as a non-empty string, and false as the empty string. The muttrc is evaluated line by line, and MuttLisp is similarly constrained. Input can be continued on more than one line by placing a backslash at the end of the line. Combines all arguments into a single string. echo (concat one two three) ==> onetwothree
Prevents interpretation of the list. Note that the list must
still obey MuttLisp syntax: single quotes, double quotes,
backticks, and parenthesis are still parsed prior to
echo (quote one two three) ==> one two three echo (quote $spoolfile) ==> $spoolfile echo (quote (one two three)) ==> (one two three) Performs a case-sensitive comparison of each argument. Stops evaluating arguments when it finds the first one that is not equal. Returns "t" if they are all equal, and the empty string if not. echo (equal one one) ==> "t" echo (equal one `echo one`) ==> "t" echo (equal one one two `echo three`) ==> "" note: `echo three` does not execute. echo (equal "one two" `echo one two`) ==> "" note: backticks generate two arguments "one" and "two" echo (equal "one two" "`echo one two`") ==> "t" note: backticks inside double quotes generates a single argument: "one two" Accepts a single argument only. Returns "t" if the argument evaluates to the empty string. Otherwise returns the empty string. echo (not one) ==> "" echo (not "") ==> "t" echo (not (equal one two)) ==> "t" Returns the first argument that evaluates to the empty string. Otherwise returns the last argument, or "t" if there are no arguments. echo (and one two) ==> "two" echo (and "" two `echo three`) ==> "" note: `echo three` does not execute. echo (and) ==> "t" Returns the first argument that evaluates to a non-empty string. Otherwise returns the empty string. echo (or one two) ==> "one" echo (or "" two `echo three`) ==> "two" note: `echo three` does not execute. echo (or) ==> "" Requires 2 or 3 arguments. The first is a conditional. If it evaluates to "true" (a non-empty string), the second argument is evaluated and returned. Otherwise the third argument is evaluated and returned. echo (if a one two) ==> "one" echo (if "" one two) ==> "two" set spoolfile = "/var/mail/user" echo (if (equal $spoolfile "/var/mail/user") yes no) ==> "yes" It's important to remember that function arguments are evaluated, but the result is not. Also, the result of an interpolated command argument is used directly, and needs no quoting.
# A three-way toggle of $index_format:
set muttlisp_inline_eval
set my_idx1 = "one"
set my_idx2 = "two"
set my_idx3 = "three"
set index_format = $my_idx1
macro index i '<enter-command>set index_format = \
(or \
(if (equal $index_format $my_idx1) $my_idx2) \
(if (equal $index_format $my_idx2) $my_idx3) \
$my_idx1) \
<enter>'
The output of the run command is re-evaluated by the muttrc parser. So it's important to pay more attention to quoting issues when generating the command string below.
# Conditionally set up background editing in tmux or GNU Screen:
run \
(if (or $STY $TMUX) \
(concat \
'set background_edit;' \
'set editor = "bgedit-screen-tmux.sh vim"') \
(concat \
'unset background_edit;' \
'set editor = "vim"'))
Because backticks are evaluated by MuttLisp too, we need to use the run command below and pay close attention to quoting.
# Use a Mutt variable inside backticks.
set spoolfile = "/var/mail/testuser"
# This will generate and then run the command string:
# set my_var = "`~/bin/myscript.sh /var/mail/testuser`"
run \
(concat \
'set my_var = "`~/bin/myscript.sh ' \
$spoolfile \
'`"')
This section documents various features that fit nowhere else.
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0119 ]-- |