95 struct Hook *h = *ptr;
181 struct Hook *hook = NULL;
244 struct Hook *hook = NULL;
246 bool pat_not =
false;
247 struct PatternList *pat = NULL;
252 if (*line->
dptr ==
'!')
351 struct Hook *hook = NULL;
353 bool pat_not =
false;
354 struct PatternList *pat = NULL;
359 if (*line->
dptr ==
'!')
460 struct Hook *hook = NULL;
462 bool pat_not =
false;
468 if (*line->
dptr ==
'!')
520 regerror(rc2, rx, err->
data, err->
dsize);
553 struct Hook *hook = NULL;
555 bool pat_not =
false;
556 bool use_regex =
true;
562 if (*line->
dptr ==
'!')
609 buf_strcpy(err,
_(
"current mailbox shortcut '^' is unset"));
621 buf_strcpy(err,
_(
"mailbox shortcut expanded to empty regex"));
656 regerror(rc2, rx, err->
data, err->
dsize);
690 struct Hook *hook = NULL;
692 bool pat_not =
false;
698 if (*line->
dptr ==
'!')
750 regerror(rc2, rx, err->
data, err->
dsize);
783 struct Hook *hook = NULL;
785 bool pat_not =
false;
786 bool use_regex =
true;
792 if (*line->
dptr ==
'!')
839 buf_strcpy(err,
_(
"current mailbox shortcut '^' is unset"));
851 buf_strcpy(err,
_(
"mailbox shortcut expanded to empty regex"));
893 regerror(rc2, rx, err->
data, err->
dsize);
930 struct Hook *hook = NULL;
932 bool pat_not =
false;
938 if (*line->
dptr ==
'!')
973 buf_strcpy(err,
_(
"badly formatted command string"));
999 regerror(rc2, rx, err->
data, err->
dsize);
1031 struct Hook *h = NULL;
1032 struct Hook *tmp = NULL;
1049 struct HookList *hl = obj;
1050 struct Hook *h = NULL;
1051 struct Hook *tmp = NULL;
1086 bool pat_not =
false;
1102 if (*line->
dptr ==
'!')
1132 struct Hook *hook = NULL;
1199 const struct Command **cp = NULL;
1202 const struct Command *cmd = *cp;
1242 buf_addstr(err,
_(
"unhook: Can't do unhook * from within a hook"));
1267 buf_printf(err,
_(
"unhook: Can't delete a %s from within a %s"),
1296 struct Hook *hook = NULL;
1309 const char *match = NULL;
1341 struct Hook *tmp = NULL;
1362 struct Hook *hook = NULL;
1373 if (hook->
type & type)
1388 memset(&cache, 0,
sizeof(cache));
1408 struct Hook *hook = NULL;
1417 if (hook->
type & type)
1449 const struct Address *addr = NULL;
1452 if (!from_me && reply_to && reply_to->
mailbox)
1454 else if (!from_me && from && from->
mailbox)
1488 if ((c_save_name || c_force_name) && (to || cc || bcc))
1490 const struct Address *addr = to ? to : (cc ? cc : bcc);
1520 struct Hook *tmp = NULL;
1552 static bool inhook =
false;
1556 struct Hook *hook = NULL;
1594 struct Hook *hook = NULL;
1626 struct Hook *hook = NULL;
1663 const struct Expando *exp = NULL;
1664 struct Hook *hook = NULL;
1687 N_(
"Run a command when switching to a matching account"),
1688 N_(
"account-hook <regex> <command>"),
1689 "optionalfeatures.html#account-hook" },
1691 N_(
"Define charset alias for languages"),
1692 N_(
"charset-hook <alias> <charset>"),
1693 "configuration.html#charset-hook" },
1695 N_(
"Specify which keyid to use for recipients matching regex"),
1696 N_(
"crypt-hook <regex> <keyid>"),
1697 "configuration.html#crypt-hook" },
1699 N_(
"Pattern rule to set the save location for outgoing mail"),
1700 N_(
"fcc-hook <pattern> <mailbox>"),
1701 "configuration.html#default-save-mailbox" },
1703 N_(
"Equivalent to both `fcc-hook` and `save-hook`"),
1704 N_(
"fcc-save-hook <pattern> <mailbox>"),
1705 "configuration.html#default-save-mailbox" },
1707 N_(
"Run a command upon entering a folder matching regex"),
1708 N_(
"folder-hook [ -noregex ] <regex> <command>"),
1709 "configuration.html#folder-hook" },
1711 N_(
"Define a system-specific alias for a character set"),
1712 N_(
"iconv-hook <charset> <local-charset>"),
1713 "configuration.html#charset-hook" },
1715 N_(
"Create dynamic index format strings"),
1716 N_(
"index-format-hook <name> [ ! ]<pattern> <format-string>"),
1717 "configuration.html#index-format-hook" },
1719 N_(
"On leaving a mailbox, move read messages matching a regex regex"),
1720 N_(
"mbox-hook [ -noregex ] <regex> <mailbox>"),
1721 "configuration.html#mbox-hook" },
1723 N_(
"Run a command when viewing a message matching patterns"),
1724 N_(
"message-hook <pattern> <command>"),
1725 "configuration.html#message-hook" },
1727 N_(
"Run a command when replying to messages matching a pattern"),
1728 N_(
"reply-hook <pattern> <command>"),
1729 "configuration.html#send-hook" },
1731 N_(
"Set default save folder for messages"),
1732 N_(
"save-hook <pattern> <mailbox>"),
1733 "configuration.html#default-save-mailbox" },
1735 N_(
"Run a command when sending a message, new or reply, matching a pattern"),
1736 N_(
"send-hook <pattern> <command>"),
1737 "configuration.html#send-hook" },
1739 N_(
"Run command whenever a composed message is edited"),
1740 N_(
"send2-hook <pattern> <command>"),
1741 "configuration.html#send-hook" },
1743 N_(
"Run a command before NeoMutt exits"),
1744 N_(
"shutdown-hook <command>"),
1745 "optionalfeatures.html#global-hooks" },
1747 N_(
"Run a command when NeoMutt starts up"),
1748 N_(
"startup-hook <command>"),
1749 "optionalfeatures.html#global-hooks" },
1751 N_(
"Run a command after a specified timeout or idle period"),
1752 N_(
"timeout-hook <command>"),
1753 "optionalfeatures.html#global-hooks" },
1755 N_(
"Remove hooks of a given type"),
1756 N_(
"unhook { * | <hook-type> }"),
1757 "configuration.html#unhook" },
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
GUI display the mailboxes in a side panel.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
#define CF_SYNONYM
Command is a synonym for another command.
#define CF_NO_FLAGS
No flags are set.
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ MUTT_CMD_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct Buffer *err)
Parse and run a muttrc line in a relative directory.
char * mutt_get_sourced_cwd(void)
Get the current file path that is being parsed.
Functions to parse commands in a config file.
struct PatternList * mutt_pattern_comp(struct MailboxView *mv, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
int mutt_comp_valid_command(const char *cmd)
Is this command string allowed?
Compressed mbox local mailbox type.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Convenience wrapper for the core headers.
int mutt_make_string(struct Buffer *buf, size_t max_cols, const struct Expando *exp, struct Mailbox *m, int inpgr, struct Email *e, MuttFormatFlags flags, const char *progress)
Create formatted strings using mailbox expandos.
Structs that make up an email.
bool mutt_pattern_exec(struct Pattern *pat, PatternExecFlags flags, struct Mailbox *m, struct Email *e, struct PatternCache *cache)
Match a pattern against an email header.
struct Expando * expando_parse(const char *str, const struct ExpandoDefinition *defs, struct Buffer *err)
Parse an Expando string.
void expando_free(struct Expando **ptr)
Free an Expando object.
int mutt_file_sanitize_regex(struct Buffer *dest, const char *src)
Escape any regex-magic characters in a string.
char * CurrentFolder
Currently selected mailbox.
enum CommandResult parse_hook_folder(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse folder hook command - Implements Command::parse() -.
enum CommandResult parse_unhook(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the unhook command - Implements Command::parse() -.
enum CommandResult parse_hook_pattern(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse pattern-based hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_regex(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse regex-based hook command - Implements Command::parse() -.
enum CommandResult parse_hook_compress(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse compress hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_index(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the index format hook command - Implements Command::parse() -.
enum CommandResult parse_hook_mailbox(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse mailbox pattern hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_global(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse global hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_charset(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse charset hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_crypt(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse crypt hook commands - Implements Command::parse() -.
enum CommandResult parse_hook_mbox(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse mbox hook command - Implements Command::parse() -.
static void idxfmt_hashelem_free(int type, void *obj, intptr_t data)
Free our hash table data - Implements hash_hdata_free_t -.
#define mutt_debug(LEVEL,...)
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
void mutt_hash_set_destructor(struct HashTable *table, hash_hdata_free_t fn, intptr_t fn_data)
Set the destructor for a Hash Table.
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
void mutt_default_save(struct Buffer *path, struct Email *e)
Find the default save path for an email.
void mutt_timeout_hook(void)
Execute any timeout hooks.
static struct HashTable * IdxFmtHooks
All Index Format hooks.
char * mutt_find_hook(HookFlags type, const char *pat)
Find a matching hook.
void mutt_startup_shutdown_hook(HookFlags type)
Execute any startup/shutdown hooks.
void mutt_delete_hooks(HookFlags type)
Delete matching hooks.
static void list_hook(struct ListHead *matches, const char *match, HookFlags type)
Find hook strings matching.
void mutt_account_hook(const char *url)
Perform an account hook.
static void delete_idxfmt_hooks(void)
Delete all the index-format-hooks.
static void hook_free(struct Hook **ptr)
Free a Hook.
void mutt_folder_hook(const char *path, const char *desc)
Perform a folder hook.
void mutt_select_fcc(struct Buffer *path, struct Email *e)
Select the FCC path for an email.
const struct Expando * mutt_idxfmt_hook(const char *name, struct Mailbox *m, struct Email *e)
Get index-format-hook format string.
static int addr_hook(struct Buffer *path, HookFlags type, struct Mailbox *m, struct Email *e)
Perform an address hook (get a path)
const struct ExpandoDefinition IndexFormatDef[]
Expando definitions.
void hooks_init(void)
Setup feature commands.
static struct HookList Hooks
All simple hooks, e.g. MUTT_FOLDER_HOOK.
static HookFlags mutt_get_hook_type(const char *name)
Find a hook by name.
static HookFlags CurrentHookType
The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.
static const struct Command HookCommands[]
Hook Commands.
void mutt_crypt_hook(struct ListHead *list, struct Address *addr)
Find crypto hooks for an Address.
static struct Hook * hook_new(void)
Create a Hook.
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Parse and execute user-defined hooks.
#define MUTT_ICONV_HOOK
iconv-hook: create a system charset alias
#define MUTT_FOLDER_HOOK
folder-hook: when entering a mailbox
#define MUTT_SAVE_HOOK
save-hook: set a default folder when saving an email
#define MUTT_SEND_HOOK
send-hook: when composing a new email
uint32_t HookFlags
Flags for parse_hook(), e.g. MUTT_FOLDER_HOOK.
#define MUTT_FCC_HOOK
fcc-hook: to save outgoing email
#define MUTT_ACCOUNT_HOOK
account-hook: when changing between accounts
#define MUTT_STARTUP_HOOK
startup-hook: run when starting NeoMutt
#define MUTT_SEND2_HOOK
send2-hook: when changing fields in the compose menu
#define MUTT_CRYPT_HOOK
crypt-hook: automatically select a PGP/SMIME key
#define MUTT_MBOX_HOOK
mbox-hook: move messages after reading them
#define MUTT_REPLY_HOOK
reply-hook: when replying to an email
#define MUTT_TIMEOUT_HOOK
timeout-hook: run a command periodically
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
#define MUTT_SHUTDOWN_HOOK
shutdown-hook: run when leaving NeoMutt
#define MUTT_IDXFMTHOOK
index-format-hook: customise the format of the index
#define MUTT_CHARSET_HOOK
charset-hook: create a charset alias for malformed emails
#define MUTT_HOOK_NO_FLAGS
No flags are set.
GUI manage the main index (list of emails)
struct MailboxView * get_current_mailbox_view(void)
Get the current Mailbox view.
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
@ LL_DEBUG5
Log at debug level 5.
@ LL_DEBUG1
Log at debug level 1.
#define MUTT_MEM_CALLOC(n, type)
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err)
Add a new character set lookup.
LookupType
Types of character set lookups.
@ MUTT_LOOKUP_ICONV
Character set conversion.
@ MUTT_LOOKUP_CHARSET
Alias for another character set.
Convenience wrapper for the library headers.
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
void mutt_temp_attachments_cleanup(void)
Delete all temporary attachments.
void buf_expand_path_regex(struct Buffer *buf, bool regex)
Create the canonical path (with regex char escaping)
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
void mutt_safe_path(struct Buffer *dest, const struct Address *a)
Make a safe filename from an email address.
Some miscellaneous functions.
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
Match patterns to emails.
#define MUTT_PC_SEND_MODE_SEARCH
Allow send-mode body searching.
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
#define MUTT_PC_FULL_MSG
Enable body and header matching.
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
#define MUTT_PC_NO_FLAGS
No flags are set.
#define MUTT_PC_PATTERN_DYNAMIC
Enable runtime date range evaluation.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
#define TAILQ_HEAD(name, type)
#define TAILQ_INSERT_TAIL(head, elm, field)
#define TAILQ_FIRST(head)
#define SLIST_FIRST(head)
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_HEAD_INITIALIZER(head)
#define TAILQ_ENTRY(type)
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
#define MUTT_FORMAT_PLAIN
Do not prepend DISP_TO, DISP_CC ...
struct Buffer * mailbox
Mailbox and host address.
String manipulation buffer.
char * dptr
Current read/write position.
size_t dsize
Length of data.
char * data
Pointer to data.
enum CommandResult(* parse)(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
intptr_t data
Data or flags to pass to the command.
const char * name
Name of the command.
The envelope/body of an email.
struct Envelope * env
Envelope information.
struct AddressList to
Email's 'To' list.
struct AddressList reply_to
Email's 'reply-to'.
struct AddressList cc
Email's 'Cc' list.
struct AddressList bcc
Email's 'Bcc' list.
struct AddressList from
Email's 'From' list.
Definition of a format string.
struct PatternList * pattern
Used for fcc,save,send-hook.
struct Regex regex
Regular expression.
char * command
Filename, command or pattern to execute.
struct Expando * expando
Used for format hooks.
char * source_file
Used for relative-directory source.
char * pattern
Limit pattern string.
Container for Accounts, Notifications.
struct CommandArray commands
NeoMutt commands.
struct ConfigSubset * sub
Inherited config items.
Cache commonly-used patterns.
A simple (non-regex) pattern.
Cached regular expression.
char * pattern
printable version
regex_t * regex
compiled expression