Ifdef Feature

Conditional config options

1. Support

Since: NeoMutt 2016-03-07

Dependencies: None

2. Introduction

The ifdef feature introduces three new commands to Mutt and allow you to share one config file between versions of Mutt that may have different features compiled in.

ifdef  symbol config-command [args...]
# If a symbol is defined
ifndef symbol config-command [args...]
# If a symbol is not defined
finish
# Finish reading the current file

Here a symbol can be a $variable, <function>, command or compile-time symbol, such as imap.

A list of compile-time symbols can be seen in the output of the command

mutt -v

(in the Compile options section).

finish is particularly useful when combined with ifndef. e.g.

# Sidebar config file
ifndef sidebar finish

3. Commands

ifdef symbol "config-command [args]"
ifndef symbol "config-command [args]"
finish

4. Muttrc

# Example NeoMutt config file for the ifdef feature.

# This feature introduces three useful commands which allow you to share
# one config file between versions of Mutt that may have different
# features compiled in.

#   ifdef  symbol config-command [args...]
#   ifndef symbol config-command [args...]
#   finish
# The 'ifdef' command tests whether Mutt understands the name of
# a variable, function, command or compile-time symbol.

# If it does, then it executes a config command.

# The 'ifndef' command tests whether a symbol does NOT exist.

# The 'finish' command tells Mutt to stop reading current config file.

# If the 'trash' variable exists, set it.
ifdef trash 'set trash=~/Mail/trash'
# If the 'tag-pattern' function exists, bind a key to it.
ifdef tag-pattern 'bind index <F6> tag-pattern'
# If the 'imap-fetch-mail' command exists, read my IMAP config.
ifdef imap-fetch-mail 'source ~/.mutt/imap.rc'
# If the compile-time symbol 'sidebar' does not exist, then
# stop reading the current config file.
ifndef sidebar finish


# vim: syntax=muttrc

5. Known Bugs

None

6. Credits