Thanks to visit codestin.com
Credit goes to code.neomutt.org

NeoMutt  2025-12-11-189-gceedb6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
command.h File Reference

NeoMutt commands API. More...

#include "config.h"
#include <stdbool.h>
#include <stdint.h>
#include "mutt/lib.h"
+ Include dependency graph for command.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Command
 

Macros

#define CF_NO_FLAGS   0
 No flags are set.
 
#define CF_SYNONYM   (1 << 0)
 Command is a synonym for another command.
 
#define CF_DEPRECATED   (1 << 1)
 Command is deprecated.
 
#define CMD_NO_DATA   0
 Convenience symbol.
 

Typedefs

typedef uint8_t CommandFlags
 Special characters that end a text string.
 

Enumerations

enum  CommandResult { MUTT_CMD_ERROR = -1 , MUTT_CMD_WARNING = -2 , MUTT_CMD_SUCCESS = 0 , MUTT_CMD_FINISH = 1 }
 Error codes for command_t parse functions. More...
 
enum  CommandId {
  CMD_NONE = 0 , CMD_ACCOUNT_HOOK , CMD_ALIAS , CMD_ALTERNATES ,
  CMD_ALTERNATIVE_ORDER , CMD_APPEND_HOOK , CMD_ATTACHMENTS , CMD_AUTO_VIEW ,
  CMD_BIND , CMD_CD , CMD_CHARSET_HOOK , CMD_CLOSE_HOOK ,
  CMD_COLOR , CMD_CRYPT_HOOK , CMD_ECHO , CMD_EXEC ,
  CMD_FCC_HOOK , CMD_FCC_SAVE_HOOK , CMD_FINISH , CMD_FOLDER_HOOK ,
  CMD_GROUP , CMD_HEADER_ORDER , CMD_HOOKS , CMD_ICONV_HOOK ,
  CMD_IFDEF , CMD_IFNDEF , CMD_IGNORE , CMD_INDEX_FORMAT_HOOK ,
  CMD_LISTS , CMD_LUA , CMD_LUA_SOURCE , CMD_MACRO ,
  CMD_MAILBOXES , CMD_MAILTO_ALLOW , CMD_MBOX_HOOK , CMD_MESSAGE_HOOK ,
  CMD_MIME_LOOKUP , CMD_MONO , CMD_MY_HEADER , CMD_NAMED_MAILBOXES ,
  CMD_NOSPAM , CMD_OPEN_HOOK , CMD_PUSH , CMD_REPLY_HOOK ,
  CMD_RESET , CMD_SAVE_HOOK , CMD_SCORE , CMD_SEND2_HOOK ,
  CMD_SEND_HOOK , CMD_SET , CMD_SETENV , CMD_SHUTDOWN_HOOK ,
  CMD_SIDEBAR_PIN , CMD_SIDEBAR_UNPIN , CMD_SOURCE , CMD_SPAM ,
  CMD_STARTUP_HOOK , CMD_SUBJECT_REGEX , CMD_SUBSCRIBE , CMD_SUBSCRIBE_TO ,
  CMD_TAG_FORMATS , CMD_TAG_TRANSFORMS , CMD_TIMEOUT_HOOK , CMD_TOGGLE ,
  CMD_UNALIAS , CMD_UNALTERNATES , CMD_UNALTERNATIVE_ORDER , CMD_UNATTACHMENTS ,
  CMD_UNAUTO_VIEW , CMD_UNBIND , CMD_UNCOLOR , CMD_UNGROUP ,
  CMD_UNHEADER_ORDER , CMD_UNHOOK , CMD_UNIGNORE , CMD_UNLISTS ,
  CMD_UNMACRO , CMD_UNMAILBOXES , CMD_UNMAILTO_ALLOW , CMD_UNMIME_LOOKUP ,
  CMD_UNMONO , CMD_UNMY_HEADER , CMD_UNSCORE , CMD_UNSET ,
  CMD_UNSETENV , CMD_UNSUBJECT_REGEX , CMD_UNSUBSCRIBE , CMD_UNSUBSCRIBE_FROM ,
  CMD_VERSION
}
 ID of Command. More...
 

Functions

 ARRAY_HEAD (CommandArray, const struct Command *)
 
const struct Commandcommands_get (struct CommandArray *ca, const char *name)
 Get a Command by its name.
 
void commands_clear (struct CommandArray *ca)
 Clear an Array of Commands.
 
bool commands_register (struct CommandArray *ca, const struct Command *cmds)
 Add commands to Commands array.
 

Detailed Description

NeoMutt commands API.

Authors
  • Richard Russon

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 command.h.

Macro Definition Documentation

◆ CF_NO_FLAGS

#define CF_NO_FLAGS   0

No flags are set.

Definition at line 46 of file command.h.

◆ CF_SYNONYM

#define CF_SYNONYM   (1 << 0)

Command is a synonym for another command.

Definition at line 47 of file command.h.

◆ CF_DEPRECATED

#define CF_DEPRECATED   (1 << 1)

Command is deprecated.

Definition at line 48 of file command.h.

◆ CMD_NO_DATA

#define CMD_NO_DATA   0

Convenience symbol.

Definition at line 148 of file command.h.

Typedef Documentation

◆ CommandFlags

typedef uint8_t CommandFlags

Special characters that end a text string.

Flags, e.g. CF_NO_FLAGS

Definition at line 45 of file command.h.

Enumeration Type Documentation

◆ CommandResult

Error codes for command_t parse functions.

Enumerator
MUTT_CMD_ERROR 

Error: Can't help the user.

MUTT_CMD_WARNING 

Warning: Help given to the user.

MUTT_CMD_SUCCESS 

Success: Command worked.

MUTT_CMD_FINISH 

Finish: Stop processing this file.

Definition at line 34 of file command.h.

35{
36 MUTT_CMD_ERROR = -1,
37 MUTT_CMD_WARNING = -2,
40};
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:38
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:36
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition command.h:37
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
Definition command.h:39

◆ CommandId

enum CommandId

ID of Command.

All the Commands in NeoMutt.

Enumerator
CMD_NONE 

No Command.

CMD_ACCOUNT_HOOK 

:account-hook

CMD_ALIAS 

:alias

See also
CMD_UNALIAS
CMD_ALTERNATES 

:alternates

See also
CMD_UNALTERNATES
CMD_ALTERNATIVE_ORDER 

:alternative-order

See also
CMD_UNALTERNATIVE_ORDER, AlternativeOrderList
CMD_APPEND_HOOK 

:append-hook

See also
CMD_CLOSE_HOOK, CMD_OPEN_HOOK
CMD_ATTACHMENTS 

:attachments

See also
CMD_UNATTACHMENTS
CMD_AUTO_VIEW 

:auto-view

See also
CMD_UNAUTO_VIEW, AutoViewList
CMD_BIND 

:bind

See also
CMD_UNBIND
CMD_CD 

:cd

CMD_CHARSET_HOOK 

:charset-hook

CMD_CLOSE_HOOK 

:close-hook

See also
CMD_APPEND_HOOK, CMD_OPEN_HOOK
CMD_COLOR 

:color

See also
CMD_UNCOLOR
CMD_CRYPT_HOOK 

:crypt-hook

CMD_ECHO 

:echo

CMD_EXEC 

:exec

CMD_FCC_HOOK 

:fcc-hook

CMD_FCC_SAVE_HOOK 

:fcc-save-hook

CMD_FINISH 

:finish

See also
CMD_IFDEF, CMD_IFNDEF
CMD_FOLDER_HOOK 

:folder-hook

CMD_GROUP 

:group

See also
CMD_UNGROUP
CMD_HEADER_ORDER 

:header-order

See also
CMD_UNHEADER_ORDER, HeaderOrderList
CMD_HOOKS 

:hooks

CMD_ICONV_HOOK 

:iconv-hook

CMD_IFDEF 

:ifdef

See also
CMD_FINISH, CMD_IFNDEF
CMD_IFNDEF 

:ifndef

See also
CMD_FINISH, CMD_IFDEF
CMD_IGNORE 

:ignore

See also
CMD_UNIGNORE
CMD_INDEX_FORMAT_HOOK 

:index-format-hook

CMD_LISTS 

:lists

See also
CMD_UNLISTS
CMD_LUA 

:lua

CMD_LUA_SOURCE 

:lua-source

CMD_MACRO 

:macro

See also
CMD_UNMACRO
CMD_MAILBOXES 

:mailboxes

See also
CMD_NAMED_MAILBOXES, CMD_UNMAILBOXES
CMD_MAILTO_ALLOW 

:mailto-allow

See also
CMD_UNMAILTO_ALLOW, MailToAllow
CMD_MBOX_HOOK 

:mbox-hook

CMD_MESSAGE_HOOK 

:message-hook

CMD_MIME_LOOKUP 

:mime-lookup

See also
CMD_UNMIME_LOOKUP, MimeLookupList
CMD_MONO 

:mono

See also
CMD_UNMONO
CMD_MY_HEADER 

:my-header

See also
CMD_UNMY_HEADER
CMD_NAMED_MAILBOXES 

:named-mailboxes

See also
CMD_MAILBOXES, CMD_UNMAILBOXES
CMD_NOSPAM 

:nospam

See also
CMD_SPAM
CMD_OPEN_HOOK 

:open-hook

See also
CMD_APPEND_HOOK, CMD_CLOSE_HOOK
CMD_PUSH 

:push

CMD_REPLY_HOOK 

:reply-hook

CMD_RESET 

:reset

See also
CMD_SET, CMD_TOGGLE, CMD_UNSET
CMD_SAVE_HOOK 

:save-hook

CMD_SCORE 

:score

See also
CMD_UNSCORE
CMD_SEND2_HOOK 

:send2-hook

CMD_SEND_HOOK 

:send-hook

CMD_SET 

:set

See also
CMD_RESET, CMD_TOGGLE, CMD_UNSET
CMD_SETENV 

:setenv

See also
CMD_UNSETENV
CMD_SHUTDOWN_HOOK 

:shutdown-hook

CMD_SIDEBAR_PIN 

:sidebar-pin

See also
CMD_SIDEBAR_UNPIN
CMD_SIDEBAR_UNPIN 

:sidebar-unpin

See also
CMD_SIDEBAR_PIN
CMD_SOURCE 

:source

CMD_SPAM 

:spam

See also
CMD_NOSPAM
CMD_STARTUP_HOOK 

:startup-hook

CMD_SUBJECT_REGEX 

:subject-regex

See also
CMD_UNSUBJECT_REGEX
CMD_SUBSCRIBE 

:subscribe

See also
CMD_UNSUBSCRIBE
CMD_SUBSCRIBE_TO 

:subscribe-to

See also
CMD_UNSUBSCRIBE_FROM
CMD_TAG_FORMATS 

:tag-formats

See also
CMD_TAG_TRANSFORMS
CMD_TAG_TRANSFORMS 

:tag-transforms

See also
CMD_TAG_FORMATS
CMD_TIMEOUT_HOOK 

:timeout-hook

CMD_TOGGLE 

:toggle

See also
CMD_RESET, CMD_SET, CMD_UNSET
CMD_UNALIAS 

:unalias

See also
CMD_ALIAS
CMD_UNALTERNATES 

:unalternates

See also
CMD_ALTERNATES
CMD_UNALTERNATIVE_ORDER 

:unalternative-order

See also
CMD_ALTERNATIVE_ORDER, AlternativeOrderList
CMD_UNATTACHMENTS 

:unattachments

See also
CMD_ATTACHMENTS
CMD_UNAUTO_VIEW 

:unauto-view

See also
CMD_AUTO_VIEW, AutoViewList
CMD_UNBIND 

:unbind

See also
CMD_BIND
CMD_UNCOLOR 

:uncolor

See also
CMD_COLOR
CMD_UNGROUP 

:ungroup

See also
CMD_GROUP
CMD_UNHEADER_ORDER 

:unheader-order

See also
CMD_HEADER_ORDER, HeaderOrderList
CMD_UNHOOK 

:unhook

CMD_UNIGNORE 

:unignore

See also
CMD_IGNORE
CMD_UNLISTS 

:unlists

See also
CMD_LISTS
CMD_UNMACRO 

:unmacro

See also
CMD_MACRO
CMD_UNMAILBOXES 

:unmailboxes

See also
CMD_MAILBOXES, CMD_NAMED_MAILBOXES
CMD_UNMAILTO_ALLOW 

:unmailto-allow

See also
CMD_MAILTO_ALLOW, MailToAllow
CMD_UNMIME_LOOKUP 

:unmime-lookup

See also
CMD_MIME_LOOKUP, MimeLookupList
CMD_UNMONO 

:unmono

See also
CMD_MONO
CMD_UNMY_HEADER 

:unmy-header

See also
CMD_MY_HEADER
CMD_UNSCORE 

:unscore

See also
CMD_SCORE
CMD_UNSET 

:unset

See also
CMD_RESET, CMD_SET, CMD_TOGGLE
CMD_UNSETENV 

:unsetenv

See also
CMD_SETENV
CMD_UNSUBJECT_REGEX 

:unsubject-regex

See also
CMD_SUBJECT_REGEX
CMD_UNSUBSCRIBE 

:unsubscribe

See also
CMD_SUBSCRIBE
CMD_UNSUBSCRIBE_FROM 

:unsubscribe-from

See also
CMD_SUBSCRIBE_TO
CMD_VERSION 

:version

Definition at line 55 of file command.h.

56{
57 CMD_NONE = 0,
59 CMD_ALIAS,
65 CMD_BIND,
66 CMD_CD,
69 CMD_COLOR,
71 CMD_ECHO,
72 CMD_EXEC,
77 CMD_GROUP,
79 CMD_HOOKS,
81 CMD_IFDEF,
85 CMD_LISTS,
86 CMD_LUA,
88 CMD_MACRO,
94 CMD_MONO,
99 CMD_PUSH,
101 CMD_RESET,
103 CMD_SCORE,
106 CMD_SET,
107 CMD_SETENV,
111 CMD_SOURCE,
112 CMD_SPAM,
120 CMD_TOGGLE,
126 CMD_UNBIND,
130 CMD_UNHOOK,
137 CMD_UNMONO,
140 CMD_UNSET,
146};
@ CMD_CLOSE_HOOK
:close-hook
Definition command.h:68
@ CMD_MIME_LOOKUP
:mime-lookup
Definition command.h:93
@ CMD_SPAM
:spam
Definition command.h:112
@ CMD_SUBSCRIBE
:subscribe
Definition command.h:115
@ CMD_UNSUBSCRIBE
:unsubscribe
Definition command.h:143
@ CMD_UNALIAS
:unalias
Definition command.h:121
@ CMD_IGNORE
:ignore
Definition command.h:83
@ CMD_GROUP
:group
Definition command.h:77
@ CMD_SEND_HOOK
:send-hook
Definition command.h:105
@ CMD_CD
:cd
Definition command.h:66
@ CMD_TAG_TRANSFORMS
:tag-transforms
Definition command.h:118
@ CMD_FCC_SAVE_HOOK
:fcc-save-hook
Definition command.h:74
@ CMD_LUA_SOURCE
:lua-source
Definition command.h:87
@ CMD_ICONV_HOOK
:iconv-hook
Definition command.h:80
@ CMD_ALIAS
:alias
Definition command.h:59
@ CMD_IFNDEF
:ifndef
Definition command.h:82
@ CMD_UNCOLOR
:uncolor
Definition command.h:127
@ CMD_COLOR
:color
Definition command.h:69
@ CMD_EXEC
:exec
Definition command.h:72
@ CMD_INDEX_FORMAT_HOOK
:index-format-hook
Definition command.h:84
@ CMD_UNMACRO
:unmacro
Definition command.h:133
@ CMD_UNSUBJECT_REGEX
:unsubject-regex
Definition command.h:142
@ CMD_SIDEBAR_PIN
:sidebar-pin
Definition command.h:109
@ CMD_SCORE
:score
Definition command.h:103
@ CMD_SHUTDOWN_HOOK
:shutdown-hook
Definition command.h:108
@ CMD_SETENV
:setenv
Definition command.h:107
@ CMD_IFDEF
:ifdef
Definition command.h:81
@ CMD_UNSUBSCRIBE_FROM
:unsubscribe-from
Definition command.h:144
@ CMD_MACRO
:macro
Definition command.h:88
@ CMD_MAILTO_ALLOW
:mailto-allow
Definition command.h:90
@ CMD_MY_HEADER
:my-header
Definition command.h:95
@ CMD_SOURCE
:source
Definition command.h:111
@ CMD_FCC_HOOK
:fcc-hook
Definition command.h:73
@ CMD_SIDEBAR_UNPIN
:sidebar-unpin
Definition command.h:110
@ CMD_LISTS
:lists
Definition command.h:85
@ CMD_MESSAGE_HOOK
:message-hook
Definition command.h:92
@ CMD_SEND2_HOOK
:send2-hook
Definition command.h:104
@ CMD_ATTACHMENTS
:attachments
Definition command.h:63
@ CMD_ECHO
:echo
Definition command.h:71
@ CMD_SUBSCRIBE_TO
:subscribe-to
Definition command.h:116
@ CMD_UNMIME_LOOKUP
:unmime-lookup
Definition command.h:136
@ CMD_PUSH
:push
Definition command.h:99
@ CMD_REPLY_HOOK
:reply-hook
Definition command.h:100
@ CMD_VERSION
:version
Definition command.h:145
@ CMD_LUA
:lua
Definition command.h:86
@ CMD_STARTUP_HOOK
:startup-hook
Definition command.h:113
@ CMD_AUTO_VIEW
:auto-view
Definition command.h:64
@ CMD_UNALTERNATIVE_ORDER
:unalternative-order
Definition command.h:123
@ CMD_UNAUTO_VIEW
:unauto-view
Definition command.h:125
@ CMD_CHARSET_HOOK
:charset-hook
Definition command.h:67
@ CMD_UNHEADER_ORDER
:unheader-order
Definition command.h:129
@ CMD_HOOKS
:hooks
Definition command.h:79
@ CMD_NOSPAM
:nospam
Definition command.h:97
@ CMD_UNGROUP
:ungroup
Definition command.h:128
@ CMD_NONE
No Command.
Definition command.h:57
@ CMD_TAG_FORMATS
:tag-formats
Definition command.h:117
@ CMD_MAILBOXES
:mailboxes
Definition command.h:89
@ CMD_ALTERNATES
:alternates
Definition command.h:60
@ CMD_UNIGNORE
:unignore
Definition command.h:131
@ CMD_UNLISTS
:unlists
Definition command.h:132
@ CMD_SAVE_HOOK
:save-hook
Definition command.h:102
@ CMD_FINISH
:finish
Definition command.h:75
@ CMD_ALTERNATIVE_ORDER
:alternative-order
Definition command.h:61
@ CMD_TIMEOUT_HOOK
:timeout-hook
Definition command.h:119
@ CMD_ACCOUNT_HOOK
:account-hook
Definition command.h:58
@ CMD_BIND
:bind
Definition command.h:65
@ CMD_MONO
:mono
Definition command.h:94
@ CMD_CRYPT_HOOK
:crypt-hook
Definition command.h:70
@ CMD_UNSETENV
:unsetenv
Definition command.h:141
@ CMD_UNALTERNATES
:unalternates
Definition command.h:122
@ CMD_MBOX_HOOK
:mbox-hook
Definition command.h:91
@ CMD_UNSCORE
:unscore
Definition command.h:139
@ CMD_UNMAILBOXES
:unmailboxes
Definition command.h:134
@ CMD_UNATTACHMENTS
:unattachments
Definition command.h:124
@ CMD_FOLDER_HOOK
:folder-hook
Definition command.h:76
@ CMD_UNMONO
:unmono
Definition command.h:137
@ CMD_SUBJECT_REGEX
:subject-regex
Definition command.h:114
@ CMD_HEADER_ORDER
:header-order
Definition command.h:78
@ CMD_UNHOOK
:unhook
Definition command.h:130
@ CMD_UNBIND
:unbind
Definition command.h:126
@ CMD_UNMAILTO_ALLOW
:unmailto-allow
Definition command.h:135
@ CMD_RESET
:reset
Definition command.h:101
@ CMD_NAMED_MAILBOXES
:named-mailboxes
Definition command.h:96
@ CMD_TOGGLE
:toggle
Definition command.h:120
@ CMD_UNSET
:unset
Definition command.h:140
@ CMD_SET
:set
Definition command.h:106
@ CMD_OPEN_HOOK
:open-hook
Definition command.h:98
@ CMD_APPEND_HOOK
:append-hook
Definition command.h:62
@ CMD_UNMY_HEADER
:unmy-header
Definition command.h:138

Function Documentation

◆ ARRAY_HEAD()

ARRAY_HEAD ( CommandArray ,
const struct Command *  )

◆ commands_get()

const struct Command * commands_get ( struct CommandArray * ca,
const char * name )

Get a Command by its name.

Parameters
caCommand Array
nameCommand name to lookup
Return values
ptrSuccess, Command
NULLError, no such command

Definition at line 82 of file command.c.

83{
84 const struct Command **cp = NULL;
85 ARRAY_FOREACH(cp, ca)
86 {
87 const struct Command *cmd = *cp;
88
89 if (mutt_str_equal(name, cmd->name))
90 return cmd;
91 }
92 return NULL;
93}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
const char * name
Name of the Command.
Definition command.h:159
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commands_clear()

void commands_clear ( struct CommandArray * ca)

Clear an Array of Commands.

Note
The Array itself is not freed

Definition at line 70 of file command.c.

71{
72 ARRAY_FREE(ca);
73}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
+ Here is the caller graph for this function:

◆ commands_register()

bool commands_register ( struct CommandArray * ca,
const struct Command * cmds )

Add commands to Commands array.

Parameters
caCommand Array
cmdsNew Commands to add
Return values
trueSuccess

Definition at line 51 of file command.c.

52{
53 if (!ca || !cmds)
54 return false;
55
56 for (int i = 0; cmds[i].name; i++)
57 {
58 ARRAY_ADD(ca, &cmds[i]);
59 }
60 ARRAY_SORT(ca, commands_sort, NULL);
61
62 return true;
63}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition array.h:373
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
static int commands_sort(const void *a, const void *b, void *sdata)
Compare two commands by name - Implements sort_t -.
Definition command.c:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function: