NeoMutt  2023-05-17-56-ga67199
Teaching an old dog new tricks
DOXYGEN
commands.c File Reference

Functions to parse commands in a config file. More...

#include "config.h"
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.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 "gui/lib.h"
#include "mutt.h"
#include "commands.h"
#include "attach/lib.h"
#include "color/lib.h"
#include "imap/lib.h"
#include "menu/lib.h"
#include "pager/lib.h"
#include "parse/lib.h"
#include "store/lib.h"
#include "alternates.h"
#include "globals.h"
#include "keymap.h"
#include "muttlib.h"
#include "mx.h"
#include "score.h"
#include "version.h"
#include "monitor.h"
#include <libintl.h>
+ Include dependency graph for commands.c:

Go to the source code of this file.

Macros

#define MAX_ERRS   128
 

Enumerations

enum  GroupState { GS_NONE , GS_RX , GS_ADDR }
 Type of email address group. More...
 

Functions

static bool is_function (const char *name)
 Is the argument a neomutt function? More...
 
int parse_grouplist (struct GroupList *gl, struct Buffer *buf, struct Buffer *s, struct Buffer *err)
 Parse a group context. More...
 
enum CommandResult parse_rc_line_cwd (const char *line, char *cwd, struct Buffer *err)
 Parse and run a muttrc line in a relative directory. More...
 
char * mutt_get_sourced_cwd (void)
 Get the current file path that is being parsed. More...
 
int source_rc (const char *rcfile_path, struct Buffer *err)
 Read an initialization file. More...
 
static enum CommandResult parse_cd (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'cd' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_echo (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'echo' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_finish (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'finish' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_group (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'group' and 'ungroup' commands - Implements Command::parse() -. More...
 
static enum CommandResult parse_ifdef (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'ifdef' and 'ifndef' commands - Implements Command::parse() -. More...
 
static enum CommandResult parse_ignore (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'ignore' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_lists (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'lists' command - Implements Command::parse() -. More...
 
enum CommandResult parse_mailboxes (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'mailboxes' command - Implements Command::parse() -. More...
 
enum CommandResult parse_my_hdr (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'my_hdr' command - Implements Command::parse() -. More...
 
enum CommandResult set_dump (ConfigDumpFlags flags, struct Buffer *err)
 Dump list of config variables into a file/pager. More...
 
static int envlist_sort (const void *a, const void *b)
 Sort two environment strings. More...
 
static enum CommandResult parse_setenv (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'setenv' and 'unsetenv' commands - Implements Command::parse() -. More...
 
static enum CommandResult parse_source (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'source' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_spam_list (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'spam' and 'nospam' commands - Implements Command::parse() -. More...
 
static enum CommandResult parse_stailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse a list command - Implements Command::parse() -. More...
 
static enum CommandResult parse_subscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe' command - Implements Command::parse() -. More...
 
enum CommandResult parse_subscribe_to (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'subscribe-to' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_tag_formats (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-formats' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_tag_transforms (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'tag-transforms' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_unignore (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unignore' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_unlists (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unlists' command - Implements Command::parse() -. More...
 
static void do_unmailboxes (struct Mailbox *m)
 Remove a Mailbox from the Sidebar/notifications. More...
 
static void do_unmailboxes_star (void)
 Remove all Mailboxes from the Sidebar/notifications. More...
 
enum CommandResult parse_unmailboxes (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmailboxes' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_unmy_hdr (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unmy_hdr' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_unstailq (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse an unlist command - Implements Command::parse() -. More...
 
static enum CommandResult parse_unsubscribe (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe' command - Implements Command::parse() -. More...
 
enum CommandResult parse_unsubscribe_from (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'unsubscribe-from' command - Implements Command::parse() -. More...
 
static enum CommandResult parse_version (struct Buffer *buf, struct Buffer *s, intptr_t data, struct Buffer *err)
 Parse the 'version' command - Implements Command::parse() -. More...
 
void clear_source_stack (void)
 Free memory from the stack used for the source command. More...
 
void commands_init (void)
 Initialize commands array and register default commands. More...
 

Variables

static struct ListHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack)
 LIFO designed to contain the list of config files that have been sourced and avoid cyclic sourcing. More...
 
static const struct Command MuttCommands []
 General NeoMutt Commands. More...
 

Detailed Description

Functions to parse commands in a config file.

Authors
  • Michael R. Elkins
  • g10 Code GmbH
  • R Primus

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.

Macro Definition Documentation

◆ MAX_ERRS

#define MAX_ERRS   128

Definition at line 74 of file commands.c.

Enumeration Type Documentation

◆ GroupState

enum GroupState

Type of email address group.

Enumerator
GS_NONE 

Group is missing an argument.

GS_RX 

Entry is a regular expression.

GS_ADDR 

Entry is an address.

Definition at line 79 of file commands.c.

80{
81 GS_NONE,
82 GS_RX,
83 GS_ADDR,
84};
@ GS_RX
Entry is a regular expression.
Definition: commands.c:82
@ GS_NONE
Group is missing an argument.
Definition: commands.c:81
@ GS_ADDR
Entry is an address.
Definition: commands.c:83

Function Documentation

◆ is_function()

static bool is_function ( const char *  name)
static

Is the argument a neomutt function?

Parameters
nameCommand name to be searched for
Return values
trueFunction found
falseFunction not found

Definition at line 92 of file commands.c.

93{
94 for (size_t i = 0; MenuNames[i].name; i++)
95 {
96 const struct MenuFuncOp *fns = km_get_table(MenuNames[i].value);
97 if (!fns)
98 continue;
99
100 for (int j = 0; fns[j].name; j++)
101 if (mutt_str_equal(name, fns[j].name))
102 return true;
103 }
104 return false;
105}
const struct MenuFuncOp * km_get_table(enum MenuType mtype)
Lookup a Menu's functions.
Definition: keymap.c:1248
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:798
const char * name
String value.
Definition: mapping.h:33
Mapping between a function and an operation.
Definition: keymap.h:92
const char * name
Name of the function.
Definition: keymap.h:93
const struct Mapping MenuNames[]
Menu name lookup table.
Definition: type.c:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_grouplist()

int parse_grouplist ( struct GroupList *  gl,
struct Buffer buf,
struct Buffer s,
struct Buffer err 
)

Parse a group context.

Parameters
glGroupList to add to
bufTemporary Buffer space
sBuffer containing string to be parsed
errBuffer for error messages
Return values
0Success
-1Error

Definition at line 116 of file commands.c.

118{
119 while (mutt_istr_equal(buf->data, "-group"))
120 {
121 if (!MoreArgs(s))
122 {
123 buf_strcpy(err, _("-group: no group name"));
124 return -1;
125 }
126
128
130
131 if (!MoreArgs(s))
132 {
133 buf_strcpy(err, _("out of arguments"));
134 return -1;
135 }
136
138 }
139
140 return 0;
141}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:401
int parse_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags)
Extract one token from a string.
Definition: extract.c:47
#define MoreArgs(buf)
Definition: extract.h:30
#define TOKEN_NO_FLAGS
No flags are set.
Definition: extract.h:44
void mutt_grouplist_add(struct GroupList *gl, struct Group *group)
Add a Group to a GroupList.
Definition: group.c:182
struct Group * mutt_pattern_group(const char *pat)
Match a pattern to a Group.
Definition: group.c:117
#define _(a)
Definition: message.h:28
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:810
char * data
Pointer to data.
Definition: buffer.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_rc_line_cwd()

enum CommandResult parse_rc_line_cwd ( const char *  line,
char *  cwd,
struct Buffer err 
)

Parse and run a muttrc line in a relative directory.

Parameters
lineLine to be parsed
cwdFile relative where to run the line
errWhere to write error messages
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS

Definition at line 150 of file commands.c.

151{
153
154 enum CommandResult ret = parse_rc_line(line, err);
155
156 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
158 FREE(&np->data);
159 FREE(&np);
160
161 return ret;
162}
CommandResult
Error codes for command_t parse functions.
Definition: command.h:36
static struct ListHead MuttrcStack
LIFO designed to contain the list of config files that have been sourced and avoid cyclic sourcing.
Definition: commands.c:72
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
Definition: list.c:45
#define FREE(x)
Definition: memory.h:43
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:251
#define STAILQ_REMOVE_HEAD(head, field)
Definition: queue.h:422
#define STAILQ_FIRST(head)
Definition: queue.h:350
enum CommandResult parse_rc_line(const char *line, struct Buffer *err)
Parse a line of user config.
Definition: rc.c:108
#define NONULL(x)
Definition: string2.h:37
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_get_sourced_cwd()

char * mutt_get_sourced_cwd ( void  )

Get the current file path that is being parsed.

Return values
ptrFile path that is being parsed or cwd at runtime
Note
Caller is responsible for freeing returned string

Definition at line 170 of file commands.c.

171{
172 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
173 if (np && np->data)
174 return mutt_str_dup(np->data);
175
176 // stack is empty, return our own dummy file relative to cwd
177 struct Buffer *cwd = buf_pool_get();
178 mutt_path_getcwd(cwd);
179 buf_addstr(cwd, "/dummy.rc");
180 char *ret = buf_strdup(cwd);
181 buf_pool_release(&cwd);
182 return ret;
183}
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:238
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:536
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
Definition: path.c:563
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
String manipulation buffer.
Definition: buffer.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ source_rc()

int source_rc ( const char *  rcfile_path,
struct Buffer err 
)

Read an initialization file.

Parameters
rcfile_pathPath to initialization file
errBuffer for error messages
Return values
<0NeoMutt should pause to let the user know

Definition at line 191 of file commands.c.

192{
193 int lineno = 0, rc = 0, warnings = 0;
194 enum CommandResult line_rc;
195 struct Buffer *token = NULL, *linebuf = NULL;
196 char *line = NULL;
197 char *currentline = NULL;
198 char rcfile[PATH_MAX] = { 0 };
199 size_t linelen = 0;
200 pid_t pid;
201
202 mutt_str_copy(rcfile, rcfile_path, sizeof(rcfile));
203
204 size_t rcfilelen = mutt_str_len(rcfile);
205 if (rcfilelen == 0)
206 return -1;
207
208 bool ispipe = rcfile[rcfilelen - 1] == '|';
209
210 if (!ispipe)
211 {
212 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
213 if (!mutt_path_to_absolute(rcfile, np ? NONULL(np->data) : ""))
214 {
215 mutt_error(_("Error: Can't build path of '%s'"), rcfile_path);
216 return -1;
217 }
218
219 STAILQ_FOREACH(np, &MuttrcStack, entries)
220 {
221 if (mutt_str_equal(np->data, rcfile))
222 {
223 break;
224 }
225 }
226 if (np)
227 {
228 mutt_error(_("Error: Cyclic sourcing of configuration file '%s'"), rcfile);
229 return -1;
230 }
231
233 }
234
235 mutt_debug(LL_DEBUG2, "Reading configuration file '%s'\n", rcfile);
236
237 FILE *fp = mutt_open_read(rcfile, &pid);
238 if (!fp)
239 {
240 buf_printf(err, "%s: %s", rcfile, strerror(errno));
241 return -1;
242 }
243
244 token = buf_pool_get();
245 linebuf = buf_pool_get();
246
247 const char *const c_config_charset = cs_subset_string(NeoMutt->sub, "config_charset");
248 const char *const c_charset = cc_charset();
249 while ((line = mutt_file_read_line(line, &linelen, fp, &lineno, MUTT_RL_CONT)) != NULL)
250 {
251 const bool conv = c_config_charset && c_charset;
252 if (conv)
253 {
254 currentline = mutt_str_dup(line);
255 if (!currentline)
256 continue;
257 mutt_ch_convert_string(&currentline, c_config_charset, c_charset, MUTT_ICONV_NO_FLAGS);
258 }
259 else
260 {
261 currentline = line;
262 }
263
264 buf_strcpy(linebuf, currentline);
265
266 buf_reset(err);
267 line_rc = parse_rc_buffer(linebuf, token, err);
268 if (line_rc == MUTT_CMD_ERROR)
269 {
270 mutt_error(_("Error in %s, line %d: %s"), rcfile, lineno, err->data);
271 if (--rc < -MAX_ERRS)
272 {
273 if (conv)
274 FREE(&currentline);
275 break;
276 }
277 }
278 else if (line_rc == MUTT_CMD_WARNING)
279 {
280 /* Warning */
281 mutt_warning(_("Warning in %s, line %d: %s"), rcfile, lineno, err->data);
282 warnings++;
283 }
284 else if (line_rc == MUTT_CMD_FINISH)
285 {
286 if (conv)
287 FREE(&currentline);
288 break; /* Found "finish" command */
289 }
290 else
291 {
292 if (rc < 0)
293 rc = -1;
294 }
295 if (conv)
296 FREE(&currentline);
297 }
298
299 FREE(&line);
300 mutt_file_fclose(&fp);
301 if (pid != -1)
302 filter_wait(pid);
303
304 if (rc)
305 {
306 /* the neomuttrc source keyword */
307 buf_reset(err);
308 buf_printf(err, (rc >= -MAX_ERRS) ? _("source: errors in %s") : _("source: reading aborted due to too many errors in %s"),
309 rcfile);
310 rc = -1;
311 }
312 else
313 {
314 /* Don't alias errors with warnings */
315 if (warnings > 0)
316 {
317 buf_printf(err, ngettext("source: %d warning in %s", "source: %d warnings in %s", warnings),
318 warnings, rcfile);
319 rc = -2;
320 }
321 }
322
323 if (!ispipe && !STAILQ_EMPTY(&MuttrcStack))
324 {
325 struct ListNode *np = STAILQ_FIRST(&MuttrcStack);
327 FREE(&np->data);
328 FREE(&np);
329 }
330
331 buf_pool_release(&token);
332 buf_pool_release(&linebuf);
333 return rc;
334}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:173
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:88
const char * cc_charset(void)
Get the cached value of $charset.
Definition: cache.c:106
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition: command.h:37
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition: command.h:38
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
Definition: command.h:40
#define MAX_ERRS
Definition: commands.c:74
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition: helpers.c:317
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition: file.c:738
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:150
#define MUTT_RL_CONT
-continuation
Definition: file.h:40
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
#define mutt_warning(...)
Definition: logging2.h:88
#define mutt_error(...)
Definition: logging2.h:90
#define mutt_debug(LEVEL,...)
Definition: logging2.h:87
@ LL_DEBUG2
Log at debug level 2.
Definition: logging2.h:44
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
Definition: charset.c:822
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Definition: charset.h:71
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
Definition: path.c:397
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:568
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:653
#define PATH_MAX
Definition: mutt.h:41
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Definition: muttlib.c:1280
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define STAILQ_EMPTY(head)
Definition: queue.h:348
enum CommandResult parse_rc_buffer(struct Buffer *line, struct Buffer *token, struct Buffer *err)
Parse a line of user config.
Definition: rc.c:50
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_dump()

enum CommandResult set_dump ( ConfigDumpFlags  flags,
struct Buffer err 
)

Dump list of config variables into a file/pager.

Parameters
flagswhat configs to dump: see ConfigDumpFlags
errbuffer for error message
Returns
num See CommandResult

FIXME: Move me into parse/set.c. Note: this function currently depends on pager, which is the reason it is not included in the parse library.

Definition at line 736 of file commands.c.

737{
738 char tempfile[PATH_MAX] = { 0 };
739 mutt_mktemp(tempfile, sizeof(tempfile));
740
741 FILE *fp_out = mutt_file_fopen(tempfile, "w");
742 if (!fp_out)
743 {
744 // L10N: '%s' is the file name of the temporary file
745 buf_printf(err, _("Could not create temporary file %s"), tempfile);
746 return MUTT_CMD_ERROR;
747 }
748
749 dump_config(NeoMutt->sub->cs, flags, fp_out);
750
751 mutt_file_fclose(&fp_out);
752
753 struct PagerData pdata = { 0 };
754 struct PagerView pview = { &pdata };
755
756 pdata.fname = tempfile;
757
758 pview.banner = "set";
760 pview.mode = PAGER_MODE_OTHER;
761
762 mutt_do_pager(&pview, NULL);
763
764 return MUTT_CMD_SUCCESS;
765}
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition: command.h:39
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition: do_pager.c:123
bool dump_config(struct ConfigSet *cs, ConfigDumpFlags flags, FILE *fp)
Write all the config to a file.
Definition: dump.c:165
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:634
#define MUTT_PAGER_NO_FLAGS
No flags are set.
Definition: lib.h:59
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition: lib.h:140
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
Data to be displayed by PagerView.
Definition: lib.h:159
const char * fname
Name of the file to read.
Definition: lib.h:163
Paged view into some data.
Definition: lib.h:170
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition: lib.h:171
enum PagerMode mode
Pager mode.
Definition: lib.h:172
PagerFlags flags
Additional settings to tweak pager's function.
Definition: lib.h:173
const char * banner
Title to display in status bar.
Definition: lib.h:174
#define mutt_mktemp(buf, buflen)
Definition: tmp.h:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ envlist_sort()

static int envlist_sort ( const void *  a,
const void *  b 
)
static

Sort two environment strings.

Parameters
aFirst string
bSecond string
Return values
-1a precedes b
0a and b are identical
1b precedes a

Definition at line 775 of file commands.c.

776{
777 return strcmp(*(const char **) a, *(const char **) b);
778}
+ Here is the caller graph for this function:

◆ do_unmailboxes()

static void do_unmailboxes ( struct Mailbox m)
static

Remove a Mailbox from the Sidebar/notifications.

Parameters
mMailbox to unmailboxes

Definition at line 1265 of file commands.c.

1266{
1267#ifdef USE_INOTIFY
1269#endif
1270 m->visible = false;
1271 m->gen = -1;
1272 if (m->opened)
1273 {
1274 struct EventMailbox ev_m = { NULL };
1275 mutt_debug(LL_NOTIFY, "NT_MAILBOX_CHANGE: NULL\n");
1277 }
1278 else
1279 {
1281 mailbox_free(&m);
1282 }
1283}
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:96
@ LL_NOTIFY
Log of notifications.
Definition: logging2.h:48
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:88
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition: mailbox.h:171
int mutt_monitor_remove(struct Mailbox *m)
Remove a watch for a mailbox.
Definition: monitor.c:534
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition: notify_type.h:49
An Event that happened to a Mailbox.
Definition: mailbox.h:185
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:127
bool visible
True if a result of "mailboxes".
Definition: mailbox.h:130
int opened
Number of times mailbox is opened.
Definition: mailbox.h:128
int gen
Generation number, for sorting.
Definition: mailbox.h:145
struct Notify * notify
Notifications handler.
Definition: neomutt.h:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ do_unmailboxes_star()

static void do_unmailboxes_star ( void  )
static

Remove all Mailboxes from the Sidebar/notifications.

Definition at line 1288 of file commands.c.

1289{
1290 struct MailboxList ml = STAILQ_HEAD_INITIALIZER(ml);
1292 struct MailboxNode *np = NULL;
1293 struct MailboxNode *nptmp = NULL;
1294 STAILQ_FOREACH_SAFE(np, &ml, entries, nptmp)
1295 {
1297 }
1299}
static void do_unmailboxes(struct Mailbox *m)
Remove a Mailbox from the Sidebar/notifications.
Definition: commands.c:1265
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition: mailbox.h:42
void neomutt_mailboxlist_clear(struct MailboxList *ml)
Free a Mailbox List.
Definition: neomutt.c:141
size_t neomutt_mailboxlist_get_all(struct MailboxList *head, struct NeoMutt *n, enum MailboxType type)
Get a List of all Mailboxes.
Definition: neomutt.c:164
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition: queue.h:362
List of Mailboxes.
Definition: mailbox.h:152
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:153
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear_source_stack()

void clear_source_stack ( void  )

Free memory from the stack used for the source command.

Definition at line 1510 of file commands.c.

1511{
1513}
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commands_init()

void commands_init ( void  )

Initialize commands array and register default commands.

Definition at line 1586 of file commands.c.

1587{
1589}
static const struct Command MuttCommands[]
General NeoMutt Commands.
Definition: commands.c:1518
void commands_register(const struct Command *cmds, const size_t num_cmds)
Add commands to Commands array.
Definition: command.c:53
#define mutt_array_size(x)
Definition: memory.h:36
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ MuttrcStack

struct ListHead MuttrcStack = STAILQ_HEAD_INITIALIZER(MuttrcStack)
static

LIFO designed to contain the list of config files that have been sourced and avoid cyclic sourcing.

Definition at line 72 of file commands.c.

◆ MuttCommands

const struct Command MuttCommands[]
static

General NeoMutt Commands.

Definition at line 1518 of file commands.c.