NeoMutt
2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
command.h
Go to the documentation of this file.
1
22
23
#ifndef MUTT_CORE_COMMAND_H
24
#define MUTT_CORE_COMMAND_H
25
26
#include <stdbool.h>
27
#include <stdint.h>
28
#include "
mutt/lib.h
"
29
30
struct
ParseContext
;
31
struct
ParseError
;
32
36
enum
CommandResult
37
{
38
MUTT_CMD_ERROR
= -1,
39
MUTT_CMD_WARNING
= -2,
40
MUTT_CMD_SUCCESS
= 0,
41
MUTT_CMD_FINISH
= 1
42
};
43
47
typedef
uint8_t
CommandFlags
;
48
#define CF_NO_FLAGS 0
49
#define CF_SYNONYM (1 << 0)
50
#define CF_DEPRECATED (1 << 1)
51
57
enum
CommandId
58
{
59
CMD_NONE
= 0,
60
CMD_ACCOUNT_HOOK
,
61
CMD_ALIAS
,
62
CMD_ALTERNATES
,
63
CMD_ALTERNATIVE_ORDER
,
64
CMD_APPEND_HOOK
,
65
CMD_ATTACHMENTS
,
66
CMD_AUTO_VIEW
,
67
CMD_BIND
,
68
CMD_CD
,
69
CMD_CHARSET_HOOK
,
70
CMD_CLOSE_HOOK
,
71
CMD_COLOR
,
72
CMD_CRYPT_HOOK
,
73
CMD_ECHO
,
74
CMD_EXEC
,
75
CMD_FCC_HOOK
,
76
CMD_FCC_SAVE_HOOK
,
77
CMD_FINISH
,
78
CMD_FOLDER_HOOK
,
79
CMD_GROUP
,
80
CMD_HEADER_ORDER
,
81
CMD_HOOKS
,
82
CMD_ICONV_HOOK
,
83
CMD_IFDEF
,
84
CMD_IFNDEF
,
85
CMD_IGNORE
,
86
CMD_INDEX_FORMAT_HOOK
,
87
CMD_LISTS
,
88
CMD_LUA
,
89
CMD_LUA_SOURCE
,
90
CMD_MACRO
,
91
CMD_MAILBOXES
,
92
CMD_MAILTO_ALLOW
,
93
CMD_MBOX_HOOK
,
94
CMD_MESSAGE_HOOK
,
95
CMD_MIME_LOOKUP
,
96
CMD_MONO
,
97
CMD_MY_HEADER
,
98
CMD_NAMED_MAILBOXES
,
99
CMD_NOSPAM
,
100
CMD_OPEN_HOOK
,
101
CMD_PUSH
,
102
CMD_REPLY_HOOK
,
103
CMD_RESET
,
104
CMD_SAVE_HOOK
,
105
CMD_SCORE
,
106
CMD_SEND2_HOOK
,
107
CMD_SEND_HOOK
,
108
CMD_SET
,
109
CMD_SETENV
,
110
CMD_SHUTDOWN_HOOK
,
111
CMD_SIDEBAR_PIN
,
112
CMD_SIDEBAR_UNPIN
,
113
CMD_SOURCE
,
114
CMD_SPAM
,
115
CMD_STARTUP_HOOK
,
116
CMD_SUBJECT_REGEX
,
117
CMD_SUBSCRIBE
,
118
CMD_SUBSCRIBE_TO
,
119
CMD_TAG_FORMATS
,
120
CMD_TAG_TRANSFORMS
,
121
CMD_TIMEOUT_HOOK
,
122
CMD_TOGGLE
,
123
CMD_UNALIAS
,
124
CMD_UNALTERNATES
,
125
CMD_UNALTERNATIVE_ORDER
,
126
CMD_UNATTACHMENTS
,
127
CMD_UNAUTO_VIEW
,
128
CMD_UNBIND
,
129
CMD_UNCOLOR
,
130
CMD_UNGROUP
,
131
CMD_UNHEADER_ORDER
,
132
CMD_UNHOOK
,
133
CMD_UNIGNORE
,
134
CMD_UNLISTS
,
135
CMD_UNMACRO
,
136
CMD_UNMAILBOXES
,
137
CMD_UNMAILTO_ALLOW
,
138
CMD_UNMIME_LOOKUP
,
139
CMD_UNMONO
,
140
CMD_UNMY_HEADER
,
141
CMD_UNSCORE
,
142
CMD_UNSET
,
143
CMD_UNSETENV
,
144
CMD_UNSUBJECT_REGEX
,
145
CMD_UNSUBSCRIBE
,
146
CMD_UNSUBSCRIBE_FROM
,
147
CMD_VERSION
,
148
};
149
157
struct
Command
158
{
159
const
char
*
name
;
160
enum
CommandId
id
;
161
178
enum
CommandResult
(*
parse
)(
const
struct
Command
*cmd,
struct
Buffer
*line,
const
struct
ParseContext
*pc,
struct
ParseError
*pe);
179
180
const
char
*
help
;
181
const
char
*
proto
;
182
const
char
*
path
;
183
184
CommandFlags
flags
;
185
};
186
ARRAY_HEAD
(CommandArray,
const
struct
Command
*);
187
188
const
struct
Command
*
commands_get
(
struct
CommandArray *ca,
const
char
*
name
);
189
void
commands_clear
(
struct
CommandArray *ca);
190
bool
commands_register
(
struct
CommandArray *ca,
const
struct
Command
*cmds);
191
192
#endif
/* MUTT_CORE_COMMAND_H */
ARRAY_HEAD
#define ARRAY_HEAD(name, T)
Define a named struct for arrays of elements of a certain type.
Definition
array.h:47
commands_register
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition
command.c:51
commands_get
const struct Command * commands_get(struct CommandArray *ca, const char *name)
Get a Command by its name.
Definition
command.c:82
commands_clear
void commands_clear(struct CommandArray *ca)
Clear an Array of Commands.
Definition
command.c:70
CommandId
CommandId
ID of Command.
Definition
command.h:58
CMD_CLOSE_HOOK
@ CMD_CLOSE_HOOK
:close-hook
Definition
command.h:70
CMD_MIME_LOOKUP
@ CMD_MIME_LOOKUP
:mime-lookup
Definition
command.h:95
CMD_SPAM
@ CMD_SPAM
:spam
Definition
command.h:114
CMD_SUBSCRIBE
@ CMD_SUBSCRIBE
:subscribe
Definition
command.h:117
CMD_UNSUBSCRIBE
@ CMD_UNSUBSCRIBE
:unsubscribe
Definition
command.h:145
CMD_UNALIAS
@ CMD_UNALIAS
:unalias
Definition
command.h:123
CMD_IGNORE
@ CMD_IGNORE
:ignore
Definition
command.h:85
CMD_GROUP
@ CMD_GROUP
:group
Definition
command.h:79
CMD_SEND_HOOK
@ CMD_SEND_HOOK
:send-hook
Definition
command.h:107
CMD_CD
@ CMD_CD
:cd
Definition
command.h:68
CMD_TAG_TRANSFORMS
@ CMD_TAG_TRANSFORMS
:tag-transforms
Definition
command.h:120
CMD_FCC_SAVE_HOOK
@ CMD_FCC_SAVE_HOOK
:fcc-save-hook
Definition
command.h:76
CMD_LUA_SOURCE
@ CMD_LUA_SOURCE
:lua-source
Definition
command.h:89
CMD_ICONV_HOOK
@ CMD_ICONV_HOOK
:iconv-hook
Definition
command.h:82
CMD_ALIAS
@ CMD_ALIAS
:alias
Definition
command.h:61
CMD_IFNDEF
@ CMD_IFNDEF
:ifndef
Definition
command.h:84
CMD_UNCOLOR
@ CMD_UNCOLOR
:uncolor
Definition
command.h:129
CMD_COLOR
@ CMD_COLOR
:color
Definition
command.h:71
CMD_EXEC
@ CMD_EXEC
:exec
Definition
command.h:74
CMD_INDEX_FORMAT_HOOK
@ CMD_INDEX_FORMAT_HOOK
:index-format-hook
Definition
command.h:86
CMD_UNMACRO
@ CMD_UNMACRO
:unmacro
Definition
command.h:135
CMD_UNSUBJECT_REGEX
@ CMD_UNSUBJECT_REGEX
:unsubject-regex
Definition
command.h:144
CMD_SIDEBAR_PIN
@ CMD_SIDEBAR_PIN
:sidebar-pin
Definition
command.h:111
CMD_SCORE
@ CMD_SCORE
:score
Definition
command.h:105
CMD_SHUTDOWN_HOOK
@ CMD_SHUTDOWN_HOOK
:shutdown-hook
Definition
command.h:110
CMD_SETENV
@ CMD_SETENV
:setenv
Definition
command.h:109
CMD_IFDEF
@ CMD_IFDEF
:ifdef
Definition
command.h:83
CMD_UNSUBSCRIBE_FROM
@ CMD_UNSUBSCRIBE_FROM
:unsubscribe-from
Definition
command.h:146
CMD_MACRO
@ CMD_MACRO
:macro
Definition
command.h:90
CMD_MAILTO_ALLOW
@ CMD_MAILTO_ALLOW
:mailto-allow
Definition
command.h:92
CMD_MY_HEADER
@ CMD_MY_HEADER
:my-header
Definition
command.h:97
CMD_SOURCE
@ CMD_SOURCE
:source
Definition
command.h:113
CMD_FCC_HOOK
@ CMD_FCC_HOOK
:fcc-hook
Definition
command.h:75
CMD_SIDEBAR_UNPIN
@ CMD_SIDEBAR_UNPIN
:sidebar-unpin
Definition
command.h:112
CMD_LISTS
@ CMD_LISTS
:lists
Definition
command.h:87
CMD_MESSAGE_HOOK
@ CMD_MESSAGE_HOOK
:message-hook
Definition
command.h:94
CMD_SEND2_HOOK
@ CMD_SEND2_HOOK
:send2-hook
Definition
command.h:106
CMD_ATTACHMENTS
@ CMD_ATTACHMENTS
:attachments
Definition
command.h:65
CMD_ECHO
@ CMD_ECHO
:echo
Definition
command.h:73
CMD_SUBSCRIBE_TO
@ CMD_SUBSCRIBE_TO
:subscribe-to
Definition
command.h:118
CMD_UNMIME_LOOKUP
@ CMD_UNMIME_LOOKUP
:unmime-lookup
Definition
command.h:138
CMD_PUSH
@ CMD_PUSH
:push
Definition
command.h:101
CMD_REPLY_HOOK
@ CMD_REPLY_HOOK
:reply-hook
Definition
command.h:102
CMD_VERSION
@ CMD_VERSION
:version
Definition
command.h:147
CMD_LUA
@ CMD_LUA
:lua
Definition
command.h:88
CMD_STARTUP_HOOK
@ CMD_STARTUP_HOOK
:startup-hook
Definition
command.h:115
CMD_AUTO_VIEW
@ CMD_AUTO_VIEW
:auto-view
Definition
command.h:66
CMD_UNALTERNATIVE_ORDER
@ CMD_UNALTERNATIVE_ORDER
:unalternative-order
Definition
command.h:125
CMD_UNAUTO_VIEW
@ CMD_UNAUTO_VIEW
:unauto-view
Definition
command.h:127
CMD_CHARSET_HOOK
@ CMD_CHARSET_HOOK
:charset-hook
Definition
command.h:69
CMD_UNHEADER_ORDER
@ CMD_UNHEADER_ORDER
:unheader-order
Definition
command.h:131
CMD_HOOKS
@ CMD_HOOKS
:hooks
Definition
command.h:81
CMD_NOSPAM
@ CMD_NOSPAM
:nospam
Definition
command.h:99
CMD_UNGROUP
@ CMD_UNGROUP
:ungroup
Definition
command.h:130
CMD_NONE
@ CMD_NONE
No Command.
Definition
command.h:59
CMD_TAG_FORMATS
@ CMD_TAG_FORMATS
:tag-formats
Definition
command.h:119
CMD_MAILBOXES
@ CMD_MAILBOXES
:mailboxes
Definition
command.h:91
CMD_ALTERNATES
@ CMD_ALTERNATES
:alternates
Definition
command.h:62
CMD_UNIGNORE
@ CMD_UNIGNORE
:unignore
Definition
command.h:133
CMD_UNLISTS
@ CMD_UNLISTS
:unlists
Definition
command.h:134
CMD_SAVE_HOOK
@ CMD_SAVE_HOOK
:save-hook
Definition
command.h:104
CMD_FINISH
@ CMD_FINISH
:finish
Definition
command.h:77
CMD_ALTERNATIVE_ORDER
@ CMD_ALTERNATIVE_ORDER
:alternative-order
Definition
command.h:63
CMD_TIMEOUT_HOOK
@ CMD_TIMEOUT_HOOK
:timeout-hook
Definition
command.h:121
CMD_ACCOUNT_HOOK
@ CMD_ACCOUNT_HOOK
:account-hook
Definition
command.h:60
CMD_BIND
@ CMD_BIND
:bind
Definition
command.h:67
CMD_MONO
@ CMD_MONO
:mono
Definition
command.h:96
CMD_CRYPT_HOOK
@ CMD_CRYPT_HOOK
:crypt-hook
Definition
command.h:72
CMD_UNSETENV
@ CMD_UNSETENV
:unsetenv
Definition
command.h:143
CMD_UNALTERNATES
@ CMD_UNALTERNATES
:unalternates
Definition
command.h:124
CMD_MBOX_HOOK
@ CMD_MBOX_HOOK
:mbox-hook
Definition
command.h:93
CMD_UNSCORE
@ CMD_UNSCORE
:unscore
Definition
command.h:141
CMD_UNMAILBOXES
@ CMD_UNMAILBOXES
:unmailboxes
Definition
command.h:136
CMD_UNATTACHMENTS
@ CMD_UNATTACHMENTS
:unattachments
Definition
command.h:126
CMD_FOLDER_HOOK
@ CMD_FOLDER_HOOK
:folder-hook
Definition
command.h:78
CMD_UNMONO
@ CMD_UNMONO
:unmono
Definition
command.h:139
CMD_SUBJECT_REGEX
@ CMD_SUBJECT_REGEX
:subject-regex
Definition
command.h:116
CMD_HEADER_ORDER
@ CMD_HEADER_ORDER
:header-order
Definition
command.h:80
CMD_UNHOOK
@ CMD_UNHOOK
:unhook
Definition
command.h:132
CMD_UNBIND
@ CMD_UNBIND
:unbind
Definition
command.h:128
CMD_UNMAILTO_ALLOW
@ CMD_UNMAILTO_ALLOW
:unmailto-allow
Definition
command.h:137
CMD_RESET
@ CMD_RESET
:reset
Definition
command.h:103
CMD_NAMED_MAILBOXES
@ CMD_NAMED_MAILBOXES
:named-mailboxes
Definition
command.h:98
CMD_TOGGLE
@ CMD_TOGGLE
:toggle
Definition
command.h:122
CMD_UNSET
@ CMD_UNSET
:unset
Definition
command.h:142
CMD_SET
@ CMD_SET
:set
Definition
command.h:108
CMD_OPEN_HOOK
@ CMD_OPEN_HOOK
:open-hook
Definition
command.h:100
CMD_APPEND_HOOK
@ CMD_APPEND_HOOK
:append-hook
Definition
command.h:64
CMD_UNMY_HEADER
@ CMD_UNMY_HEADER
:unmy-header
Definition
command.h:140
CommandResult
CommandResult
Error codes for command_t parse functions.
Definition
command.h:37
MUTT_CMD_SUCCESS
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition
command.h:40
MUTT_CMD_ERROR
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition
command.h:38
MUTT_CMD_WARNING
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition
command.h:39
MUTT_CMD_FINISH
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
Definition
command.h:41
CommandFlags
uint8_t CommandFlags
Special characters that end a text string.
Definition
command.h:47
lib.h
Convenience wrapper for the library headers.
Buffer
String manipulation buffer.
Definition
buffer.h:36
Command
Definition
command.h:158
Command::flags
CommandFlags flags
Command flags, e.g. CF_SYNONYM.
Definition
command.h:184
Command::proto
const char * proto
Command prototype.
Definition
command.h:181
Command::help
const char * help
One-line description of the Command.
Definition
command.h:180
Command::parse
enum CommandResult(* parse)(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Definition
command.h:178
Command::path
const char * path
Help path, relative to the NeoMutt Docs.
Definition
command.h:182
Command::name
const char * name
Name of the Command.
Definition
command.h:159
Command::id
enum CommandId id
ID of the Command.
Definition
command.h:160
ParseContext
Context for config parsing (history/backtrace)
Definition
pcontext.h:34
ParseError
Detailed error information from config parsing.
Definition
perror.h:34