NeoMutt  2025-12-11-58-g09398d
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
hook.c File Reference

Parse and execute user-defined hooks. More...

#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "hook.h"
#include "attach/lib.h"
#include "compmbox/lib.h"
#include "expando/lib.h"
#include "index/lib.h"
#include "parse/lib.h"
#include "pattern/lib.h"
#include "commands.h"
#include "globals.h"
#include "muttlib.h"
#include "mx.h"
+ Include dependency graph for hook.c:

Go to the source code of this file.

Data Structures

struct  Hook
 A list of user hooks. More...
 

Functions

 TAILQ_HEAD (HookList, Hook)
 
static void hook_free (struct Hook **ptr)
 Free a Hook.
 
static struct Hookhook_new (void)
 Create a Hook.
 
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_global (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse global hook commands - 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_mailbox (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse mailbox pattern 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_folder (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse folder hook command - 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() -.
 
enum CommandResult parse_hook_compress (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse compress hook commands - Implements Command::parse() -.
 
void mutt_delete_hooks (HookFlags type)
 Delete matching hooks.
 
static void idxfmt_hashelem_free (int type, void *obj, intptr_t data)
 Free our hash table data - Implements hash_hdata_free_t -.
 
static void delete_idxfmt_hooks (void)
 Delete all the index-format-hooks.
 
enum CommandResult parse_hook_index (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse the index format hook command - Implements Command::parse() -.
 
static HookFlags mutt_get_hook_type (const char *name)
 Find a hook by name.
 
enum CommandResult parse_unhook (const struct Command *cmd, struct Buffer *line, struct Buffer *err)
 Parse the unhook command - Implements Command::parse() -.
 
void mutt_folder_hook (const char *path, const char *desc)
 Perform a folder hook.
 
char * mutt_find_hook (HookFlags type, const char *pat)
 Find a matching hook.
 
void mutt_message_hook (struct Mailbox *m, struct Email *e, HookFlags type)
 Perform a message hook.
 
static int addr_hook (struct Buffer *path, HookFlags type, struct Mailbox *m, struct Email *e)
 Perform an address hook (get a path)
 
void mutt_default_save (struct Buffer *path, struct Email *e)
 Find the default save path for an email.
 
void mutt_select_fcc (struct Buffer *path, struct Email *e)
 Select the FCC path for an email.
 
static void list_hook (struct ListHead *matches, const char *match, HookFlags type)
 Find hook strings matching.
 
void mutt_crypt_hook (struct ListHead *list, struct Address *addr)
 Find crypto hooks for an Address.
 
void mutt_account_hook (const char *url)
 Perform an account hook.
 
void mutt_timeout_hook (void)
 Execute any timeout hooks.
 
void mutt_startup_shutdown_hook (HookFlags type)
 Execute any startup/shutdown hooks.
 
const struct Expandomutt_idxfmt_hook (const char *name, struct Mailbox *m, struct Email *e)
 Get index-format-hook format string.
 
void hooks_init (void)
 Setup feature commands.
 

Variables

const struct ExpandoDefinition IndexFormatDef []
 Expando definitions.
 
static struct HookList Hooks = TAILQ_HEAD_INITIALIZER(Hooks)
 All simple hooks, e.g. MUTT_FOLDER_HOOK.
 
static struct HashTableIdxFmtHooks = NULL
 All Index Format hooks.
 
static HookFlags CurrentHookType = MUTT_HOOK_NO_FLAGS
 The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.
 
static const struct Command HookCommands []
 Hook Commands.
 

Detailed Description

Parse and execute user-defined hooks.

Authors
  • Michael R. Elkins, and others
  • Thomas Adam
  • Richard Russon
  • Pietro Cerutti
  • Federico Kircheis
  • Naveen Nathan
  • Oliver Bandel
  • Dennis Schön
  • Tóth János

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file hook.c.

Function Documentation

◆ TAILQ_HEAD()

TAILQ_HEAD ( HookList ,
Hook  )

◆ hook_free()

static void hook_free ( struct Hook ** ptr)
static

Free a Hook.

Parameters
ptrHook to free

Definition at line 90 of file hook.c.

91{
92 if (!ptr || !*ptr)
93 return;
94
95 struct Hook *h = *ptr;
96
97 FREE(&h->command);
98 FREE(&h->source_file);
99 FREE(&h->regex.pattern);
100 if (h->regex.regex)
101 {
102 regfree(h->regex.regex);
103 FREE(&h->regex.regex);
104 }
107 FREE(ptr);
108}
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:774
void expando_free(struct Expando **ptr)
Free an Expando object.
Definition expando.c:61
#define FREE(x)
Definition memory.h:62
A list of user hooks.
Definition hook.c:66
struct PatternList * pattern
Used for fcc,save,send-hook.
Definition hook.c:71
struct Regex regex
Regular expression.
Definition hook.c:68
char * command
Filename, command or pattern to execute.
Definition hook.c:69
struct Expando * expando
Used for format hooks.
Definition hook.c:72
char * source_file
Used for relative-directory source.
Definition hook.c:70
char * pattern
printable version
Definition regex3.h:87
regex_t * regex
compiled expression
Definition regex3.h:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hook_new()

static struct Hook * hook_new ( void )
static

Create a Hook.

Return values
ptrNew Hook

Definition at line 114 of file hook.c.

115{
116 return MUTT_MEM_CALLOC(1, struct Hook);
117}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:47
+ Here is the caller graph for this function:

◆ mutt_delete_hooks()

void mutt_delete_hooks ( HookFlags type)

Delete matching hooks.

Parameters
typeHook type to delete, see HookFlags

If MUTT_HOOK_NO_FLAGS is passed, all the hooks will be deleted.

Definition at line 1029 of file hook.c.

1030{
1031 struct Hook *h = NULL;
1032 struct Hook *tmp = NULL;
1033
1034 TAILQ_FOREACH_SAFE(h, &Hooks, entries, tmp)
1035 {
1036 if ((type == MUTT_HOOK_NO_FLAGS) || (type == h->type))
1037 {
1038 TAILQ_REMOVE(&Hooks, h, entries);
1039 hook_free(&h);
1040 }
1041 }
1042}
static void hook_free(struct Hook **ptr)
Free a Hook.
Definition hook.c:90
static struct HookList Hooks
All simple hooks, e.g. MUTT_FOLDER_HOOK.
Definition hook.c:78
#define MUTT_HOOK_NO_FLAGS
No flags are set.
Definition hook.h:36
#define TAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition queue.h:792
#define TAILQ_REMOVE(head, elm, field)
Definition queue.h:901
HookFlags type
Hook type.
Definition hook.c:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete_idxfmt_hooks()

static void delete_idxfmt_hooks ( void )
static

Delete all the index-format-hooks.

Definition at line 1065 of file hook.c.

1066{
1068}
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:457
static struct HashTable * IdxFmtHooks
All Index Format hooks.
Definition hook.c:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_hook_type()

static HookFlags mutt_get_hook_type ( const char * name)
static

Find a hook by name.

Parameters
nameName to find
Return values
numHook ID, e.g. MUTT_FOLDER_HOOK
MUTT_HOOK_NO_FLAGSError, no matching hook

Definition at line 1197 of file hook.c.

1198{
1199 const struct Command **cp = NULL;
1201 {
1202 const struct Command *cmd = *cp;
1203
1204 if (((cmd->parse == parse_hook_index) || (cmd->parse == parse_hook_global) ||
1205 (cmd->parse == parse_hook_pattern) ||
1206 (cmd->parse == parse_hook_mailbox) || (cmd->parse == parse_hook_regex) ||
1207 (cmd->parse == parse_hook_folder) || (cmd->parse == parse_hook_crypt) ||
1208 (cmd->parse == parse_hook_mbox) || (cmd->parse == parse_hook_compress)) &&
1209 mutt_istr_equal(cmd->name, name))
1210 {
1211 return cmd->data;
1212 }
1213 }
1214 return MUTT_HOOK_NO_FLAGS;
1215}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:214
enum CommandResult parse_hook_folder(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse folder hook command - Implements Command::parse() -.
Definition hook.c:550
enum CommandResult parse_hook_pattern(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse pattern-based hook commands - Implements Command::parse() -.
Definition hook.c:241
enum CommandResult parse_hook_regex(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse regex-based hook command - Implements Command::parse() -.
Definition hook.c:457
enum CommandResult parse_hook_compress(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse compress hook commands - Implements Command::parse() -.
Definition hook.c:927
enum CommandResult parse_hook_index(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the index format hook command - Implements Command::parse() -.
Definition hook.c:1076
enum CommandResult parse_hook_mailbox(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse mailbox pattern hook commands - Implements Command::parse() -.
Definition hook.c:348
enum CommandResult parse_hook_global(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse global hook commands - Implements Command::parse() -.
Definition hook.c:178
enum CommandResult parse_hook_crypt(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse crypt hook commands - Implements Command::parse() -.
Definition hook.c:687
enum CommandResult parse_hook_mbox(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse mbox hook command - Implements Command::parse() -.
Definition hook.c:780
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:672
enum CommandResult(* parse)(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Definition command.h:75
intptr_t data
Data or flags to pass to the command.
Definition command.h:77
const char * name
Name of the command.
Definition command.h:59
Container for Accounts, Notifications.
Definition neomutt.h:43
struct CommandArray commands
NeoMutt commands.
Definition neomutt.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_folder_hook()

void mutt_folder_hook ( const char * path,
const char * desc )

Perform a folder hook.

Parameters
pathPath to potentially match
descDescription to potentially match

Definition at line 1291 of file hook.c.

1292{
1293 if (!path && !desc)
1294 return;
1295
1296 struct Hook *hook = NULL;
1297 struct Buffer *err = buf_pool_get();
1298
1300
1301 TAILQ_FOREACH(hook, &Hooks, entries)
1302 {
1303 if (!hook->command)
1304 continue;
1305
1306 if (!(hook->type & MUTT_FOLDER_HOOK))
1307 continue;
1308
1309 const char *match = NULL;
1310 if (mutt_regex_match(&hook->regex, path))
1311 match = path;
1312 else if (mutt_regex_match(&hook->regex, desc))
1313 match = desc;
1314
1315 if (match)
1316 {
1317 mutt_debug(LL_DEBUG1, "folder-hook '%s' matches '%s'\n", hook->regex.pattern, match);
1318 mutt_debug(LL_DEBUG5, " %s\n", hook->command);
1319 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
1320 {
1321 mutt_error("%s", buf_string(err));
1322 break;
1323 }
1324 }
1325 }
1326 buf_pool_release(&err);
1327
1329}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:36
enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct Buffer *err)
Parse and run a muttrc line in a relative directory.
Definition commands.c:179
#define mutt_error(...)
Definition logging2.h:93
#define mutt_debug(LEVEL,...)
Definition logging2.h:90
static HookFlags CurrentHookType
The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.
Definition hook.c:84
#define MUTT_FOLDER_HOOK
folder-hook: when entering a mailbox
Definition hook.h:37
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:48
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:44
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture()
Definition regex.c:613
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
String manipulation buffer.
Definition buffer.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_find_hook()

char * mutt_find_hook ( HookFlags type,
const char * pat )

Find a matching hook.

Parameters
typeHook type, see HookFlags
patPattern to match
Return values
ptrCommand string
Note
The returned string must not be freed.

Definition at line 1339 of file hook.c.

1340{
1341 struct Hook *tmp = NULL;
1342
1343 TAILQ_FOREACH(tmp, &Hooks, entries)
1344 {
1345 if (tmp->type & type)
1346 {
1347 if (mutt_regex_match(&tmp->regex, pat))
1348 return tmp->command;
1349 }
1350 }
1351 return NULL;
1352}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_message_hook()

void mutt_message_hook ( struct Mailbox * m,
struct Email * e,
HookFlags type )

Perform a message hook.

Parameters
mMailbox
eEmail
typeHook type, see HookFlags

Definition at line 1360 of file hook.c.

1361{
1362 struct Hook *hook = NULL;
1363 struct PatternCache cache = { 0 };
1364 struct Buffer *err = buf_pool_get();
1365
1366 CurrentHookType = type;
1367
1368 TAILQ_FOREACH(hook, &Hooks, entries)
1369 {
1370 if (!hook->command)
1371 continue;
1372
1373 if (hook->type & type)
1374 {
1375 if ((mutt_pattern_exec(SLIST_FIRST(hook->pattern), 0, m, e, &cache) > 0) ^
1376 hook->regex.pat_not)
1377 {
1378 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
1379 {
1380 mutt_error("%s", buf_string(err));
1382 buf_pool_release(&err);
1383
1384 return;
1385 }
1386 /* Executing arbitrary commands could affect the pattern results,
1387 * so the cache has to be wiped */
1388 memset(&cache, 0, sizeof(cache));
1389 }
1390 }
1391 }
1392 buf_pool_release(&err);
1393
1395}
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.
Definition exec.c:1148
#define SLIST_FIRST(head)
Definition queue.h:227
Cache commonly-used patterns.
Definition lib.h:117
bool pat_not
do not match
Definition regex3.h:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addr_hook()

static int addr_hook ( struct Buffer * path,
HookFlags type,
struct Mailbox * m,
struct Email * e )
static

Perform an address hook (get a path)

Parameters
pathBuffer for path
typeHook type, see HookFlags
mMailbox
eEmail
Return values
0Success
-1Failure

Definition at line 1406 of file hook.c.

1407{
1408 struct Hook *hook = NULL;
1409 struct PatternCache cache = { 0 };
1410
1411 /* determine if a matching hook exists */
1412 TAILQ_FOREACH(hook, &Hooks, entries)
1413 {
1414 if (!hook->command)
1415 continue;
1416
1417 if (hook->type & type)
1418 {
1419 if ((mutt_pattern_exec(SLIST_FIRST(hook->pattern), 0, m, e, &cache) > 0) ^
1420 hook->regex.pat_not)
1421 {
1422 buf_alloc(path, PATH_MAX);
1423 mutt_make_string(path, -1, hook->expando, m, -1, e, MUTT_FORMAT_PLAIN, NULL);
1424 buf_fix_dptr(path);
1425 return 0;
1426 }
1427 }
1428 }
1429
1430 return -1;
1431}
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition buffer.c:182
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:337
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.
Definition dlg_index.c:802
#define PATH_MAX
Definition mutt.h:42
#define MUTT_FORMAT_PLAIN
Do not prepend DISP_TO, DISP_CC ...
Definition render.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_default_save()

void mutt_default_save ( struct Buffer * path,
struct Email * e )

Find the default save path for an email.

Parameters
pathBuffer for the path
eEmail

Definition at line 1438 of file hook.c.

1439{
1440 struct Mailbox *m_cur = get_current_mailbox();
1441 if (addr_hook(path, MUTT_SAVE_HOOK, m_cur, e) == 0)
1442 return;
1443
1444 struct Envelope *env = e->env;
1445 const struct Address *from = TAILQ_FIRST(&env->from);
1446 const struct Address *reply_to = TAILQ_FIRST(&env->reply_to);
1447 const struct Address *to = TAILQ_FIRST(&env->to);
1448 const struct Address *cc = TAILQ_FIRST(&env->cc);
1449 const struct Address *addr = NULL;
1450 bool from_me = mutt_addr_is_user(from);
1451
1452 if (!from_me && reply_to && reply_to->mailbox)
1453 addr = reply_to;
1454 else if (!from_me && from && from->mailbox)
1455 addr = from;
1456 else if (to && to->mailbox)
1457 addr = to;
1458 else if (cc && cc->mailbox)
1459 addr = cc;
1460 else
1461 addr = NULL;
1462 if (addr)
1463 {
1464 struct Buffer *tmp = buf_pool_get();
1465 mutt_safe_path(tmp, addr);
1466 buf_add_printf(path, "=%s", buf_string(tmp));
1467 buf_pool_release(&tmp);
1468 }
1469}
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition alias.c:595
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition buffer.c:204
static int addr_hook(struct Buffer *path, HookFlags type, struct Mailbox *m, struct Email *e)
Perform an address hook (get a path)
Definition hook.c:1406
#define MUTT_SAVE_HOOK
save-hook: set a default folder when saving an email
Definition hook.h:41
struct Mailbox * get_current_mailbox(void)
Get the current Mailbox.
Definition index.c:721
void mutt_safe_path(struct Buffer *dest, const struct Address *a)
Make a safe filename from an email address.
Definition muttlib.c:681
#define TAILQ_FIRST(head)
Definition queue.h:780
An email address.
Definition address.h:35
struct Buffer * mailbox
Mailbox and host address.
Definition address.h:37
struct Envelope * env
Envelope information.
Definition email.h:68
The header of an Email.
Definition envelope.h:57
struct AddressList to
Email's 'To' list.
Definition envelope.h:60
struct AddressList reply_to
Email's 'reply-to'.
Definition envelope.h:64
struct AddressList cc
Email's 'Cc' list.
Definition envelope.h:61
struct AddressList from
Email's 'From' list.
Definition envelope.h:59
A mailbox.
Definition mailbox.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_select_fcc()

void mutt_select_fcc ( struct Buffer * path,
struct Email * e )

Select the FCC path for an email.

Parameters
pathBuffer for the path
eEmail

Definition at line 1476 of file hook.c.

1477{
1478 buf_alloc(path, PATH_MAX);
1479
1480 if (addr_hook(path, MUTT_FCC_HOOK, NULL, e) != 0)
1481 {
1482 const struct Address *to = TAILQ_FIRST(&e->env->to);
1483 const struct Address *cc = TAILQ_FIRST(&e->env->cc);
1484 const struct Address *bcc = TAILQ_FIRST(&e->env->bcc);
1485 const bool c_save_name = cs_subset_bool(NeoMutt->sub, "save_name");
1486 const bool c_force_name = cs_subset_bool(NeoMutt->sub, "force_name");
1487 const char *const c_record = cs_subset_string(NeoMutt->sub, "record");
1488 if ((c_save_name || c_force_name) && (to || cc || bcc))
1489 {
1490 const struct Address *addr = to ? to : (cc ? cc : bcc);
1491 struct Buffer *buf = buf_pool_get();
1492 mutt_safe_path(buf, addr);
1493 const char *const c_folder = cs_subset_string(NeoMutt->sub, "folder");
1494 buf_concat_path(path, NONULL(c_folder), buf_string(buf));
1495 buf_pool_release(&buf);
1496 if (!c_force_name && (mx_access(buf_string(path), W_OK) != 0))
1497 buf_strcpy(path, c_record);
1498 }
1499 else
1500 {
1501 buf_strcpy(path, c_record);
1502 }
1503 }
1504 else
1505 {
1506 buf_fix_dptr(path);
1507 }
1508
1509 buf_pretty_mailbox(path);
1510}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
size_t buf_concat_path(struct Buffer *buf, const char *dir, const char *fname)
Join a directory name and a filename.
Definition buffer.c:509
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
#define MUTT_FCC_HOOK
fcc-hook: to save outgoing email
Definition hook.h:40
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:518
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
Definition mx.c:170
#define NONULL(x)
Definition string2.h:43
struct AddressList bcc
Email's 'Bcc' list.
Definition envelope.h:62
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ list_hook()

static void list_hook ( struct ListHead * matches,
const char * match,
HookFlags type )
static

Find hook strings matching.

Parameters
[out]matchesList of hook strings
[in]matchString to match
[in]typeHook type, see HookFlags

Definition at line 1518 of file hook.c.

1519{
1520 struct Hook *tmp = NULL;
1521
1522 TAILQ_FOREACH(tmp, &Hooks, entries)
1523 {
1524 if ((tmp->type & type) && mutt_regex_match(&tmp->regex, match))
1525 {
1527 }
1528 }
1529}
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition list.c:65
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:255
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_crypt_hook()

void mutt_crypt_hook ( struct ListHead * list,
struct Address * addr )

Find crypto hooks for an Address.

Parameters
[out]listList of keys
[in]addrAddress to match

The crypt-hook associates keys with addresses.

Definition at line 1538 of file hook.c.

1539{
1541}
static void list_hook(struct ListHead *matches, const char *match, HookFlags type)
Find hook strings matching.
Definition hook.c:1518
#define MUTT_CRYPT_HOOK
crypt-hook: automatically select a PGP/SMIME key
Definition hook.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_account_hook()

void mutt_account_hook ( const char * url)

Perform an account hook.

Parameters
urlAccount URL to match

Definition at line 1547 of file hook.c.

1548{
1549 /* parsing commands with URLs in an account hook can cause a recursive
1550 * call. We just skip processing if this occurs. Typically such commands
1551 * belong in a folder-hook -- perhaps we should warn the user. */
1552 static bool inhook = false;
1553 if (inhook)
1554 return;
1555
1556 struct Hook *hook = NULL;
1557 struct Buffer *err = buf_pool_get();
1558
1559 TAILQ_FOREACH(hook, &Hooks, entries)
1560 {
1561 if (!(hook->command && (hook->type & MUTT_ACCOUNT_HOOK)))
1562 continue;
1563
1564 if (mutt_regex_match(&hook->regex, url))
1565 {
1566 inhook = true;
1567 mutt_debug(LL_DEBUG1, "account-hook '%s' matches '%s'\n", hook->regex.pattern, url);
1568 mutt_debug(LL_DEBUG5, " %s\n", hook->command);
1569
1570 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
1571 {
1572 mutt_error("%s", buf_string(err));
1573 buf_pool_release(&err);
1574
1575 inhook = false;
1576 goto done;
1577 }
1578
1579 inhook = false;
1580 }
1581 }
1582done:
1583 buf_pool_release(&err);
1584}
#define MUTT_ACCOUNT_HOOK
account-hook: when changing between accounts
Definition hook.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_timeout_hook()

void mutt_timeout_hook ( void )

Execute any timeout hooks.

The user can configure hooks to be run on timeout. This function finds all the matching hooks and executes them.

Definition at line 1592 of file hook.c.

1593{
1594 struct Hook *hook = NULL;
1595 struct Buffer *err = buf_pool_get();
1596
1597 TAILQ_FOREACH(hook, &Hooks, entries)
1598 {
1599 if (!(hook->command && (hook->type & MUTT_TIMEOUT_HOOK)))
1600 continue;
1601
1602 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
1603 {
1604 mutt_error("%s", buf_string(err));
1605 buf_reset(err);
1606
1607 /* The hooks should be independent of each other, so even though this on
1608 * failed, we'll carry on with the others. */
1609 }
1610 }
1611 buf_pool_release(&err);
1612
1613 /* Delete temporary attachment files */
1615}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
#define MUTT_TIMEOUT_HOOK
timeout-hook: run a command periodically
Definition hook.h:53
void mutt_temp_attachments_cleanup(void)
Delete all temporary attachments.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_startup_shutdown_hook()

void mutt_startup_shutdown_hook ( HookFlags type)

Execute any startup/shutdown hooks.

Parameters
typeHook type: MUTT_STARTUP_HOOK or MUTT_SHUTDOWN_HOOK

The user can configure hooks to be run on startup/shutdown. This function finds all the matching hooks and executes them.

Definition at line 1624 of file hook.c.

1625{
1626 struct Hook *hook = NULL;
1627 struct Buffer *err = buf_pool_get();
1628
1629 TAILQ_FOREACH(hook, &Hooks, entries)
1630 {
1631 if (!(hook->command && (hook->type & type)))
1632 continue;
1633
1634 if (parse_rc_line_cwd(hook->command, hook->source_file, err) == MUTT_CMD_ERROR)
1635 {
1636 mutt_error("%s", buf_string(err));
1637 buf_reset(err);
1638 }
1639 }
1640 buf_pool_release(&err);
1641}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_idxfmt_hook()

const struct Expando * mutt_idxfmt_hook ( const char * name,
struct Mailbox * m,
struct Email * e )

Get index-format-hook format string.

Parameters
nameHook name
mMailbox
eEmail
Return values
ptrExpando
NULLNo matching hook

Definition at line 1651 of file hook.c.

1652{
1653 if (!IdxFmtHooks)
1654 return NULL;
1655
1656 struct HookList *hl = mutt_hash_find(IdxFmtHooks, name);
1657 if (!hl)
1658 return NULL;
1659
1661
1662 struct PatternCache cache = { 0 };
1663 const struct Expando *exp = NULL;
1664 struct Hook *hook = NULL;
1665
1666 TAILQ_FOREACH(hook, hl, entries)
1667 {
1668 struct Pattern *pat = SLIST_FIRST(hook->pattern);
1669 if ((mutt_pattern_exec(pat, 0, m, e, &cache) > 0) ^ hook->regex.pat_not)
1670 {
1671 exp = hook->expando;
1672 break;
1673 }
1674 }
1675
1677
1678 return exp;
1679}
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition hash.c:362
#define MUTT_IDXFMTHOOK
index-format-hook: customise the format of the index
Definition hook.h:52
Parsed Expando trees.
Definition expando.h:41
A simple (non-regex) pattern.
Definition lib.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hooks_init()

void hooks_init ( void )

Setup feature commands.

Definition at line 1769 of file hook.c.

1770{
1772}
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
static const struct Command HookCommands[]
Hook Commands.
Definition hook.c:1684
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ IndexFormatDef

const struct ExpandoDefinition IndexFormatDef
extern

Expando definitions.

Config:

  • $attribution_intro
  • $attribution_trailer
  • $forward_attribution_intro
  • $forward_attribution_trailer
  • $forward_format
  • $index_format
  • $message_format
  • $pager_format
Note
Longer Expandos must precede any similar, but shorter Expandos

Definition at line 320 of file mutt_config.c.

320 {
321 // clang-format off
322 { "*", "padding-soft", ED_GLOBAL, ED_GLO_PADDING_SOFT, node_padding_parse },
323 { ">", "padding-hard", ED_GLOBAL, ED_GLO_PADDING_HARD, node_padding_parse },
324 { "|", "padding-eol", ED_GLOBAL, ED_GLO_PADDING_EOL, node_padding_parse },
327 { "a", "from", ED_ENVELOPE, ED_ENV_FROM, NULL },
328 { "A", "reply-to", ED_ENVELOPE, ED_ENV_REPLY_TO, NULL },
329 { "b", "mailbox-name", ED_MAILBOX, ED_MBX_MAILBOX_NAME, NULL },
330 { "B", "list-address", ED_ENVELOPE, ED_ENV_LIST_ADDRESS, NULL },
331 { "cr", "body-characters", ED_EMAIL, ED_EMA_BODY_CHARACTERS, NULL },
332 { "c", "size", ED_EMAIL, ED_EMA_SIZE, NULL },
333 { "C", "number", ED_EMAIL, ED_EMA_NUMBER, NULL },
334 { "d", "date-format", ED_EMAIL, ED_EMA_DATE_FORMAT, NULL },
335 { "D", "date-format-local", ED_EMAIL, ED_EMA_DATE_FORMAT_LOCAL, NULL },
336 { "e", "thread-number", ED_EMAIL, ED_EMA_THREAD_NUMBER, NULL },
337 { "E", "thread-count", ED_EMAIL, ED_EMA_THREAD_COUNT, NULL },
338 { "f", "from-full", ED_ENVELOPE, ED_ENV_FROM_FULL, NULL },
339 { "Fp", "sender-plain", ED_ENVELOPE, ED_ENV_SENDER_PLAIN, NULL },
340 { "F", "sender", ED_ENVELOPE, ED_ENV_SENDER, NULL },
341 { "g", "tags", ED_EMAIL, ED_EMA_TAGS, NULL },
342 { "G", "tags-transformed", ED_EMAIL, ED_EMA_TAGS_TRANSFORMED, parse_tags_transformed },
343 { "H", "spam", ED_ENVELOPE, ED_ENV_SPAM, NULL },
344 { "i", "message-id", ED_ENVELOPE, ED_ENV_MESSAGE_ID, NULL },
345 { "I", "initials", ED_ENVELOPE, ED_ENV_INITIALS, NULL },
346 { "J", "thread-tags", ED_EMAIL, ED_EMA_THREAD_TAGS, NULL },
347 { "K", "list-empty", ED_ENVELOPE, ED_ENV_LIST_EMPTY, NULL },
348 { "l", "lines", ED_EMAIL, ED_EMA_LINES, NULL },
349 { "L", "from-list", ED_EMAIL, ED_EMA_FROM_LIST, NULL },
350 { "m", "message-count", ED_MAILBOX, ED_MBX_MESSAGE_COUNT, NULL },
351 { "M", "thread-hidden-count", ED_EMAIL, ED_EMA_THREAD_HIDDEN_COUNT, NULL },
352 { "n", "name", ED_ENVELOPE, ED_ENV_NAME, NULL },
353 { "N", "score", ED_EMAIL, ED_EMA_SCORE, NULL },
354 { "O", "save-folder", ED_EMAIL, ED_EMA_LIST_OR_SAVE_FOLDER, NULL },
355 { "P", "percentage", ED_MAILBOX, ED_MBX_PERCENTAGE, NULL },
356 { "q", "newsgroup", ED_ENVELOPE, ED_ENV_NEWSGROUP, NULL },
357 { "r", "to-all", ED_ENVELOPE, ED_ENV_TO_ALL, NULL },
358 { "R", "cc-all", ED_ENVELOPE, ED_ENV_CC_ALL, NULL },
359 { "s", "subject", ED_ENVELOPE, ED_ENV_SUBJECT, parse_subject },
360 { "S", "flag-chars", ED_EMAIL, ED_EMA_FLAG_CHARS, NULL },
361 { "t", "to", ED_ENVELOPE, ED_ENV_TO, NULL },
362 { "T", "to-chars", ED_EMAIL, ED_EMA_TO_CHARS, NULL },
363 { "u", "username", ED_ENVELOPE, ED_ENV_USERNAME, NULL },
364 { "v", "first-name", ED_ENVELOPE, ED_ENV_FIRST_NAME, NULL },
365 { "W", "organization", ED_ENVELOPE, ED_ENV_ORGANIZATION, NULL },
366 { "x", "x-comment-to", ED_ENVELOPE, ED_ENV_X_COMMENT_TO, NULL },
367 { "X", "attachment-count", ED_EMAIL, ED_EMA_ATTACHMENT_COUNT, NULL },
368 { "y", "x-label", ED_ENVELOPE, ED_ENV_X_LABEL, NULL },
369 { "Y", "thread-x-label", ED_ENVELOPE, ED_ENV_THREAD_X_LABEL, NULL },
370 { "Z", "combined-flags", ED_EMAIL, ED_EMA_COMBINED_FLAGS, NULL },
371 { "zc", "crypto-flags", ED_EMAIL, ED_EMA_CRYPTO_FLAGS, NULL },
372 { "zs", "status-flags", ED_EMAIL, ED_EMA_STATUS_FLAGS, NULL },
373 { "zt", "message-flags", ED_EMAIL, ED_EMA_MESSAGE_FLAGS, NULL },
376 { NULL, NULL, 0, -1, NULL }
377 // clang-format on
378};
@ ED_MBX_MESSAGE_COUNT
Mailbox.msg_count.
Definition mailbox.h:159
@ ED_MBX_PERCENTAGE
EmailFormatInfo.pager_progress.
Definition mailbox.h:160
@ ED_MBX_MAILBOX_NAME
Mailbox, mailbox_path()
Definition mailbox.h:158
@ ED_ENVELOPE
Envelope ED_ENV_ ExpandoDataEnvelope.
Definition domain.h:42
@ ED_EMAIL
Email ED_EMA_ ExpandoDataEmail.
Definition domain.h:41
@ ED_GLOBAL
Global ED_GLO_ ExpandoDataGlobal.
Definition domain.h:44
@ ED_MAILBOX
Mailbox ED_MBX_ ExpandoDataMailbox.
Definition domain.h:47
@ ED_EMA_DATE_STRF_LOCAL
Email.date_sent.
Definition email.h:143
@ ED_EMA_ATTACHMENT_COUNT
Email, mutt_count_body_parts()
Definition email.h:136
@ ED_EMA_DATE_FORMAT_LOCAL
Email.date_sent.
Definition email.h:141
@ ED_EMA_TAGS_TRANSFORMED
Email.tags, driver_tags_get_transformed()
Definition email.h:156
@ ED_EMA_THREAD_HIDDEN_COUNT
Email.collapsed, Email.num_hidden, ...
Definition email.h:158
@ ED_EMA_DATE_FORMAT
Email.date_sent.
Definition email.h:140
@ ED_EMA_THREAD_TAGS
Email.tags.
Definition email.h:160
@ ED_EMA_TAGS
Email.tags.
Definition email.h:155
@ ED_EMA_SIZE
Body.length.
Definition email.h:152
@ ED_EMA_FLAG_CHARS
Email.deleted, Email.attach_del, ...
Definition email.h:144
@ ED_EMA_THREAD_NUMBER
Email, mutt_messages_in_thread()
Definition email.h:159
@ ED_EMA_TO_CHARS
Email, User_is_recipient()
Definition email.h:161
@ ED_EMA_BODY_CHARACTERS
Body.length.
Definition email.h:137
@ ED_EMA_COMBINED_FLAGS
Email.read, Email.old, thread_is_new(), ...
Definition email.h:138
@ ED_EMA_THREAD_COUNT
Email, mutt_messages_in_thread()
Definition email.h:157
@ ED_EMA_STATUS_FLAGS
Email.deleted, Email.attach_del, ...
Definition email.h:153
@ ED_EMA_NUMBER
Email.msgno.
Definition email.h:150
@ ED_EMA_DATE_STRF
Email.date_sent, Email.zhours, Email.zminutes, Email.zoccident.
Definition email.h:142
@ ED_EMA_FROM_LIST
Envelope.to, Envelope.cc.
Definition email.h:145
@ ED_EMA_SCORE
Email.score.
Definition email.h:151
@ ED_EMA_CRYPTO_FLAGS
Email.security, SecurityFlags.
Definition email.h:139
@ ED_EMA_STRF_RECV_LOCAL
Email.received.
Definition email.h:154
@ ED_EMA_LIST_OR_SAVE_FOLDER
Envelope.to, Envelope.cc, check_for_mailing_list()
Definition email.h:148
@ ED_EMA_INDEX_HOOK
Mailbox, Email, mutt_idxfmt_hook()
Definition email.h:146
@ ED_EMA_LINES
Email.lines.
Definition email.h:147
@ ED_EMA_MESSAGE_FLAGS
Email.tagged, Email.flagged.
Definition email.h:149
@ ED_ENV_SUBJECT
Envelope.subject, Envelope.disp_subj.
Definition envelope.h:116
@ ED_ENV_NEWSGROUP
Envelope.newsgroups.
Definition envelope.h:109
@ ED_ENV_INITIALS
Envelope.from (first)
Definition envelope.h:104
@ ED_ENV_FROM_FULL
Envelope.from (all)
Definition envelope.h:103
@ ED_ENV_X_COMMENT_TO
Envelope.x_comment_to.
Definition envelope.h:123
@ ED_ENV_FROM
Envelope.from (first)
Definition envelope.h:102
@ ED_ENV_LIST_ADDRESS
Envelope.to, Envelope.cc.
Definition envelope.h:105
@ ED_ENV_SPAM
Envelope.spam.
Definition envelope.h:115
@ ED_ENV_SENDER
Envelope, make_from()
Definition envelope.h:113
@ ED_ENV_TO_ALL
Envelope.to (all)
Definition envelope.h:120
@ ED_ENV_X_LABEL
Envelope.x_label.
Definition envelope.h:124
@ ED_ENV_NAME
Envelope.from (first)
Definition envelope.h:108
@ ED_ENV_CC_ALL
Envelope.cc.
Definition envelope.h:100
@ ED_ENV_ORGANIZATION
Envelope.organization.
Definition envelope.h:110
@ ED_ENV_REPLY_TO
Envelope.reply_to.
Definition envelope.h:112
@ ED_ENV_LIST_EMPTY
Envelope.to, Envelope.cc.
Definition envelope.h:106
@ ED_ENV_THREAD_X_LABEL
Envelope.x_label.
Definition envelope.h:118
@ ED_ENV_MESSAGE_ID
Envelope.message_id.
Definition envelope.h:107
@ ED_ENV_SENDER_PLAIN
Envelope, make_from()
Definition envelope.h:114
@ ED_ENV_USERNAME
Envelope.from.
Definition envelope.h:121
@ ED_ENV_TO
Envelope.to, Envelope.cc (first)
Definition envelope.h:119
@ ED_ENV_FIRST_NAME
Envelope.from, Envelope.to, Envelope.cc.
Definition envelope.h:101
struct ExpandoNode * node_padding_parse(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Padding Expando - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_index_hook(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse an index-hook - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_subject(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Subject Expando - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_index_date_recv_local(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Date Expando - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_index_date_local(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Date Expando - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_index_date(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Date Expando - Implements ExpandoDefinition::parse() -.
struct ExpandoNode * parse_tags_transformed(const char *str, struct ExpandoFormat *fmt, int did, int uid, ExpandoParserFlags flags, const char **parsed_until, struct ExpandoParseError *err)
Parse a Tags-Transformed Expando - Implements ExpandoDefinition::parse() -.
@ ED_GLO_PADDING_EOL
Padding to end-of-line.
Definition uid.h:38
@ ED_GLO_PADDING_HARD
Hard Padding.
Definition uid.h:39
@ ED_GLO_PADDING_SOFT
Soft Padding.
Definition uid.h:40

◆ Hooks

struct HookList Hooks = TAILQ_HEAD_INITIALIZER(Hooks)
static

All simple hooks, e.g. MUTT_FOLDER_HOOK.

Definition at line 78 of file hook.c.

◆ IdxFmtHooks

struct HashTable* IdxFmtHooks = NULL
static

All Index Format hooks.

Definition at line 81 of file hook.c.

◆ CurrentHookType

HookFlags CurrentHookType = MUTT_HOOK_NO_FLAGS
static

The type of the hook currently being executed, e.g. MUTT_SAVE_HOOK.

Definition at line 84 of file hook.c.

◆ HookCommands

const struct Command HookCommands[]
static

Hook Commands.

Definition at line 1684 of file hook.c.

1684 {
1685 // clang-format off
1686 { "account-hook", parse_hook_regex, MUTT_ACCOUNT_HOOK,
1687 N_("Run a command when switching to a matching account"),
1688 N_("account-hook <regex> <command>"),
1689 "optionalfeatures.html#account-hook" },
1690 { "charset-hook", parse_hook_charset, MUTT_CHARSET_HOOK,
1691 N_("Define charset alias for languages"),
1692 N_("charset-hook <alias> <charset>"),
1693 "configuration.html#charset-hook" },
1694 { "crypt-hook", parse_hook_crypt, MUTT_CRYPT_HOOK,
1695 N_("Specify which keyid to use for recipients matching regex"),
1696 N_("crypt-hook <regex> <keyid>"),
1697 "configuration.html#crypt-hook" },
1698 { "fcc-hook", parse_hook_mailbox, MUTT_FCC_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" },
1702 { "fcc-save-hook", parse_hook_mailbox, MUTT_FCC_HOOK | MUTT_SAVE_HOOK,
1703 N_("Equivalent to both `fcc-hook` and `save-hook`"),
1704 N_("fcc-save-hook <pattern> <mailbox>"),
1705 "configuration.html#default-save-mailbox" },
1706 { "folder-hook", parse_hook_folder, MUTT_FOLDER_HOOK,
1707 N_("Run a command upon entering a folder matching regex"),
1708 N_("folder-hook [ -noregex ] <regex> <command>"),
1709 "configuration.html#folder-hook" },
1710 { "iconv-hook", parse_hook_charset, MUTT_ICONV_HOOK,
1711 N_("Define a system-specific alias for a character set"),
1712 N_("iconv-hook <charset> <local-charset>"),
1713 "configuration.html#charset-hook" },
1714 { "index-format-hook", parse_hook_index, MUTT_IDXFMTHOOK,
1715 N_("Create dynamic index format strings"),
1716 N_("index-format-hook <name> [ ! ]<pattern> <format-string>"),
1717 "configuration.html#index-format-hook" },
1718 { "mbox-hook", parse_hook_mbox, MUTT_MBOX_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" },
1722 { "message-hook", parse_hook_pattern, MUTT_MESSAGE_HOOK,
1723 N_("Run a command when viewing a message matching patterns"),
1724 N_("message-hook <pattern> <command>"),
1725 "configuration.html#message-hook" },
1726 { "reply-hook", parse_hook_pattern, MUTT_REPLY_HOOK,
1727 N_("Run a command when replying to messages matching a pattern"),
1728 N_("reply-hook <pattern> <command>"),
1729 "configuration.html#send-hook" },
1730 { "save-hook", parse_hook_mailbox, MUTT_SAVE_HOOK,
1731 N_("Set default save folder for messages"),
1732 N_("save-hook <pattern> <mailbox>"),
1733 "configuration.html#default-save-mailbox" },
1734 { "send-hook", parse_hook_pattern, MUTT_SEND_HOOK,
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" },
1738 { "send2-hook", parse_hook_pattern, MUTT_SEND2_HOOK,
1739 N_("Run command whenever a composed message is edited"),
1740 N_("send2-hook <pattern> <command>"),
1741 "configuration.html#send-hook" },
1742 { "shutdown-hook", parse_hook_global, MUTT_SHUTDOWN_HOOK,
1743 N_("Run a command before NeoMutt exits"),
1744 N_("shutdown-hook <command>"),
1745 "optionalfeatures.html#global-hooks" },
1746 { "startup-hook", parse_hook_global, MUTT_STARTUP_HOOK,
1747 N_("Run a command when NeoMutt starts up"),
1748 N_("startup-hook <command>"),
1749 "optionalfeatures.html#global-hooks" },
1750 { "timeout-hook", parse_hook_global, MUTT_TIMEOUT_HOOK,
1751 N_("Run a command after a specified timeout or idle period"),
1752 N_("timeout-hook <command>"),
1753 "optionalfeatures.html#global-hooks" },
1754 { "unhook", parse_unhook, 0,
1755 N_("Remove hooks of a given type"),
1756 N_("unhook { * | <hook-type> }"),
1757 "configuration.html#unhook" },
1758
1759 // Deprecated
1760 { "pgp-hook", parse_hook_crypt, MUTT_CRYPT_HOOK, NULL, NULL, NULL, CF_SYNONYM },
1761
1762 { NULL, NULL, 0, NULL, NULL, NULL, CF_NO_FLAGS },
1763 // clang-format on
1764};
#define CF_SYNONYM
Command is a synonym for another command.
Definition command.h:47
#define CF_NO_FLAGS
No flags are set.
Definition command.h:46
enum CommandResult parse_unhook(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse the unhook command - Implements Command::parse() -.
Definition hook.c:1223
enum CommandResult parse_hook_charset(const struct Command *cmd, struct Buffer *line, struct Buffer *err)
Parse charset hook commands - Implements Command::parse() -.
Definition hook.c:126
#define MUTT_ICONV_HOOK
iconv-hook: create a system charset alias
Definition hook.h:43
#define MUTT_SEND_HOOK
send-hook: when composing a new email
Definition hook.h:39
#define MUTT_STARTUP_HOOK
startup-hook: run when starting NeoMutt
Definition hook.h:54
#define MUTT_SEND2_HOOK
send2-hook: when changing fields in the compose menu
Definition hook.h:48
#define MUTT_MBOX_HOOK
mbox-hook: move messages after reading them
Definition hook.h:38
#define MUTT_REPLY_HOOK
reply-hook: when replying to an email
Definition hook.h:47
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition hook.h:44
#define MUTT_SHUTDOWN_HOOK
shutdown-hook: run when leaving NeoMutt
Definition hook.h:55
#define MUTT_CHARSET_HOOK
charset-hook: create a charset alias for malformed emails
Definition hook.h:42
#define N_(a)
Definition message.h:32