NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
commands.c File Reference

Setup NeoMutt Commands. More...

#include "config.h"
#include <stdio.h>
#include "mutt/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "color/lib.h"
#include "parse/lib.h"
#include "ifdef.h"
#include "mailboxes.h"
#include "parse.h"
#include "setenv.h"
#include "source.h"
+ Include dependency graph for commands.c:

Go to the source code of this file.

Functions

const struct Commandcommand_find_by_id (const struct CommandArray *ca, enum CommandId id)
 Find a NeoMutt Command by its CommandId.
 
const struct Commandcommand_find_by_name (const struct CommandArray *ca, const char *name)
 Find a NeoMutt Command by its name.
 

Variables

const struct Command CommandsCommands []
 General NeoMutt Commands.
 

Detailed Description

Setup NeoMutt Commands.

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 commands.c.

Function Documentation

◆ command_find_by_id()

const struct Command * command_find_by_id ( const struct CommandArray * ca,
enum CommandId id )

Find a NeoMutt Command by its CommandId.

Parameters
caArray of Commands
idID to find
Return values
ptrMatching Command

Definition at line 146 of file commands.c.

147{
148 if (!ca || (id == CMD_NONE))
149 return NULL;
150
151 const struct Command **cp = NULL;
152 ARRAY_FOREACH(cp, ca)
153 {
154 const struct Command *cmd = *cp;
155
156 if (cmd->id == id)
157 return cmd;
158 }
159
160 return NULL;
161}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
@ CMD_NONE
No Command.
Definition command.h:59
enum CommandId id
ID of the Command.
Definition command.h:160
+ Here is the caller graph for this function:

◆ command_find_by_name()

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

Find a NeoMutt Command by its name.

Parameters
caArray of Commands
nameName to find
Return values
ptrMatching Command
Note
If the name matches a Command Synonym, the real Command is returned.

Definition at line 171 of file commands.c.

172{
173 if (!ca || !name)
174 return NULL;
175
176 const struct Command **cp = NULL;
177 ARRAY_FOREACH(cp, ca)
178 {
179 const struct Command *cmd = *cp;
180
181 if (mutt_str_equal(cmd->name, name))
182 {
183 // If this is a synonym, look up the real Command
184 if ((cmd->flags & CF_SYNONYM) && cmd->help)
185 {
186 const char *real_name = cmd->help;
187 // Search for the real command (non-recursive, single pass)
188 const struct Command **rp = NULL;
189 ARRAY_FOREACH(rp, ca)
190 {
191 const struct Command *real_cmd = *rp;
192 if (mutt_str_equal(real_cmd->name, real_name) && !(real_cmd->flags & CF_SYNONYM))
193 return real_cmd;
194 }
195 return NULL; // Real command not found
196 }
197 return cmd;
198 }
199 }
200
201 return NULL;
202}
#define CF_SYNONYM
Command is a synonym for another command.
Definition command.h:49
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
CommandFlags flags
Command flags, e.g. CF_SYNONYM.
Definition command.h:184
const char * help
One-line description of the Command.
Definition command.h:180
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:

Variable Documentation

◆ CommandsCommands

const struct Command CommandsCommands[]

General NeoMutt Commands.

Definition at line 45 of file commands.c.

45 {
46 // clang-format off
47 { "cd", CMD_CD, parse_cd,
48 N_("Change NeoMutt's current working directory"),
49 N_("cd [ <directory> ]"),
50 "configuration.html#cd" },
51 { "color", CMD_COLOR, parse_color,
52 N_("Define colors for the user interface"),
53 N_("color <object> [ <attribute> ... ] <fg> <bg> [ <regex> [ <num> ]]"),
54 "configuration.html#color" },
55 { "echo", CMD_ECHO, parse_echo,
56 N_("Print a message to the status line"),
57 N_("echo <message>"),
58 "advancedusage.html#echo" },
59 { "finish", CMD_FINISH, parse_finish,
60 N_("Stop reading current config file"),
61 N_("finish"),
62 "optionalfeatures.html#ifdef" },
63 { "ifdef", CMD_IFDEF, parse_ifdef,
64 N_("Conditionally include config commands if symbol defined"),
65 N_("ifdef <symbol> '<config-command> [ <args> ... ]'"),
66 "optionalfeatures.html#ifdef" },
67 { "ifndef", CMD_IFNDEF, parse_ifdef,
68 N_("Conditionally include if symbol is not defined"),
69 N_("ifndef <symbol> '<config-command> [ <args> ... ]'"),
70 "optionalfeatures.html#ifdef" },
71 { "mailboxes", CMD_MAILBOXES, parse_mailboxes,
72 N_("Define a list of mailboxes to watch"),
73 N_("mailboxes [ -label <label> ] [ -notify ] [ -poll ] <mailbox> [ ... ]"),
74 "configuration.html#mailboxes" },
75 { "mono", CMD_MONO, parse_mono,
76 N_("Deprecated: Use `color` instead"),
77 N_("mono <object> <attribute> [ <pattern> | <regex> ]"),
78 "configuration.html#color-mono" },
79 { "named-mailboxes", CMD_NAMED_MAILBOXES, parse_mailboxes,
80 N_("Define a list of labelled mailboxes to watch"),
81 N_("named-mailboxes [ -notify ] [ -poll ] <label> <mailbox> [ ... ]"),
82 "configuration.html#mailboxes" },
83 { "reset", CMD_RESET, parse_set,
84 N_("Reset a config option to its initial value"),
85 N_("reset <variable> [ <variable> ... ]"),
86 "configuration.html#set" },
87 { "set", CMD_SET, parse_set,
88 N_("Set a config variable"),
89 N_("set [ no | inv | & ] <variable> [?] | <variable> [=|+=|-=] <value> [...]"),
90 "configuration.html#set" },
91 { "setenv", CMD_SETENV, parse_setenv,
92 N_("Set an environment variable"),
93 N_("setenv { <variable>? | <variable>=<value> }"),
94 "advancedusage.html#setenv" },
95 { "source", CMD_SOURCE, parse_source,
96 N_("Read and execute commands from a config file"),
97 N_("source <filename> [ <filename> ... ]"),
98 "configuration.html#source" },
99 { "subscribe", CMD_SUBSCRIBE, parse_subscribe,
100 N_("Add address to the list of subscribed mailing lists"),
101 N_("subscribe [ -group <name> ... ] <regex> [ ... ]"),
102 "configuration.html#lists" },
103 { "toggle", CMD_TOGGLE, parse_set,
104 N_("Toggle the value of a boolean/quad config option"),
105 N_("toggle <variable> [ ... ]"),
106 "configuration.html#set" },
107 { "uncolor", CMD_UNCOLOR, parse_uncolor,
108 N_("Remove a `color` definition"),
109 N_("uncolor <object> { * | <pattern> ... }"),
110 "configuration.html#color" },
111 { "unmailboxes", CMD_UNMAILBOXES, parse_unmailboxes,
112 N_("Remove mailboxes from the watch list"),
113 N_("unmailboxes { * | <mailbox> ... }"),
114 "configuration.html#mailboxes" },
115 { "unmono", CMD_UNMONO, parse_unmono,
116 N_("Deprecated: Use `uncolor` instead"),
117 N_("unmono <object> { * | <pattern> ... }"),
118 "configuration.html#color-mono" },
119 { "unset", CMD_UNSET, parse_set,
120 N_("Reset a config option to false/empty"),
121 N_("unset <variable> [ <variable> ... ]"),
122 "configuration.html#set" },
123 { "unsetenv", CMD_UNSETENV, parse_setenv,
124 N_("Unset an environment variable"),
125 N_("unsetenv <variable>"),
126 "advancedusage.html#setenv" },
127 { "unsubscribe", CMD_UNSUBSCRIBE, parse_unsubscribe,
128 N_("Remove address from the list of subscribed mailing lists"),
129 N_("unsubscribe { * | <regex> ... }"),
130 "configuration.html#lists" },
131 { "version", CMD_VERSION, parse_version,
132 N_("Show NeoMutt version and build information"),
133 N_("version"),
134 "advancedusage.html#version" },
135
136 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NO_FLAGS },
137 // clang-format on
138};
#define CF_NO_FLAGS
No flags are set.
Definition command.h:48
@ CMD_SUBSCRIBE
:subscribe
Definition command.h:117
@ CMD_UNSUBSCRIBE
:unsubscribe
Definition command.h:145
@ CMD_CD
:cd
Definition command.h:68
@ CMD_IFNDEF
:ifndef
Definition command.h:84
@ CMD_UNCOLOR
:uncolor
Definition command.h:129
@ CMD_COLOR
:color
Definition command.h:71
@ CMD_SETENV
:setenv
Definition command.h:109
@ CMD_IFDEF
:ifdef
Definition command.h:83
@ CMD_SOURCE
:source
Definition command.h:113
@ CMD_ECHO
:echo
Definition command.h:73
@ CMD_VERSION
:version
Definition command.h:147
@ CMD_MAILBOXES
:mailboxes
Definition command.h:91
@ CMD_FINISH
:finish
Definition command.h:77
@ CMD_MONO
:mono
Definition command.h:96
@ CMD_UNSETENV
:unsetenv
Definition command.h:143
@ CMD_UNMAILBOXES
:unmailboxes
Definition command.h:136
@ CMD_UNMONO
:unmono
Definition command.h:139
@ CMD_RESET
:reset
Definition command.h:103
@ CMD_NAMED_MAILBOXES
:named-mailboxes
Definition command.h:98
@ CMD_TOGGLE
:toggle
Definition command.h:122
@ CMD_UNSET
:unset
Definition command.h:142
@ CMD_SET
:set
Definition command.h:108
enum CommandResult parse_subscribe(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'subscribe' command - Implements Command::parse() -.
Definition group.c:236
enum CommandResult parse_finish(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'finish' command - Implements Command::parse() -.
Definition ifdef.c:150
enum CommandResult parse_echo(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'echo' command - Implements Command::parse() -.
Definition parse.c:96
enum CommandResult parse_cd(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'cd' command - Implements Command::parse() -.
Definition parse.c:59
enum CommandResult parse_uncolor(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'uncolor' command - Implements Command::parse() -.
Definition commands.c:445
enum CommandResult parse_unmono(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unmono' command - Implements Command::parse() -.
Definition commands.c:483
enum CommandResult parse_setenv(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse() -.
Definition setenv.c:67
enum CommandResult parse_mono(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'mono' command - Implements Command::parse() -.
Definition commands.c:538
enum CommandResult parse_version(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'version' command - Implements Command::parse() -.
Definition parse.c:125
enum CommandResult parse_unmailboxes(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unmailboxes' command - Implements Command::parse() -.
Definition mailboxes.c:437
enum CommandResult parse_ifdef(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'ifdef' and 'ifndef' commands - Implements Command::parse() -.
Definition ifdef.c:89
enum CommandResult parse_unsubscribe(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'unsubscribe' command - Implements Command::parse() -.
Definition group.c:332
enum CommandResult parse_mailboxes(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'mailboxes' command - Implements Command::parse() -.
Definition mailboxes.c:346
enum CommandResult parse_source(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'source' command - Implements Command::parse() -.
Definition source.c:229
enum CommandResult parse_set(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'set' family of commands - Implements Command::parse() -.
Definition set.c:474
enum CommandResult parse_color(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'color' command - Implements Command::parse() -.
Definition commands.c:505
#define N_(a)
Definition message.h:32