NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
module.c File Reference

Definition of the Commands Module. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "module_data.h"
+ Include dependency graph for module.c:

Go to the source code of this file.

Functions

static bool commands_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool commands_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool commands_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 

Variables

const struct Command CommandsCommands []
 General NeoMutt Commands.
 
const struct Module ModuleCommands
 Module for the Commands library.
 

Detailed Description

Definition of the Commands Module.

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

Function Documentation

◆ commands_init()

static bool commands_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 41 of file module.c.

42{
43 struct CommandsModuleData *mod_data = MUTT_MEM_CALLOC(1, struct CommandsModuleData);
44 STAILQ_INIT(&mod_data->muttrc_stack);
46
47 mod_data->notify = notify_new();
48 notify_set_parent(mod_data->notify, n->notify);
49
50 return true;
51}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_COMMANDS
ModuleCommands, NeoMutt Commands
Definition module_api.h:54
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
#define STAILQ_INIT(head)
Definition queue.h:410
Commands private Module data.
Definition module_data.h:32
struct ListHead muttrc_stack
LIFO of sourced config files (avoid cycles)
Definition module_data.h:34
struct Notify * notify
Notifications.
Definition module_data.h:33
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:

◆ commands_commands_register()

static bool commands_commands_register ( struct NeoMutt * n,
struct CommandArray * ca )
static

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 56 of file module.c.

57{
59}
const struct Command CommandsCommands[]
General NeoMutt Commands.
Definition commands.c:43
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
+ Here is the call graph for this function:

◆ commands_cleanup()

static bool commands_cleanup ( struct NeoMutt * n,
void * data )
static

Clean up a Module - Implements Module::cleanup()

Definition at line 64 of file module.c.

65{
66 struct CommandsModuleData *mod_data = data;
67
68 notify_free(&mod_data->notify);
69
70 mutt_list_free(&mod_data->muttrc_stack);
71 FREE(&mod_data);
72 return true;
73}
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
+ Here is the call graph for this function:

Variable Documentation

◆ CommandsCommands

const struct Command CommandsCommands[]
extern

General NeoMutt Commands.

Definition at line 43 of file commands.c.

43 {
44 // clang-format off
45 { "cd", CMD_CD, parse_cd,
46 N_("Change NeoMutt's current working directory"),
47 N_("cd [ <directory> ]"),
48 "configuration.html#cd" },
49 { "echo", CMD_ECHO, parse_echo,
50 N_("Print a message to the status line"),
51 N_("echo <message>"),
52 "advancedusage.html#echo" },
53 { "finish", CMD_FINISH, parse_finish,
54 N_("Stop reading current config file"),
55 N_("finish"),
56 "optionalfeatures.html#ifdef" },
57 { "ifdef", CMD_IFDEF, parse_ifdef,
58 N_("Conditionally include config commands if symbol defined"),
59 N_("ifdef <symbol> '<config-command> [ <args> ... ]'"),
60 "optionalfeatures.html#ifdef" },
61 { "ifndef", CMD_IFNDEF, parse_ifdef,
62 N_("Conditionally include if symbol is not defined"),
63 N_("ifndef <symbol> '<config-command> [ <args> ... ]'"),
64 "optionalfeatures.html#ifdef" },
65 { "mailboxes", CMD_MAILBOXES, parse_mailboxes,
66 N_("Define a list of mailboxes to watch"),
67 N_("mailboxes [ -label <label> ] [ -notify ] [ -poll ] <mailbox> [ ... ]"),
68 "configuration.html#mailboxes" },
69 { "named-mailboxes", CMD_NAMED_MAILBOXES, parse_mailboxes,
70 N_("Define a list of labelled mailboxes to watch"),
71 N_("named-mailboxes [ -notify ] [ -poll ] <label> <mailbox> [ ... ]"),
72 "configuration.html#mailboxes" },
73 { "reset", CMD_RESET, parse_set,
74 N_("Reset a config option to its initial value"),
75 N_("reset <variable> [ <variable> ... ]"),
76 "configuration.html#set" },
77 { "set", CMD_SET, parse_set,
78 N_("Set a config variable"),
79 N_("set [ no | inv | & ] <variable> [?] | <variable> [=|+=|-=] <value> [...]"),
80 "configuration.html#set" },
81 { "setenv", CMD_SETENV, parse_setenv,
82 N_("Set an environment variable"),
83 N_("setenv { <variable>? | <variable>=<value> }"),
84 "advancedusage.html#setenv" },
85 { "source", CMD_SOURCE, parse_source,
86 N_("Read and execute commands from a config file"),
87 N_("source <filename> [ <filename> ... ]"),
88 "configuration.html#source" },
89 { "toggle", CMD_TOGGLE, parse_set,
90 N_("Toggle the value of a boolean/quad config option"),
91 N_("toggle <variable> [ ... ]"),
92 "configuration.html#set" },
93 { "unmailboxes", CMD_UNMAILBOXES, parse_unmailboxes,
94 N_("Remove mailboxes from the watch list"),
95 N_("unmailboxes { * | <mailbox> ... }"),
96 "configuration.html#mailboxes" },
97 { "unset", CMD_UNSET, parse_set,
98 N_("Reset a config option to false/empty"),
99 N_("unset <variable> [ <variable> ... ]"),
100 "configuration.html#set" },
101 { "unsetenv", CMD_UNSETENV, parse_setenv,
102 N_("Unset an environment variable"),
103 N_("unsetenv <variable>"),
104 "advancedusage.html#setenv" },
105 { "version", CMD_VERSION, parse_version,
106 N_("Show NeoMutt version and build information"),
107 N_("version"),
108 "advancedusage.html#version" },
109
110 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
111 // clang-format on
112};
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_CD
:cd
Definition command.h:71
@ CMD_IFNDEF
:ifndef
Definition command.h:87
@ CMD_SETENV
:setenv
Definition command.h:112
@ CMD_IFDEF
:ifdef
Definition command.h:86
@ CMD_SOURCE
:source
Definition command.h:116
@ CMD_ECHO
:echo
Definition command.h:76
@ CMD_VERSION
:version
Definition command.h:150
@ CMD_NONE
No Command.
Definition command.h:62
@ CMD_MAILBOXES
:mailboxes
Definition command.h:94
@ CMD_FINISH
:finish
Definition command.h:80
@ CMD_UNSETENV
:unsetenv
Definition command.h:146
@ CMD_UNMAILBOXES
:unmailboxes
Definition command.h:139
@ CMD_RESET
:reset
Definition command.h:106
@ CMD_NAMED_MAILBOXES
:named-mailboxes
Definition command.h:101
@ CMD_TOGGLE
:toggle
Definition command.h:125
@ CMD_UNSET
:unset
Definition command.h:145
@ CMD_SET
:set
Definition command.h:111
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_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_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:440
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_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:349
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:227
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:488
#define N_(a)
Definition message.h:32

◆ ModuleCommands

const struct Module ModuleCommands
Initial value:
= {
"commands",
NULL,
NULL,
NULL,
NULL,
}
static bool commands_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:64
static bool commands_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:56
static bool commands_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:41

Module for the Commands library.

Definition at line 78 of file module.c.

78 {
80 "commands",
82 NULL, // config_define_types
83 NULL, // config_define_variables
85 NULL, // gui_init
86 NULL, // gui_cleanup
88};