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