NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches

Function to parse a command. More...

+ Collaboration diagram for parse():

Functions

enum CommandResult parse_alternates (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'alternates' command - Implements Command::parse() -.
 
enum CommandResult parse_unalternates (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unalternates' command - Implements Command::parse() -.
 
enum CommandResult parse_alias (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'alias' command - Implements Command::parse() -.
 
enum CommandResult parse_unalias (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unalias' command - Implements Command::parse() -.
 
enum CommandResult parse_attachments (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'attachments' command - Implements Command::parse() -.
 
enum CommandResult parse_unattachments (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unattachments' command - Implements Command::parse() -.
 
enum CommandResult parse_mime_lookup (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'mime-lookup' command - Implements Command::parse() -.
 
enum CommandResult parse_unmime_lookup (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unmime-lookup' command - Implements Command::parse() -.
 
enum CommandResult parse_uncolor_command (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse an 'uncolor' command - Implements Command::parse() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
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() -.
 
enum CommandResult parse_stailq (const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
 Parse a list command - Implements Command::parse() -.
 
enum CommandResult parse_unstailq (const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
 Parse an unlist command - Implements Command::parse() -.
 
enum CommandResult parse_list (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse a list command - Implements Command::parse() -.
 
enum CommandResult parse_unlist (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse an unlist command - Implements Command::parse() -.
 
enum CommandResult parse_tag_formats (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'tag-formats' command - Implements Command::parse() -.
 
enum CommandResult parse_tag_transforms (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'tag-transforms' command - Implements Command::parse() -.
 
enum CommandResult parse_group (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'group' and 'ungroup' commands - Implements Command::parse() -.
 
enum CommandResult parse_lists (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'lists' command - Implements Command::parse() -.
 
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() -.
 
enum CommandResult parse_unlists (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unlists' command - Implements Command::parse() -.
 
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() -.
 
enum CommandResult parse_ignore (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'ignore' command - Implements Command::parse() -.
 
enum CommandResult parse_unignore (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unignore' command - Implements Command::parse() -.
 
enum CommandResult parse_score (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'score' command - Implements Command::parse() -.
 
enum CommandResult parse_unscore (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unscore' command - Implements Command::parse() -.
 
enum CommandResult parse_nospam (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'nospam' command - Implements Command::parse() -.
 
enum CommandResult parse_spam (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'spam' command - Implements Command::parse() -.
 
enum CommandResult parse_hooks (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'hooks' command - Implements Command::parse() -.
 
enum CommandResult parse_charset_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse charset Hook commands - Implements Command::parse() -.
 
enum CommandResult parse_global_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse global Hook commands - Implements Command::parse() -.
 
enum CommandResult parse_pattern_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse pattern-based Hook commands - Implements Command::parse() -.
 
enum CommandResult parse_mailbox_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse mailbox pattern hook commands - Implements Command::parse() -.
 
enum CommandResult parse_regex_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse regex-based hook command - Implements Command::parse() -.
 
enum CommandResult parse_folder_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse folder hook command - Implements Command::parse() -.
 
enum CommandResult parse_crypt_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse crypt hook commands - Implements Command::parse() -.
 
enum CommandResult parse_mbox_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse mbox hook command - Implements Command::parse() -.
 
enum CommandResult parse_compress_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse compress hook commands - Implements Command::parse() -.
 
enum CommandResult parse_index_hook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the index format hook command - Implements Command::parse() -.
 
enum CommandResult parse_unhook (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the unhook command - Implements Command::parse() -.
 
enum CommandResult parse_subscribe_to (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'subscribe-to' command - Implements Command::parse() -.
 
enum CommandResult parse_unsubscribe_from (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unsubscribe-from' command - Implements Command::parse() -.
 
enum CommandResult parse_subjectrx_list (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'subject-regex' command - Implements Command::parse() -.
 
enum CommandResult parse_unsubjectrx_list (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unsubject-regex' command - Implements Command::parse() -.
 
enum CommandResult parse_dump (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse 'bind' and 'macro' commands - Implements Command::parse() -.
 
enum CommandResult parse_push (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'push' command - Implements Command::parse() -.
 
enum CommandResult parse_bind (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'bind' command - Implements Command::parse() -.
 
enum CommandResult parse_unbind (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unbind' and 'unmacro' commands - Implements Command::parse() -.
 
enum CommandResult parse_macro (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'macro' command - Implements Command::parse() -.
 
enum CommandResult parse_exec (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'exec' command - Implements Command::parse() -.
 
enum CommandResult parse_lua (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'lua' command - Implements Command::parse() -.
 
enum CommandResult parse_lua_source (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'lua-source' command - Implements Command::parse() -.
 
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() -.
 
enum CommandResult parse_my_header (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'my-header' command - Implements Command::parse() -.
 
enum CommandResult parse_unmy_header (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'unmy-header' command - Implements Command::parse() -.
 
enum CommandResult parse_sidebar_pin (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'sidebar-pin' command - Implements Command::parse() -.
 
enum CommandResult parse_sidebar_unpin (const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
 Parse the 'sidebar-unpin' command - Implements Command::parse() -.
 

Detailed Description

Function to parse a command.

Parameters
cmdCommand being parsed
lineBuffer containing string to be parsed
pcParse Context
peParse Errors
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS
Precondition
cmd is not NULL
line is not NULL
pc is not NULL
pe is not NULL

Function Documentation

◆ parse_alternates()

enum CommandResult parse_alternates ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'alternates' command - Implements Command::parse() -.

Parse:

  • alternates [ -group <name> ... ] <regex> [ <regex> ... ]

Definition at line 67 of file alternates.c.

69{
70 struct Buffer *err = pe->message;
71
72 if (!MoreArgs(line))
73 {
74 buf_printf(err, _("%s: too few arguments"), cmd->name);
75 return MUTT_CMD_WARNING;
76 }
77
78 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
79 struct Buffer *token = buf_pool_get();
81
83 ASSERT(md);
84
85 do
86 {
88
89 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
90 goto done;
91
93
94 if (mutt_regexlist_add(&md->alternates, buf_string(token), REG_ICASE, err) != 0)
95 goto done;
96
97 if (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0)
98 goto done;
99 } while (MoreArgs(line));
100
101 mutt_debug(LL_NOTIFY, "NT_ALTERN_ADD: %s\n", buf_string(token));
103
104 rc = MUTT_CMD_SUCCESS;
105
106done:
107 buf_pool_release(&token);
109 return rc;
110}
int grouplist_add_regex(struct GroupList *gl, const char *str, uint16_t flags, struct Buffer *err)
Add matching Addresses to a GroupList.
Definition group.c:245
void grouplist_destroy(struct GroupList *gl)
Free a GroupList.
Definition group.c:203
@ NT_ALTERN_ADD
Alternate address has been added.
Definition alternates.h:43
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
CommandResult
Error codes for command_t parse functions.
Definition command.h:37
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:40
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:38
@ MUTT_CMD_WARNING
Warning: Help given to the user.
Definition command.h:39
int parse_grouplist(struct GroupList *gl, struct Buffer *token, struct Buffer *line, struct Buffer *err, struct HashTable *groups)
Parse a group context.
Definition group.c:56
int parse_extract_token(struct Buffer *dest, struct Buffer *line, TokenFlags flags)
Extract one token from a string.
Definition extract.c:49
#define MoreArgs(buf)
Definition extract.h:31
#define TOKEN_NO_FLAGS
No flags are set.
Definition extract.h:45
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:50
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
#define _(a)
Definition message.h:28
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
int mutt_regexlist_add(struct RegexList *rl, const char *str, uint16_t flags, struct Buffer *err)
Compile a regex string and add it to a list.
Definition regex.c:140
int mutt_regexlist_remove(struct RegexList *rl, const char *str)
Remove a Regex from a list.
Definition regex.c:235
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
@ NT_ALTERN
Alternates command changed, NotifyAlternates.
Definition notify_type.h:38
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
#define STAILQ_HEAD_INITIALIZER(head)
Definition queue.h:324
#define ASSERT(COND)
Definition signal2.h:59
Alias private Module data.
Definition module_data.h:33
struct RegexList unalternates
Regexes to exclude false matches in alternates.
Definition module_data.h:38
struct Notify * alternates_notify
Notifications: NotifyAlternates.
Definition module_data.h:39
struct RegexList alternates
Regexes to match the user's alternate email addresses.
Definition module_data.h:37
String manipulation buffer.
Definition buffer.h:36
const char * name
Name of the Command.
Definition command.h:159
Container for Accounts, Notifications.
Definition neomutt.h:41
struct HashTable * groups
Hash Table: "group-name" -> Group.
Definition neomutt.h:54
struct Buffer * message
Error message.
Definition perror.h:35
+ Here is the call graph for this function:

◆ parse_unalternates()

enum CommandResult parse_unalternates ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unalternates' command - Implements Command::parse() -.

Parse:

  • unalternates { * | <regex> ... }

Definition at line 118 of file alternates.c.

120{
121 struct Buffer *err = pe->message;
122
123 if (!MoreArgs(line))
124 {
125 buf_printf(err, _("%s: too few arguments"), cmd->name);
126 return MUTT_CMD_WARNING;
127 }
128
129 struct Buffer *token = buf_pool_get();
131
133 ASSERT(md);
134
135 do
136 {
139
140 if (!mutt_str_equal(buf_string(token), "*") &&
141 (mutt_regexlist_add(&md->unalternates, buf_string(token), REG_ICASE, err) != 0))
142 {
143 goto done;
144 }
145
146 } while (MoreArgs(line));
147
148 mutt_debug(LL_NOTIFY, "NT_ALTERN_DELETE: %s\n", buf_string(token));
150
151 rc = MUTT_CMD_SUCCESS;
152
153done:
154 buf_pool_release(&token);
155 return rc;
156}
@ NT_ALTERN_DELETE
Alternate address has been deleted.
Definition alternates.h:44
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:665
+ Here is the call graph for this function:

◆ parse_alias()

enum CommandResult parse_alias ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'alias' command - Implements Command::parse() -.

e.g. "alias jim James Smith <js@example.com> # Pointy-haired boss"

Parse:

  • alias [ -group <name> ... ] <key> <address> [, <address> ...] [ # [ <comments> ] [ tags:... ]]

Definition at line 138 of file commands.c.

140{
141 struct Buffer *err = pe->message;
142
143 if (!MoreArgs(line))
144 {
145 buf_printf(err, _("%s: too few arguments"), cmd->name);
146 return MUTT_CMD_WARNING;
147 }
148
149 struct Alias *a = NULL;
150 enum NotifyAlias event;
151 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
152 struct Buffer *token = buf_pool_get();
154
155 /* name */
157 mutt_debug(LL_DEBUG5, "First token is '%s'\n", buf_string(token));
158 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
159 goto done;
160
161 char *name = mutt_str_dup(buf_string(token));
162
163 /* address list */
165 mutt_debug(LL_DEBUG5, "Second token is '%s'\n", buf_string(token));
166 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
167 int parsed = mutt_addrlist_parse2(&al, buf_string(token));
168 if (parsed == 0)
169 {
170 buf_printf(err, _("Warning: Bad address '%s' in alias '%s'"), buf_string(token), name);
171 FREE(&name);
172 goto done;
173 }
174
175 /* IDN */
176 char *estr = NULL;
177 if (mutt_addrlist_to_intl(&al, &estr))
178 {
179 buf_printf(err, _("Warning: Bad IDN '%s' in alias '%s'"), estr, name);
180 FREE(&name);
181 FREE(&estr);
182 goto done;
183 }
184
186 ASSERT(md);
187
188 /* check to see if an alias with this name already exists */
189 struct Alias **ap = NULL;
190 ARRAY_FOREACH(ap, &md->aliases)
191 {
192 if (mutt_istr_equal((*ap)->name, name))
193 {
194 a = *ap;
195 break;
196 }
197 }
198
199 if (a)
200 {
201 FREE(&name);
203 /* override the previous value */
205 FREE(&a->comment);
206 event = NT_ALIAS_CHANGE;
207 }
208 else
209 {
210 /* create a new alias */
211 a = alias_new();
212 a->name = name;
213 ARRAY_ADD(&md->aliases, a);
214 event = NT_ALIAS_ADD;
215 }
216 a->addr = al;
217
219
220 const short c_debug_level = cs_subset_number(NeoMutt->sub, "debug_level");
221 if (c_debug_level > LL_DEBUG4)
222 {
223 /* A group is terminated with an empty address, so check addr->mailbox */
224 struct Address *addr = NULL;
225 TAILQ_FOREACH(addr, &a->addr, entries)
226 {
227 if (!addr->mailbox)
228 break;
229
230 if (addr->group)
231 mutt_debug(LL_DEBUG5, " Group %s\n", buf_string(addr->mailbox));
232 else
233 mutt_debug(LL_DEBUG5, " %s\n", buf_string(addr->mailbox));
234 }
235 }
236
237 if (!MoreArgs(line) && (line->dptr[0] == '#'))
238 {
239 line->dptr++; // skip over the "# "
240 if (*line->dptr == ' ')
241 line->dptr++;
242
243 parse_alias_comments(a, line->dptr);
244 *line->dptr = '\0'; // We're done parsing
245 }
246
248
249 mutt_debug(LL_NOTIFY, "%s: %s\n",
250 (event == NT_ALIAS_ADD) ? "NT_ALIAS_ADD" : "NT_ALIAS_CHANGE", a->name);
251 struct EventAlias ev_a = { a };
252 notify_send(NeoMutt->notify, NT_ALIAS, event, &ev_a);
253
254 rc = MUTT_CMD_SUCCESS;
255
256done:
257 buf_pool_release(&token);
259 return rc;
260}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition address.c:1469
int mutt_addrlist_parse2(struct AddressList *al, const char *s)
Parse a list of email addresses.
Definition address.c:649
int mutt_addrlist_to_intl(struct AddressList *al, char **err)
Convert an Address list to Punycode.
Definition address.c:1302
void grouplist_add_addrlist(struct GroupList *gl, struct AddressList *al)
Add Address list to a GroupList.
Definition group.c:224
void parse_alias_comments(struct Alias *alias, const char *com)
Parse the alias/query comment field.
Definition commands.c:95
struct Alias * alias_new(void)
Create a new Alias.
Definition alias.c:661
NotifyAlias
Alias notification types.
Definition alias.h:54
@ NT_ALIAS_ADD
Alias has been added.
Definition alias.h:55
@ NT_ALIAS_CHANGE
Alias has been changed.
Definition alias.h:58
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
#define TOKEN_SPACE
Don't treat whitespace as a term.
Definition extract.h:48
#define TOKEN_QUOTE
Don't interpret quotes.
Definition extract.h:49
#define TOKEN_SEMICOLON
Don't treat ; as special.
Definition extract.h:52
@ LL_DEBUG4
Log at debug level 4.
Definition logging2.h:48
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:677
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
@ NT_ALIAS
Alias has changed, NotifyAlias, EventAlias.
Definition notify_type.h:37
#define TAILQ_FOREACH(var, head, field)
Definition queue.h:782
#define TAILQ_HEAD_INITIALIZER(head)
Definition queue.h:694
void alias_reverse_add(struct Alias *alias)
Add an email address lookup for an Alias.
Definition reverse.c:62
void alias_reverse_delete(struct Alias *alias)
Remove an email address lookup for an Alias.
Definition reverse.c:87
An email address.
Definition address.h:35
bool group
Group mailbox?
Definition address.h:38
struct Buffer * mailbox
Mailbox and host address.
Definition address.h:37
struct AliasArray aliases
User's email aliases.
Definition module_data.h:34
A shortcut for an email address or addresses.
Definition alias.h:35
char * comment
Free-form comment string.
Definition alias.h:38
char * name
Short name.
Definition alias.h:36
struct AddressList addr
List of Addresses the Alias expands to.
Definition alias.h:37
char * dptr
Current read/write position.
Definition buffer.h:38
An alias-change event.
Definition alias.h:65
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:

◆ parse_unalias()

enum CommandResult parse_unalias ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unalias' command - Implements Command::parse() -.

Parse:

  • unalias { * | <key> ... }

Definition at line 268 of file commands.c.

270{
271 struct Buffer *err = pe->message;
272
273 if (!MoreArgs(line))
274 {
275 buf_printf(err, _("%s: too few arguments"), cmd->name);
276 return MUTT_CMD_WARNING;
277 }
278
279 struct Buffer *token = buf_pool_get();
280
282 ASSERT(md);
283
284 do
285 {
287
288 struct Alias **ap = NULL;
289 if (mutt_str_equal("*", buf_string(token)))
290 {
291 ARRAY_FOREACH(ap, &md->aliases)
292 {
294 }
295
297 goto done;
298 }
299
300 ARRAY_FOREACH(ap, &md->aliases)
301 {
302 if (!mutt_istr_equal(buf_string(token), (*ap)->name))
303 continue;
304
305 struct Alias *a = *ap;
306 ARRAY_REMOVE(&md->aliases, ap);
308 alias_free(&a);
309 break;
310 }
311 } while (MoreArgs(line));
312
313done:
314 buf_pool_release(&token);
315 return MUTT_CMD_SUCCESS;
316}
void alias_free(struct Alias **ptr)
Free an Alias.
Definition alias.c:673
void aliaslist_clear(struct AliasArray *aa)
Empty a List of Aliases.
Definition alias.c:698
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
+ Here is the call graph for this function:

◆ parse_attachments()

enum CommandResult parse_attachments ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'attachments' command - Implements Command::parse() -.

Parse:

  • attachments { + | - }<disposition> <mime-type> [ <mime-type> ...]
  • attachments ?

Definition at line 472 of file commands.c.

474{
476 ASSERT(md);
477
478 struct Buffer *err = pe->message;
479
480 if (!MoreArgs(line))
481 {
482 buf_printf(err, _("%s: too few arguments"), cmd->name);
483 return MUTT_CMD_WARNING;
484 }
485
486 struct Buffer *token = buf_pool_get();
488
490
491 char *category = token->data;
492 char op = *category++;
493
494 if (op == '?')
495 {
496 mutt_endwin();
497 fflush(stdout);
498 printf("\n%s\n\n", _("Current attachments settings:"));
499 print_attach_list(&md->attach_allow, '+', "A");
500 print_attach_list(&md->attach_exclude, '-', "A");
501 print_attach_list(&md->inline_allow, '+', "I");
502 print_attach_list(&md->inline_exclude, '-', "I");
504
505 rc = MUTT_CMD_SUCCESS;
506 goto done;
507 }
508
509 if ((op != '+') && (op != '-'))
510 {
511 op = '+';
512 category--;
513 }
514
515 struct ListHead *head = NULL;
516 if (mutt_istr_startswith("attachment", category))
517 {
518 if (op == '+')
519 head = &md->attach_allow;
520 else
521 head = &md->attach_exclude;
522 }
523 else if (mutt_istr_startswith("inline", category))
524 {
525 if (op == '+')
526 head = &md->inline_allow;
527 else
528 head = &md->inline_exclude;
529 }
530 else
531 {
532 buf_strcpy(err, _("attachments: invalid disposition"));
533 goto done;
534 }
535
536 rc = parse_attach_list(cmd, line, head, err);
537
538done:
539 buf_pool_release(&token);
540 return rc;
541}
static int print_attach_list(struct ListHead *h, const char op, const char *name)
Print a list of attachments.
Definition commands.c:452
static enum CommandResult parse_attach_list(const struct Command *cmd, struct Buffer *line, struct ListHead *head, struct Buffer *err)
Parse the "attachments" command.
Definition commands.c:291
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition curs_lib.c:173
void mutt_endwin(void)
Shutdown curses.
Definition curs_lib.c:151
@ MODULE_ID_ATTACH
ModuleAttach, Attachments
Definition module_api.h:49
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Definition string.c:246
Attach private Module data.
Definition module_data.h:32
struct ListHead attach_allow
List of attachment types to be counted.
Definition module_data.h:33
struct ListHead attach_exclude
List of attachment types to be ignored.
Definition module_data.h:34
struct ListHead inline_allow
List of inline types to counted.
Definition module_data.h:35
struct ListHead inline_exclude
List of inline types to ignore.
Definition module_data.h:36
char * data
Pointer to data.
Definition buffer.h:37
+ Here is the call graph for this function:

◆ parse_unattachments()

enum CommandResult parse_unattachments ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unattachments' command - Implements Command::parse() -.

Parse:

  • unattachments { + | - } disposition mime-type [ mime-type ...]
  • unattachments *

Definition at line 550 of file commands.c.

552{
553 struct Buffer *err = pe->message;
554
555 if (!MoreArgs(line))
556 {
557 buf_printf(err, _("%s: too few arguments"), cmd->name);
558 return MUTT_CMD_WARNING;
559 }
560
562 ASSERT(md);
563
564 struct Buffer *token = buf_pool_get();
566
567 char op;
568 const char *p = NULL;
569 struct ListHead *head = NULL;
570
572
573 p = buf_string(token);
574 op = *p++;
575
576 if (op == '*')
577 {
582
583 mutt_debug(LL_NOTIFY, "NT_ATTACH_DELETE_ALL\n");
585
586 rc = MUTT_CMD_SUCCESS;
587 goto done;
588 }
589
590 if ((op != '+') && (op != '-'))
591 {
592 op = '+';
593 p--;
594 }
595 if (mutt_istr_startswith("attachment", p))
596 {
597 if (op == '+')
598 head = &md->attach_allow;
599 else
600 head = &md->attach_exclude;
601 }
602 else if (mutt_istr_startswith("inline", p))
603 {
604 if (op == '+')
605 head = &md->inline_allow;
606 else
607 head = &md->inline_exclude;
608 }
609 else
610 {
611 buf_strcpy(err, _("unattachments: invalid disposition"));
612 goto done;
613 }
614
615 rc = parse_unattach_list(cmd, line, head, err);
616
617done:
618 buf_pool_release(&token);
619 return rc;
620}
static enum CommandResult parse_unattach_list(const struct Command *cmd, struct Buffer *line, struct ListHead *head, struct Buffer *err)
Parse the "unattachments" command.
Definition commands.c:380
@ NT_ATTACH_DELETE_ALL
All Attachment regexes have been deleted.
Definition commands.h:46
void attachmatch_free(struct AttachMatch **ptr)
Free an AttachMatch - Implements list_free_t -.
Definition commands.c:63
void mutt_list_free_type(struct ListHead *h, list_free_t fn)
Free a List of type.
Definition list.c:144
void(* list_free_t)(void **ptr)
Definition list.h:50
@ NT_ATTACH
Attachment command changed, NotifyAttach.
Definition notify_type.h:39
struct Notify * attachments_notify
Notifications: NotifyAttach.
Definition module_data.h:37
+ Here is the call graph for this function:

◆ parse_mime_lookup()

enum CommandResult parse_mime_lookup ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'mime-lookup' command - Implements Command::parse() -.

Parse:

  • mime-lookup { + | - }<disposition> <mime-type> [ <mime-type> ...]
  • mime-lookup ?

Definition at line 652 of file commands.c.

654{
656 ASSERT(md);
657
658 return parse_stailq(cmd, line, &md->mime_lookup, pc, pe);
659}
enum CommandResult parse_stailq(const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
Parse a list command - Implements Command::parse() -.
Definition stailq.c:52
struct ListHead mime_lookup
List of mime types that that shouldn't use the mailcap entry.
Definition module_data.h:39
+ Here is the call graph for this function:

◆ parse_unmime_lookup()

enum CommandResult parse_unmime_lookup ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unmime-lookup' command - Implements Command::parse() -.

Parse:

  • unmime-lookup { + | - } disposition mime-type [ mime-type ...]
  • unmime-lookup *

Definition at line 668 of file commands.c.

670{
672 ASSERT(md);
673
674 return parse_unstailq(cmd, line, &md->mime_lookup, pc, pe);
675}
enum CommandResult parse_unstailq(const struct Command *cmd, struct Buffer *line, struct ListHead *list, const struct ParseContext *pc, struct ParseError *pe)
Parse an unlist command - Implements Command::parse() -.
Definition stailq.c:85
+ Here is the call graph for this function:

◆ parse_uncolor_command()

enum CommandResult parse_uncolor_command ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse an 'uncolor' command - Implements Command::parse() -.

Usage:

  • uncolor OBJECT [ PATTERN | REGEX | * ]

Definition at line 199 of file commands.c.

202{
203 struct Buffer *err = pe->message;
204
205 if (!MoreArgs(line))
206 {
207 buf_printf(err, _("%s: too few arguments"), cmd->name);
208 return MUTT_CMD_WARNING;
209 }
210
211 struct Buffer *token = buf_pool_get();
213
214 // Peek at the next token ('*' won't match a colour name)
215 if (line->dptr[0] == '*')
216 {
218 if (mutt_str_equal(buf_string(token), "*"))
219 {
220 colors_reset();
221 rc = MUTT_CMD_SUCCESS;
222 goto done;
223 }
224 }
225
226 enum ColorId cid = MT_COLOR_NONE;
227 color_debug(LL_DEBUG5, "uncolor: %s\n", buf_string(token));
228 rc = parse_object(cmd, line, &cid, err);
229 if (rc != MUTT_CMD_SUCCESS)
230 goto done;
231
232 if ((cid == MT_COLOR_STATUS) && !MoreArgs(line))
233 {
234 color_debug(LL_DEBUG5, "simple\n");
235 simple_color_reset(cid); // default colour for the status bar
236 goto done;
237 }
238
239 if (!mutt_color_has_pattern(cid))
240 {
241 color_debug(LL_DEBUG5, "simple\n");
243 goto done;
244 }
245
246 if (!MoreArgs(line))
247 {
248 if (regex_colors_parse_uncolor(cid, NULL))
249 rc = MUTT_CMD_SUCCESS;
250 else
251 rc = MUTT_CMD_ERROR;
252 goto done;
253 }
254
255 do
256 {
258 if (mutt_str_equal("*", buf_string(token)))
259 {
260 if (regex_colors_parse_uncolor(cid, NULL))
261 rc = MUTT_CMD_SUCCESS;
262 else
263 rc = MUTT_CMD_ERROR;
264 goto done;
265 }
266
268
269 } while (MoreArgs(line));
270
271 rc = MUTT_CMD_SUCCESS;
272
273done:
274 buf_pool_release(&token);
275 return rc;
276}
static enum CommandResult parse_object(const struct Command *cmd, struct Buffer *line, enum ColorId *cid, struct Buffer *err)
Identify a colour object.
Definition commands.c:146
bool regex_colors_parse_uncolor(enum ColorId cid, const char *pat)
Parse a Regex 'uncolor' command.
Definition regex.c:425
void simple_color_reset(enum ColorId cid)
Clear the colour of a simple object.
Definition simple.c:150
bool mutt_color_has_pattern(enum ColorId cid)
Check if a color object supports a regex pattern.
Definition color.c:98
void colors_reset(void)
Reset all the simple, quoted and regex colours.
Definition color.c:68
ColorId
List of all coloured objects.
Definition color.h:35
@ MT_COLOR_STATUS
Status bar (takes a pattern)
Definition color.h:78
@ MT_COLOR_NONE
No colour.
Definition color.h:36
static int color_debug(enum LogLevel level, const char *format,...)
Definition debug.h:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_uncolor()

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() -.

Parse:

  • uncolor <object> { * | <pattern> ... }

Definition at line 445 of file commands.c.

447{
448 struct Buffer *err = pe->message;
449
450 if (!MoreArgs(line))
451 {
452 buf_printf(err, _("%s: too few arguments"), cmd->name);
453 return MUTT_CMD_WARNING;
454 }
455
456 struct Buffer *token = buf_pool_get();
458
459 if (!OptGui) // No GUI, so quietly discard the command
460 {
461 while (MoreArgs(line))
462 {
464 }
465 goto done;
466 }
467
468 color_debug(LL_DEBUG5, "parse: %s\n", buf_string(token));
469 rc = parse_uncolor_command(cmd, line, pc, pe);
470 curses_colors_dump(token);
471
472done:
473 buf_pool_release(&token);
474 return rc;
475}
void curses_colors_dump(struct Buffer *buf)
Dump all the Curses colours.
Definition debug.c:143
bool OptGui
(pseudo) when the gui (and curses) are started
Definition globals.c:48
enum CommandResult parse_uncolor_command(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse an 'uncolor' command - Implements Command::parse() -.
Definition commands.c:199
+ Here is the call graph for this function:

◆ parse_unmono()

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() -.

Parse:

  • unmono <object> { * | <pattern> ... }

Definition at line 483 of file commands.c.

485{
486 // Quietly discard the command
487 struct Buffer *token = buf_pool_get();
488 while (MoreArgs(line))
489 {
491 }
492 buf_pool_release(&token);
493
494 return MUTT_CMD_SUCCESS;
495}
+ Here is the call graph for this function:

◆ parse_color()

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() -.

Parse:

  • color object [ attribute ...] foreground background
  • color index [ attribute ...] foreground background [ pattern ]
  • color { header | body } [ attribute ...] foreground background regex

Definition at line 505 of file commands.c.

507{
508 struct Buffer *err = pe->message;
509
510 struct Buffer *token = buf_pool_get();
512
513 // No GUI, or no colours, so quietly discard the command
514 if (!OptGui || (COLORS == 0))
515 {
516 while (MoreArgs(line))
517 {
519 }
520 goto done;
521 }
522
523 color_debug(LL_DEBUG5, "parse: color\n");
524 rc = parse_color_command(cmd, line, err, parse_color_pair);
525 curses_colors_dump(token);
526
527done:
528 buf_pool_release(&token);
529 return rc;
530}
static enum CommandResult parse_color_command(const struct Command *cmd, struct Buffer *line, struct Buffer *err, parser_callback_t callback)
Parse a 'color' command.
Definition commands.c:290
enum CommandResult parse_color_pair(const struct Command *cmd, struct Buffer *line, struct AttrColor *ac, struct Buffer *err)
Parse a pair of colours - Implements parser_callback_t -.
+ Here is the call graph for this function:

◆ parse_mono()

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() -.

Parse:

  • mono <object> <attribute> [ <pattern> | <regex> ]

Definition at line 538 of file commands.c.

540{
541 struct Buffer *err = pe->message;
542
543 struct Buffer *token = buf_pool_get();
545
546 // No GUI, or colours available, so quietly discard the command
547 if (!OptGui || (COLORS != 0))
548 {
549 while (MoreArgs(line))
550 {
552 }
553 goto done;
554 }
555
556 color_debug(LL_DEBUG5, "parse: %s\n", buf_string(token));
557 rc = parse_color_command(cmd, line, err, parse_attr_spec);
558 curses_colors_dump(token);
559
560done:
561 buf_pool_release(&token);
562 return rc;
563}
enum CommandResult parse_attr_spec(const struct Command *cmd, struct Buffer *line, struct AttrColor *ac, struct Buffer *err)
Parse an attribute description - Implements parser_callback_t -.
+ Here is the call graph for this function:

◆ parse_ifdef()

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() -.

The 'ifdef' command allows conditional elements in the config file. If a given variable, function, command or compile-time symbol exists, then read the rest of the line of config commands. e.g. ifdef sidebar source ~/.neomutt/sidebar.rc

Parse:

  • ‘ifdef <symbol> ’<config-command> [ <args> ... ]' -ifndef <symbol> '<config-command> [ <args> ... ]'`

Definition at line 89 of file ifdef.c.

91{
92 struct Buffer *err = pe->message;
93
94 if (!MoreArgs(line))
95 {
96 buf_printf(err, _("%s: too few arguments"), cmd->name);
97 return MUTT_CMD_WARNING;
98 }
99
100 struct Buffer *token = buf_pool_get();
102
104
105 // is the item defined as:
106 bool res = cs_subset_lookup(NeoMutt->sub, buf_string(token)) // a variable?
107 || feature_enabled(buf_string(token)) // a compiled-in feature?
108 || is_function(buf_string(token)) // a function?
109 || commands_get(&NeoMutt->commands, buf_string(token)) // a command?
110 || is_color_object(buf_string(token)) // a color?
111#ifdef USE_HCACHE
112 || store_is_valid_backend(buf_string(token)) // a store? (database)
113#endif
114 || mutt_str_getenv(buf_string(token)); // an environment variable?
115
116 if (!MoreArgs(line))
117 {
118 buf_printf(err, _("%s: too few arguments"), cmd->name);
119 rc = MUTT_CMD_WARNING;
120 goto done;
121 }
122 parse_extract_token(token, line, TOKEN_SPACE);
123
124 /* ifdef KNOWN_SYMBOL or ifndef UNKNOWN_SYMBOL */
125 if ((res && (cmd->id == CMD_IFDEF)) || (!res && (cmd->id == CMD_IFNDEF)))
126 {
127 // Cheat: Remove the `const` so we can recurse
128 rc = parse_rc_line(token, (struct ParseContext *) pc, pe);
129 if (rc == MUTT_CMD_ERROR)
130 mutt_error(_("Error: %s"), buf_string(err));
131
132 goto done;
133 }
134
135done:
136 buf_pool_release(&token);
137 return rc;
138}
@ CMD_IFNDEF
:ifndef
Definition command.h:84
@ CMD_IFDEF
:ifdef
Definition command.h:83
const struct Command * commands_get(struct CommandArray *ca, const char *name)
Get a Command by its name.
Definition command.c:82
#define mutt_error(...)
Definition logging2.h:94
static bool is_color_object(const char *name)
Is the argument a neomutt colour?
Definition ifdef.c:69
static bool is_function(const char *name)
Is the argument a neomutt function?
Definition ifdef.c:56
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:731
enum CommandResult parse_rc_line(struct Buffer *line, struct ParseContext *pc, struct ParseError *pe)
Parse a line of user config.
Definition rc.c:45
bool store_is_valid_backend(const char *str)
Is the string a valid Store backend.
Definition store.c:110
enum CommandId id
ID of the Command.
Definition command.h:160
struct CommandArray commands
NeoMutt commands.
Definition neomutt.h:53
Context for config parsing (history/backtrace)
Definition pcontext.h:34
struct HashElem * cs_subset_lookup(const struct ConfigSubset *sub, const char *name)
Find an inherited config item.
Definition subset.c:193
bool feature_enabled(const char *name)
Test if a compile-time feature is enabled.
Definition version.c:728
+ Here is the call graph for this function:

◆ parse_finish()

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() -.

Return values
MUTT_CMD_FINISHStop processing the current file
MUTT_CMD_WARNINGFailed

If the 'finish' command is found, we should stop reading the current file.

Parse:

  • finish

Definition at line 150 of file ifdef.c.

152{
153 struct Buffer *err = pe->message;
154
155 if (MoreArgs(line))
156 {
157 buf_printf(err, _("%s: too many arguments"), cmd->name);
158 return MUTT_CMD_WARNING;
159 }
160
161 return MUTT_CMD_FINISH;
162}
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
Definition command.h:41
+ Here is the call graph for this function:

◆ parse_mailboxes()

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() -.

Parse:

  • mailboxes [[ -label <label> ] | -nolabel ] [[ -notify | -nonotify ] [ -poll | -nopoll ] <mailbox> ] [ ... ]
  • named-mailboxes <description> <mailbox> [ <description> <mailbox> ... ]

Definition at line 349 of file mailboxes.c.

351{
352 struct Buffer *err = pe->message;
353
354 struct ParseMailboxArray args = ARRAY_HEAD_INITIALIZER;
356
357 if (!parse_mailboxes_args(cmd, line, err, &args))
358 goto done;
359
360 rc = parse_mailboxes_exec(cmd, &args, err);
361
362done:
364 return rc;
365}
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
void parse_mailbox_array_free(struct ParseMailboxArray *pma)
Free a ParseMailboxArray.
Definition mailboxes.c:181
bool parse_mailboxes_args(const struct Command *cmd, struct Buffer *line, struct Buffer *err, struct ParseMailboxArray *args)
Parse the 'mailboxes' and 'named-mailboxes' commands.
Definition mailboxes.c:206
enum CommandResult parse_mailboxes_exec(const struct Command *cmd, struct ParseMailboxArray *args, struct Buffer *err)
Execute the 'mailboxes' or 'named-mailboxes' command.
Definition mailboxes.c:322
+ Here is the call graph for this function:

◆ parse_unmailboxes()

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() -.

Parse:

  • unmailboxes { * | <mailbox> ... }

Definition at line 440 of file mailboxes.c.

442{
443 struct Buffer *err = pe->message;
444
445 if (!MoreArgs(line))
446 {
447 buf_printf(err, _("%s: too few arguments"), cmd->name);
448 return MUTT_CMD_WARNING;
449 }
450
451 struct Buffer *token = buf_pool_get();
452
453 while (MoreArgs(line))
454 {
456
457 if (mutt_str_equal(buf_string(token), "*"))
458 {
460 goto done;
461 }
462
463 expand_path(token, false);
464
465 struct Account **ap = NULL;
467 {
468 struct Mailbox *m = mx_mbox_find(*ap, buf_string(token));
469 if (m)
470 {
472 break;
473 }
474 }
475 }
476
477done:
478 buf_pool_release(&token);
479 return MUTT_CMD_SUCCESS;
480}
static void do_unmailboxes_star(void)
Remove all Mailboxes from the Sidebar/notifications.
Definition mailboxes.c:422
static void do_unmailboxes(struct Mailbox *m)
Remove a Mailbox from the Sidebar/notifications.
Definition mailboxes.c:371
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:122
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition mx.c:1546
A group of associated Mailboxes.
Definition account.h:36
A mailbox.
Definition mailbox.h:78
struct AccountArray accounts
All Accounts.
Definition neomutt.h:50
+ Here is the call graph for this function:

◆ parse_cd()

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() -.

Parse:

  • cd [ <directory> ]

Definition at line 59 of file parse.c.

61{
62 struct Buffer *err = pe->message;
63
64 struct Buffer *token = buf_pool_get();
66
68 if (buf_is_empty(token))
69 {
71 }
72 else
73 {
74 expand_path(token, false);
75 }
76
77 if (chdir(buf_string(token)) != 0)
78 {
79 buf_printf(err, "%s: %s", cmd->name, strerror(errno));
80 goto done;
81 }
82
84
85done:
86 buf_pool_release(&token);
87 return rc;
88}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
char * home_dir
User's home directory.
Definition neomutt.h:56
+ Here is the call graph for this function:

◆ parse_echo()

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() -.

Parse:

  • echo <message>

Definition at line 96 of file parse.c.

98{
99 struct Buffer *err = pe->message;
100
101 if (!MoreArgs(line))
102 {
103 buf_printf(err, _("%s: too few arguments"), cmd->name);
104 return MUTT_CMD_WARNING;
105 }
106
107 struct Buffer *token = buf_pool_get();
108
110 OptForceRefresh = true;
111 mutt_message("%s", buf_string(token));
112 OptForceRefresh = false;
113 mutt_sleep(0);
114
115 buf_pool_release(&token);
116 return MUTT_CMD_SUCCESS;
117}
bool OptForceRefresh
(pseudo) refresh even during macros
Definition globals.c:47
#define mutt_message(...)
Definition logging2.h:93
void mutt_sleep(short s)
Sleep for a while.
Definition muttlib.c:787
+ Here is the call graph for this function:

◆ parse_version()

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() -.

Parse:

  • version

Definition at line 125 of file parse.c.

127{
128 struct Buffer *err = pe->message;
129
130 // silently ignore 'version' if it's in a config file
131 if (!StartupComplete)
132 return MUTT_CMD_SUCCESS;
133
134 if (MoreArgs(line))
135 {
136 buf_printf(err, _("%s: too many arguments"), cmd->name);
137 return MUTT_CMD_WARNING;
138 }
139
140 struct Buffer *tempfile = buf_pool_get();
142
143 buf_mktemp(tempfile);
144
145 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
146 if (!fp_out)
147 {
148 // L10N: '%s' is the file name of the temporary file
149 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
150 goto done;
151 }
152
153 print_version(fp_out, false);
154 mutt_file_fclose(&fp_out);
155
156 struct PagerData pdata = { 0 };
157 struct PagerView pview = { &pdata };
158
159 pdata.fname = buf_string(tempfile);
160
161 pview.banner = cmd->name;
163 pview.mode = PAGER_MODE_OTHER;
164
165 mutt_do_pager(&pview, NULL);
166 rc = MUTT_CMD_SUCCESS;
167
168done:
169 buf_pool_release(&tempfile);
170 return rc;
171}
bool StartupComplete
When the config has been read.
Definition address.c:11
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:122
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
#define MUTT_PAGER_NO_FLAGS
No flags are set.
Definition lib.h:62
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition lib.h:142
Data to be displayed by PagerView.
Definition lib.h:161
const char * fname
Name of the file to read.
Definition lib.h:165
Paged view into some data.
Definition lib.h:172
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:173
enum PagerMode mode
Pager mode.
Definition lib.h:174
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:175
const char * banner
Title to display in status bar.
Definition lib.h:176
#define buf_mktemp(buf)
Definition tmp.h:33
bool print_version(FILE *fp, bool use_ansi)
Print system and compile info to a file.
Definition version.c:589
+ Here is the call graph for this function:

◆ parse_setenv()

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() -.

Parse:

  • setenv { <variable>? | <variable>=<value> }
  • unsetenv <variable>

Note: Also accepts the old syntax: setenv <variable> <value>

Definition at line 67 of file setenv.c.

69{
70 struct Buffer *err = pe->message;
71
72 struct Buffer *token = buf_pool_get();
73 struct Buffer *tempfile = NULL;
75
76 char **envp = NeoMutt->env;
77
78 bool query = false;
79 bool prefix = false;
80 bool unset = (cmd->id == CMD_UNSETENV);
81
82 if (!MoreArgs(line))
83 {
84 if (!StartupComplete)
85 {
86 buf_printf(err, _("%s: too few arguments"), cmd->name);
87 goto done;
88 }
89
90 tempfile = buf_pool_get();
91 buf_mktemp(tempfile);
92
93 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
94 if (!fp_out)
95 {
96 // L10N: '%s' is the file name of the temporary file
97 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
98 rc = MUTT_CMD_ERROR;
99 goto done;
100 }
101
102 int count = 0;
103 for (char **env = NeoMutt->env; *env; env++)
104 count++;
105
106 mutt_qsort_r(NeoMutt->env, count, sizeof(char *), envlist_sort, NULL);
107
108 for (char **env = NeoMutt->env; *env; env++)
109 fprintf(fp_out, "%s\n", *env);
110
111 mutt_file_fclose(&fp_out);
112
113 struct PagerData pdata = { 0 };
114 struct PagerView pview = { &pdata };
115
116 pdata.fname = buf_string(tempfile);
117
118 pview.banner = cmd->name;
120 pview.mode = PAGER_MODE_OTHER;
121
122 mutt_do_pager(&pview, NULL);
123
124 rc = MUTT_CMD_SUCCESS;
125 goto done;
126 }
127
128 if (*line->dptr == '?')
129 {
130 query = true;
131 prefix = true;
132
133 if (unset)
134 {
135 buf_printf(err, _("Can't query option with the '%s' command"), cmd->name);
136 goto done;
137 }
138
139 line->dptr++;
140 }
141
142 /* get variable name */
144
145 /* Validate variable name: must match [_a-zA-Z][_a-zA-Z0-9]* */
146 const char *name = buf_string(token);
147 if (!buf_is_empty(token))
148 {
149 /* First character must be a letter or underscore */
150 if (!isalpha(name[0]) && (name[0] != '_'))
151 {
152 buf_printf(err, _("%s: invalid variable name '%s'"), cmd->name, name);
153 goto done;
154 }
155 /* Subsequent characters must be letter, digit, or underscore */
156 for (size_t i = 1; name[i] != '\0'; i++)
157 {
158 if (!isalpha(name[i]) && !mutt_isdigit(name[i]) && (name[i] != '_'))
159 {
160 buf_printf(err, _("%s: invalid variable name '%s'"), cmd->name, name);
161 goto done;
162 }
163 }
164 }
165
166 if (*line->dptr == '?')
167 {
168 if (unset)
169 {
170 buf_printf(err, _("Can't query option with the '%s' command"), cmd->name);
171 goto done;
172 }
173
174 if (prefix)
175 {
176 buf_printf(err, _("Can't use a prefix when querying a variable"));
177 goto done;
178 }
179
180 query = true;
181 line->dptr++;
182 }
183
184 if (query)
185 {
186 bool found = false;
187 while (envp && *envp)
188 {
189 /* This will display all matches for "^QUERY" */
190 if (mutt_str_startswith(*envp, buf_string(token)))
191 {
192 if (!found)
193 {
194 mutt_endwin();
195 found = true;
196 }
197 puts(*envp);
198 }
199 envp++;
200 }
201
202 if (found)
203 {
205 rc = MUTT_CMD_SUCCESS;
206 goto done;
207 }
208
209 buf_printf(err, _("%s is unset"), buf_string(token));
210 goto done;
211 }
212
213 if (unset)
214 {
216 rc = MUTT_CMD_SUCCESS;
217 goto done;
218 }
219
220 /* set variable */
221
222 if (*line->dptr == '=')
223 {
224 line->dptr++;
225 SKIPWS(line->dptr);
226 }
227
228 if (!MoreArgs(line))
229 {
230 buf_printf(err, _("%s: too few arguments"), cmd->name);
231 goto done;
232 }
233
234 char *varname = mutt_str_dup(buf_string(token));
236 envlist_set(&NeoMutt->env, varname, buf_string(token), true);
237 FREE(&varname);
238
239 rc = MUTT_CMD_SUCCESS;
240
241done:
242 buf_pool_release(&token);
243 buf_pool_release(&tempfile);
244 return rc;
245}
@ CMD_UNSETENV
:unsetenv
Definition command.h:143
bool mutt_isdigit(int arg)
Wrapper for isdigit(3)
Definition ctype.c:66
bool envlist_set(char ***envp, const char *name, const char *value, bool overwrite)
Set an environment variable.
Definition envlist.c:88
bool envlist_unset(char ***envp, const char *name)
Unset an environment variable.
Definition envlist.c:140
#define TOKEN_EQUAL
Treat '=' as a special.
Definition extract.h:46
#define TOKEN_QUESTION
Treat '?' as a special.
Definition extract.h:55
static int envlist_sort(const void *a, const void *b, void *sdata)
Compare two environment strings - Implements sort_t -.
Definition setenv.c:53
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition string.c:234
void mutt_qsort_r(void *base, size_t nmemb, size_t size, sort_t compar, void *sdata)
Sort an array, where the comparator has access to opaque data rather than requiring global variables.
Definition qsort_r.c:72
#define SKIPWS(ch)
Definition string2.h:52
char ** env
Private copy of the environment variables.
Definition neomutt.h:58
+ Here is the call graph for this function:

◆ parse_source()

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() -.

Parse:

  • source <filename> [ <filename> ... ]

Definition at line 229 of file source.c.

231{
232 struct Buffer *err = pe->message;
233
234 if (!MoreArgs(line))
235 {
236 buf_printf(err, _("%s: too few arguments"), cmd->name);
237 return MUTT_CMD_WARNING;
238 }
239
240 struct Buffer *token = buf_pool_get();
241 struct Buffer *path = buf_pool_get();
243
244 do
245 {
246 if (parse_extract_token(token, line, TOKEN_BACKTICK_VARS) != 0)
247 {
248 buf_printf(err, _("source: error at %s"), line->dptr);
249 goto done;
250 }
251 buf_copy(path, token);
252 expand_path(path, false);
253
254 // Cheat: Remove the `const` so we can recurse
255 if (source_rc(buf_string(path), (struct ParseContext *) pc, pe) < 0)
256 {
257 buf_printf(err, _("source: file %s could not be sourced"), buf_string(path));
258 goto done;
259 }
260
261 } while (MoreArgs(line));
262
263 rc = MUTT_CMD_SUCCESS;
264
265done:
266 buf_pool_release(&path);
267 buf_pool_release(&token);
268 return rc;
269}
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
Definition buffer.c:601
#define TOKEN_BACKTICK_VARS
Expand variables within backticks.
Definition extract.h:53
int source_rc(const char *rcfile_path, struct ParseContext *pc, struct ParseError *pe)
Read an initialization file.
Definition source.c:67
+ Here is the call graph for this function:

◆ parse_stailq()

enum CommandResult parse_stailq ( const struct Command * cmd,
struct Buffer * line,
struct ListHead * list,
const struct ParseContext * pc,
struct ParseError * pe )

Parse a list command - Implements Command::parse() -.

Parameters
cmdCommand being parsed
lineBuffer containing string to be parsed
listList for the results
pcParse Context
peParse Errors
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS

Definition at line 52 of file stailq.c.

55{
56 struct Buffer *err = pe->message;
57
58 if (!MoreArgs(line))
59 {
60 buf_printf(err, _("%s: too few arguments"), cmd->name);
61 return MUTT_CMD_WARNING;
62 }
63
64 struct Buffer *token = buf_pool_get();
65
66 do
67 {
69 add_to_stailq(list, buf_string(token));
70 } while (MoreArgs(line));
71
72 buf_pool_release(&token);
73 return MUTT_CMD_SUCCESS;
74}
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition list.c:316
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_unstailq()

enum CommandResult parse_unstailq ( const struct Command * cmd,
struct Buffer * line,
struct ListHead * list,
const struct ParseContext * pc,
struct ParseError * pe )

Parse an unlist command - Implements Command::parse() -.

Parameters
cmdCommand being parsed
lineBuffer containing string to be parsed
listList for the results
pcParse Context
peParse Errors
Return values
CommandResultResult e.g. MUTT_CMD_SUCCESS

Definition at line 85 of file stailq.c.

88{
89 struct Buffer *err = pe->message;
90
91 if (!MoreArgs(line))
92 {
93 buf_printf(err, _("%s: too few arguments"), cmd->name);
94 return MUTT_CMD_WARNING;
95 }
96
97 struct Buffer *token = buf_pool_get();
98
99 do
100 {
102 /* Check for deletion of entire list */
103 if (mutt_str_equal(buf_string(token), "*"))
104 {
105 mutt_list_free(list);
106 break;
107 }
108 remove_from_stailq(list, buf_string(token));
109 } while (MoreArgs(line));
110
111 buf_pool_release(&token);
112 return MUTT_CMD_SUCCESS;
113}
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition list.c:341
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_list()

enum CommandResult parse_list ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse a list command - Implements Command::parse() -.

Parse:

  • alternative-order <mime-type>[/<mime-subtype> ] [ <mime-type>[/<mime-subtype> ] ... ]
  • auto-view <mime-type>[/<mime-subtype> ] [ <mime-type>[/<mime-subtype> ] ... ]
  • header-order <header> [ <header> ... ]
  • mailto-allow { * | <header-field> ... }

Definition at line 51 of file commands.c.

53{
55 ASSERT(md);
56
57 switch (cmd->id)
58 {
60 return parse_stailq(cmd, line, &md->alternative_order, pc, pe);
61
62 case CMD_AUTO_VIEW:
63 return parse_stailq(cmd, line, &md->auto_view, pc, pe);
64
66 return parse_stailq(cmd, line, &md->header_order, pc, pe);
67
69 return parse_stailq(cmd, line, &md->mail_to_allow, pc, pe);
70
71 default:
72 ASSERT(false);
73 }
74
75 return MUTT_CMD_ERROR;
76}
@ CMD_MAILTO_ALLOW
:mailto-allow
Definition command.h:92
@ CMD_AUTO_VIEW
:auto-view
Definition command.h:66
@ CMD_ALTERNATIVE_ORDER
:alternative-order
Definition command.h:63
@ CMD_HEADER_ORDER
:header-order
Definition command.h:80
@ MODULE_ID_EMAIL
ModuleEmail, Email code
Definition module_api.h:64
Email private Module data.
Definition module_data.h:32
struct ListHead auto_view
List of mime types to auto view.
Definition module_data.h:35
struct ListHead mail_to_allow
Permitted fields in a mailto: url.
Definition module_data.h:39
struct ListHead alternative_order
List of preferred mime types to display.
Definition module_data.h:33
struct ListHead header_order
List of header fields in the order they should be displayed.
Definition module_data.h:36
+ Here is the call graph for this function:

◆ parse_unlist()

enum CommandResult parse_unlist ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse an unlist command - Implements Command::parse() -.

Parse:

  • unalternative-order { * | [ <mime-type>[/<mime-subtype> ] ... ] }
  • unauto-view { * | [ <mime-type>[/<mime-subtype> ] ... ] }
  • unheader-order { * | <header> ... }
  • unmailto-allow { * | <header-field> ... }

Definition at line 87 of file commands.c.

89{
91 ASSERT(md);
92
93 switch (cmd->id)
94 {
96 return parse_unstailq(cmd, line, &md->alternative_order, pc, pe);
97
98 case CMD_UNAUTO_VIEW:
99 return parse_unstailq(cmd, line, &md->auto_view, pc, pe);
100
102 return parse_unstailq(cmd, line, &md->header_order, pc, pe);
103
105 return parse_unstailq(cmd, line, &md->mail_to_allow, pc, pe);
106
107 default:
108 ASSERT(false);
109 }
110
111 return MUTT_CMD_ERROR;
112}
@ CMD_UNALTERNATIVE_ORDER
:unalternative-order
Definition command.h:125
@ CMD_UNAUTO_VIEW
:unauto-view
Definition command.h:127
@ CMD_UNHEADER_ORDER
:unheader-order
Definition command.h:131
@ CMD_UNMAILTO_ALLOW
:unmailto-allow
Definition command.h:137
+ Here is the call graph for this function:

◆ parse_tag_formats()

enum CommandResult parse_tag_formats ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'tag-formats' command - Implements Command::parse() -.

Parse config like: tag-formats pgp GP

Note
This maps format -> tag

Parse:

  • tag-formats <tag> <format-string> [ <tag> <format-string> ... ] }

Definition at line 124 of file commands.c.

126{
127 struct Buffer *err = pe->message;
128
129 if (!MoreArgs(line))
130 {
131 buf_printf(err, _("%s: too few arguments"), cmd->name);
132 return MUTT_CMD_WARNING;
133 }
134
135 struct Buffer *tag = buf_pool_get();
136 struct Buffer *fmt = buf_pool_get();
137
139 ASSERT(md);
140
141 while (MoreArgs(line))
142 {
144 if (buf_is_empty(tag))
145 continue;
146
148
149 /* avoid duplicates */
150 const char *tmp = mutt_hash_find(md->tag_formats, buf_string(fmt));
151 if (tmp)
152 {
153 mutt_warning(_("tag format '%s' already registered as '%s'"), buf_string(fmt), tmp);
154 continue;
155 }
156
158 }
159
160 buf_pool_release(&tag);
161 buf_pool_release(&fmt);
162 return MUTT_CMD_SUCCESS;
163}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
#define mutt_warning(...)
Definition logging2.h:92
struct HashElem * mutt_hash_insert(struct HashTable *table, const char *strkey, void *data)
Add a new element to the Hash Table (with string keys)
Definition hash.c:337
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition hash.c:364
struct HashTable * tag_formats
Hash Table: "inbox" -> "GI" - Tag format strings.
Definition module_data.h:43
+ Here is the call graph for this function:

◆ parse_tag_transforms()

enum CommandResult parse_tag_transforms ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'tag-transforms' command - Implements Command::parse() -.

Parse config like: tag-transforms pgp P

Note
This maps tag -> transform

Parse:

  • tag-transforms <tag> <transformed-string> [ <tag> <transformed-string> ... ]}

Definition at line 175 of file commands.c.

178{
179 struct Buffer *err = pe->message;
180
181 if (!MoreArgs(line))
182 {
183 buf_printf(err, _("%s: too few arguments"), cmd->name);
184 return MUTT_CMD_WARNING;
185 }
186
187 struct Buffer *tag = buf_pool_get();
188 struct Buffer *trans = buf_pool_get();
189
191 ASSERT(md);
192
193 while (MoreArgs(line))
194 {
196 if (buf_is_empty(tag))
197 continue;
198
200 const char *trn = buf_string(trans);
201
202 /* avoid duplicates */
203 const char *tmp = mutt_hash_find(md->tag_transforms, buf_string(tag));
204 if (tmp)
205 {
206 mutt_warning(_("tag transform '%s' already registered as '%s'"),
207 buf_string(tag), tmp);
208 continue;
209 }
210
212 }
213
214 buf_pool_release(&tag);
215 buf_pool_release(&trans);
216 return MUTT_CMD_SUCCESS;
217}
struct HashTable * tag_transforms
Hash Table: "inbox" -> "i" - Alternative tag names.
Definition module_data.h:44
+ Here is the call graph for this function:

◆ parse_group()

enum CommandResult parse_group ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'group' and 'ungroup' commands - Implements Command::parse() -.

Parse:

  • group [ -group <name> ... ] { -rx <regex> ... | -addr <address> ... }
  • ungroup [ -group <name> ... ] { * | -rx <regex> ... | -addr <address> ... }

Definition at line 90 of file group.c.

92{
93 struct Buffer *err = pe->message;
94
95 if (!MoreArgs(line))
96 {
97 buf_printf(err, _("%s: too few arguments"), cmd->name);
98 return MUTT_CMD_WARNING;
99 }
100
101 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
102 enum GroupState gstate = GS_NONE;
103 struct Buffer *token = buf_pool_get();
105
106 do
107 {
109 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
110 goto done;
111
112 if ((cmd->id == CMD_UNGROUP) && mutt_istr_equal(buf_string(token), "*"))
113 {
115 rc = MUTT_CMD_SUCCESS;
116 goto done;
117 }
118
119 if (mutt_istr_equal(buf_string(token), "-rx"))
120 {
121 gstate = GS_RX;
122 }
123 else if (mutt_istr_equal(buf_string(token), "-addr"))
124 {
125 gstate = GS_ADDR;
126 }
127 else
128 {
129 switch (gstate)
130 {
131 case GS_NONE:
132 buf_printf(err, _("%s: missing -rx or -addr"), cmd->name);
133 rc = MUTT_CMD_WARNING;
134 goto done;
135
136 case GS_RX:
137 if ((cmd->id == CMD_GROUP) &&
138 (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0))
139 {
140 goto done;
141 }
142 else if ((cmd->id == CMD_UNGROUP) &&
143 (groups_remove_regex(NeoMutt->groups, &gl, buf_string(token)) < 0))
144 {
145 goto done;
146 }
147 break;
148
149 case GS_ADDR:
150 {
151 char *estr = NULL;
152 struct AddressList al = TAILQ_HEAD_INITIALIZER(al);
153 mutt_addrlist_parse2(&al, buf_string(token));
154 if (TAILQ_EMPTY(&al))
155 goto done;
156 if (mutt_addrlist_to_intl(&al, &estr))
157 {
158 buf_printf(err, _("%s: warning: bad IDN '%s'"), cmd->name, estr);
160 FREE(&estr);
161 goto done;
162 }
163 if (cmd->id == CMD_GROUP)
164 grouplist_add_addrlist(&gl, &al);
165 else if (cmd->id == CMD_UNGROUP)
168 break;
169 }
170 }
171 }
172 } while (MoreArgs(line));
173
174 rc = MUTT_CMD_SUCCESS;
175
176done:
177 buf_pool_release(&token);
179 return rc;
180}
int groups_remove_addrlist(struct HashTable *groups, struct GroupList *gl, struct AddressList *al)
Remove an AddressList from a GroupList.
Definition group.c:337
void groups_remove_grouplist(struct HashTable *groups, struct GroupList *gl)
Clear a GroupList.
Definition group.c:312
int groups_remove_regex(struct HashTable *groups, struct GroupList *gl, const char *str)
Remove matching addresses from a GroupList.
Definition group.c:368
@ CMD_GROUP
:group
Definition command.h:79
@ CMD_UNGROUP
:ungroup
Definition command.h:130
GroupState
Type of email address group.
Definition group.h:38
@ GS_RX
Entry is a regular expression.
Definition group.h:40
@ GS_NONE
Group is missing an argument.
Definition group.h:39
@ GS_ADDR
Entry is an address.
Definition group.h:41
#define TAILQ_EMPTY(head)
Definition queue.h:778
+ Here is the call graph for this function:

◆ parse_lists()

enum CommandResult parse_lists ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'lists' command - Implements Command::parse() -.

Parse:

  • lists [ -group <name> ... ] <regex> [ <regex> ... ]

Definition at line 188 of file group.c.

190{
191 struct Buffer *err = pe->message;
192
193 if (!MoreArgs(line))
194 {
195 buf_printf(err, _("%s: too few arguments"), cmd->name);
196 return MUTT_CMD_WARNING;
197 }
198
199 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
200 struct Buffer *token = buf_pool_get();
202
204 ASSERT(md);
205
206 do
207 {
209
210 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
211 goto done;
212
214
215 if (mutt_regexlist_add(&md->mail, buf_string(token), REG_ICASE, err) != 0)
216 goto done;
217
218 if (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0)
219 goto done;
220 } while (MoreArgs(line));
221
222 rc = MUTT_CMD_SUCCESS;
223
224done:
225 buf_pool_release(&token);
227 return rc;
228}
struct RegexList unmail
Regexes to exclude false matches in mail.
Definition module_data.h:46
struct RegexList mail
Regexes to match mailing lists.
Definition module_data.h:38
+ Here is the call graph for this function:

◆ parse_subscribe()

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() -.

Parse:

  • subscribe [ -group <name> ... ] <regex> [ <regex> ... ]

Definition at line 236 of file group.c.

238{
239 struct Buffer *err = pe->message;
240
241 if (!MoreArgs(line))
242 {
243 buf_printf(err, _("%s: too few arguments"), cmd->name);
244 return MUTT_CMD_WARNING;
245 }
246
247 struct GroupList gl = STAILQ_HEAD_INITIALIZER(gl);
248 struct Buffer *token = buf_pool_get();
250
252 ASSERT(md);
253
254 do
255 {
257
258 if (parse_grouplist(&gl, token, line, err, NeoMutt->groups) == -1)
259 goto done;
260
263
264 if (mutt_regexlist_add(&md->mail, buf_string(token), REG_ICASE, err) != 0)
265 goto done;
266
267 if (mutt_regexlist_add(&md->subscribed, buf_string(token), REG_ICASE, err) != 0)
268 goto done;
269
270 if (grouplist_add_regex(&gl, buf_string(token), REG_ICASE, err) != 0)
271 goto done;
272 } while (MoreArgs(line));
273
274 rc = MUTT_CMD_SUCCESS;
275
276done:
277 buf_pool_release(&token);
279 return rc;
280}
struct RegexList unsubscribed
Regexes to exclude false matches in subscribed.
Definition module_data.h:47
struct RegexList subscribed
Regexes to match subscribed mailing lists.
Definition module_data.h:42
+ Here is the call graph for this function:

◆ parse_unlists()

enum CommandResult parse_unlists ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unlists' command - Implements Command::parse() -.

Parse:

  • unlists { * | <regex> ... }

Definition at line 288 of file group.c.

290{
291 struct Buffer *err = pe->message;
292
293 if (!MoreArgs(line))
294 {
295 buf_printf(err, _("%s: too few arguments"), cmd->name);
296 return MUTT_CMD_WARNING;
297 }
298
299 struct Buffer *token = buf_pool_get();
301
303 ASSERT(md);
304
306 do
307 {
311
312 if (!mutt_str_equal(buf_string(token), "*") &&
313 (mutt_regexlist_add(&md->unmail, buf_string(token), REG_ICASE, err) != 0))
314 {
315 goto done;
316 }
317 } while (MoreArgs(line));
318
319 rc = MUTT_CMD_SUCCESS;
320
321done:
322 buf_pool_release(&token);
323 return rc;
324}
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:459
struct HashTable * auto_subscribe_cache
Hash Table: "mailto:" (no value)
Definition module_data.h:34
+ Here is the call graph for this function:

◆ parse_unsubscribe()

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() -.

Parse:

  • unsubscribe { * | <regex> ... }

Definition at line 332 of file group.c.

334{
335 struct Buffer *err = pe->message;
336
337 if (!MoreArgs(line))
338 {
339 buf_printf(err, _("%s: too few arguments"), cmd->name);
340 return MUTT_CMD_WARNING;
341 }
342
344 ASSERT(md);
345
346 struct Buffer *token = buf_pool_get();
348
350 do
351 {
354
355 if (!mutt_str_equal(buf_string(token), "*") &&
356 (mutt_regexlist_add(&md->unsubscribed, buf_string(token), REG_ICASE, err) != 0))
357 {
358 goto done;
359 }
360 } while (MoreArgs(line));
361
362 rc = MUTT_CMD_SUCCESS;
363
364done:
365 buf_pool_release(&token);
366 return rc;
367}
+ Here is the call graph for this function:

◆ parse_ignore()

enum CommandResult parse_ignore ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'ignore' command - Implements Command::parse() -.

Parse:

  • ignore <string> [ <string> ...]

Definition at line 50 of file ignore.c.

52{
53 struct Buffer *err = pe->message;
54
55 if (!MoreArgs(line))
56 {
57 buf_printf(err, _("%s: too few arguments"), cmd->name);
58 return MUTT_CMD_WARNING;
59 }
60
61 struct Buffer *token = buf_pool_get();
62
64 ASSERT(md);
65
66 do
67 {
70 add_to_stailq(&md->ignore, buf_string(token));
71 } while (MoreArgs(line));
72
73 buf_pool_release(&token);
74 return MUTT_CMD_SUCCESS;
75}
struct ListHead unignore
Header patterns to unignore.
Definition module_data.h:45
struct ListHead ignore
Header patterns to ignore.
Definition module_data.h:37
+ Here is the call graph for this function:

◆ parse_unignore()

enum CommandResult parse_unignore ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unignore' command - Implements Command::parse() -.

Parse:

  • unignore { * | <string> ... }

Definition at line 83 of file ignore.c.

85{
86 struct Buffer *err = pe->message;
87
88 if (!MoreArgs(line))
89 {
90 buf_printf(err, _("%s: too few arguments"), cmd->name);
91 return MUTT_CMD_WARNING;
92 }
93
94 struct Buffer *token = buf_pool_get();
95
97 ASSERT(md);
98
99 do
100 {
102
103 /* don't add "*" to the unignore list */
104 if (!mutt_str_equal(buf_string(token), "*"))
105 add_to_stailq(&md->unignore, buf_string(token));
106
108 } while (MoreArgs(line));
109
110 buf_pool_release(&token);
111 return MUTT_CMD_SUCCESS;
112}
+ Here is the call graph for this function:

◆ parse_score()

enum CommandResult parse_score ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'score' command - Implements Command::parse() -.

Parse:

  • score <pattern> <value>

Definition at line 57 of file score.c.

59{
60 struct Buffer *err = pe->message;
61
62 if (!MoreArgs(line))
63 {
64 buf_printf(err, _("%s: too few arguments"), cmd->name);
65 return MUTT_CMD_WARNING;
66 }
67
68 struct Score *ptr = NULL, *last = NULL;
69 char *pattern = NULL, *patchar = NULL;
70 struct Buffer *token = buf_pool_get();
72
74 if (!MoreArgs(line))
75 {
76 buf_printf(err, _("%s: too few arguments"), cmd->name);
77 goto done;
78 }
79 pattern = buf_strdup(token);
81 if (MoreArgs(line))
82 {
83 buf_printf(err, _("%s: too many arguments"), cmd->name);
84 goto done;
85 }
86
87 /* look for an existing entry and update the value, else add it to the end
88 * of the list */
89 for (ptr = ScoreList, last = NULL; ptr; last = ptr, ptr = ptr->next)
90 if (mutt_str_equal(pattern, ptr->str))
91 break;
92
93 if (ptr)
94 {
95 /* 'token' arg was cleared and 'pattern' holds the only reference;
96 * as here 'ptr' != NULL -> update the value only in which case
97 * ptr->str already has the string, so pattern should be freed. */
98 FREE(&pattern);
99 }
100 else
101 {
102 struct MailboxView *mv_cur = get_current_mailbox_view();
103 struct PatternList *pat = mutt_pattern_comp(mv_cur, pattern, MUTT_PC_NO_FLAGS, err);
104 if (!pat)
105 {
106 goto done;
107 }
108 ptr = MUTT_MEM_CALLOC(1, struct Score);
109 if (last)
110 last->next = ptr;
111 else
112 ScoreList = ptr;
113 ptr->pat = pat;
114 ptr->str = pattern;
115 pattern = NULL;
116 }
117
118 patchar = token->data;
119 if (*patchar == '=')
120 {
121 ptr->exact = true;
122 patchar++;
123 }
124
125 if (!mutt_str_atoi_full(patchar, &ptr->val))
126 {
127 buf_strcpy(err, _("Error: score: invalid number"));
128 goto done;
129 }
130 OptNeedRescore = true;
131
132 rc = MUTT_CMD_SUCCESS;
133
134done:
135 buf_pool_release(&token);
136 FREE(&pattern);
137 return rc;
138}
struct PatternList * mutt_pattern_comp(struct MailboxView *mv, const char *s, PatternCompFlags flags, struct Buffer *err)
Create a Pattern.
Definition compile.c:954
bool OptNeedRescore
(pseudo) set when the 'score' command is used
Definition globals.c:51
struct MailboxView * get_current_mailbox_view(void)
Get the current Mailbox view.
Definition index.c:689
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
#define MUTT_PC_NO_FLAGS
No flags are set.
Definition lib.h:69
struct Score * ScoreList
Linked list of email scoring rules.
Definition score.c:49
View of a Mailbox.
Definition mview.h:40
Scoring rule for email.
Definition score.h:38
struct Score * next
Linked list.
Definition score.h:43
+ Here is the call graph for this function:

◆ parse_unscore()

enum CommandResult parse_unscore ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unscore' command - Implements Command::parse() -.

Parse:

  • unscore { * | <pattern> ... }

Definition at line 146 of file score.c.

148{
149 struct Buffer *err = pe->message;
150
151 if (!MoreArgs(line))
152 {
153 buf_printf(err, _("%s: too few arguments"), cmd->name);
154 return MUTT_CMD_WARNING;
155 }
156
157 struct Score *tmp = NULL, *last = NULL;
158 struct Buffer *token = buf_pool_get();
159
160 while (MoreArgs(line))
161 {
163 if (mutt_str_equal("*", buf_string(token)))
164 {
165 for (tmp = ScoreList; tmp;)
166 {
167 last = tmp;
168 tmp = tmp->next;
169 mutt_pattern_free(&last->pat);
170 FREE(&last);
171 }
172 ScoreList = NULL;
173 }
174 else
175 {
176 for (tmp = ScoreList; tmp; last = tmp, tmp = tmp->next)
177 {
178 if (mutt_str_equal(buf_string(token), tmp->str))
179 {
180 if (last)
181 last->next = tmp->next;
182 else
183 ScoreList = tmp->next;
184 mutt_pattern_free(&tmp->pat);
185 FREE(&tmp);
186 /* there should only be one score per pattern, so we can stop here */
187 break;
188 }
189 }
190 }
191 }
192
193 OptNeedRescore = true;
194 buf_pool_release(&token);
195 return MUTT_CMD_SUCCESS;
196}
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:826
+ Here is the call graph for this function:

◆ parse_nospam()

enum CommandResult parse_nospam ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'nospam' command - Implements Command::parse() -.

Parse:

  • nospam { * | <regex> }

Definition at line 51 of file spam.c.

53{
54 struct Buffer *err = pe->message;
55
56 if (!MoreArgs(line))
57 {
58 buf_printf(err, _("%s: too few arguments"), cmd->name);
59 return MUTT_CMD_WARNING;
60 }
61
62 struct Buffer *token = buf_pool_get();
64
65 // Extract the first token, a regex or "*"
67
68 if (MoreArgs(line))
69 {
70 buf_printf(err, _("%s: too many arguments"), cmd->name);
71 goto done;
72 }
73
75 ASSERT(md);
76
77 // "*" is special - clear both spam and nospam lists
78 if (mutt_str_equal(buf_string(token), "*"))
79 {
83 goto done;
84 }
85
86 // If it's on the spam list, just remove it
87 if (mutt_replacelist_remove(&md->spam, buf_string(token)) != 0)
88 {
90 goto done;
91 }
92
93 // Otherwise, add it to the nospam list
94 if (mutt_regexlist_add(&md->no_spam, buf_string(token), REG_ICASE, err) != 0)
95 {
96 rc = MUTT_CMD_ERROR;
97 goto done;
98 }
99
100 rc = MUTT_CMD_SUCCESS;
101
102done:
103 buf_pool_release(&token);
104 return rc;
105}
int mutt_replacelist_remove(struct ReplaceList *rl, const char *pat)
Remove a pattern from a list.
Definition regex.c:566
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition regex.c:179
void mutt_replacelist_free(struct ReplaceList *rl)
Free a ReplaceList object.
Definition regex.c:450
struct ReplaceList spam
Regexes and patterns to match spam emails.
Definition module_data.h:41
struct RegexList no_spam
Regexes to identify non-spam emails.
Definition module_data.h:40
+ Here is the call graph for this function:

◆ parse_spam()

enum CommandResult parse_spam ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'spam' command - Implements Command::parse() -.

Parse:

  • spam <regex> [ <format> ]

Definition at line 113 of file spam.c.

115{
116 struct Buffer *err = pe->message;
117
118 if (!MoreArgs(line))
119 {
120 buf_printf(err, _("%s: too few arguments"), cmd->name);
121 return MUTT_CMD_WARNING;
122 }
123
124 struct Buffer *token = buf_pool_get();
125 struct Buffer *templ = NULL;
127
128 // Extract the first token, a regex
130
132 ASSERT(md);
133
134 // If there's a second parameter, it's a template for the spam tag
135 if (MoreArgs(line))
136 {
137 templ = buf_pool_get();
139
140 // Add to the spam list
141 if (mutt_replacelist_add(&md->spam, buf_string(token), buf_string(templ), err) != 0)
142 goto done;
143 }
144 else
145 {
146 // If not, try to remove from the nospam list
148 }
149
150 rc = MUTT_CMD_SUCCESS;
151
152done:
153 buf_pool_release(&templ);
154 buf_pool_release(&token);
155 return rc;
156}
int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err)
Add a pattern and a template to a list.
Definition regex.c:271
+ Here is the call graph for this function:

◆ parse_hooks()

enum CommandResult parse_hooks ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'hooks' command - Implements Command::parse() -.

Parse:

  • hooks

Definition at line 225 of file dump.c.

227{
228 struct Buffer *err = pe->message;
229
230 if (MoreArgs(line))
231 {
232 buf_printf(err, _("%s: too many arguments"), cmd->name);
233 return MUTT_CMD_WARNING;
234 }
235
236 if (!StartupComplete)
237 return MUTT_CMD_SUCCESS;
238
239 if (TAILQ_EMPTY(&Hooks))
240 {
241 buf_printf(err, _("%s: No Hooks are configured"), cmd->name);
242 return MUTT_CMD_WARNING;
243 }
244
245 struct Buffer *tempfile = buf_pool_get();
246 buf_mktemp(tempfile);
247
248 FILE *fp = mutt_file_fopen(buf_string(tempfile), "w");
249 if (!fp)
250 {
251 mutt_error(_("Could not create temporary file %s"), buf_string(tempfile));
252 buf_pool_release(&tempfile);
253 return MUTT_CMD_ERROR;
254 }
255
256 struct Buffer *buf = buf_pool_get();
257
259 hooks_dump_index(buf);
261
263 mutt_file_fclose(&fp);
264 buf_pool_release(&buf);
265
266 struct PagerData pdata = { 0 };
267 struct PagerView pview = { &pdata };
268
269 pdata.fname = buf_string(tempfile);
270
271 pview.banner = "hooks";
273 pview.mode = PAGER_MODE_OTHER;
274
275 mutt_do_pager(&pview, NULL);
276 buf_pool_release(&tempfile);
277 return MUTT_CMD_SUCCESS;
278}
size_t mutt_file_save_str(FILE *fp, const char *str)
Save a string to a file.
Definition file.c:1574
static void hooks_dump_charset(struct Buffer *buf)
Dump the Charset Hooks.
Definition dump.c:174
static void hooks_dump_index(struct Buffer *buf)
Dump the Index Format Hooks.
Definition dump.c:134
static void hooks_dump_simple(struct Buffer *buf)
Dump the simple Hooks.
Definition dump.c:94
struct HookList Hooks
All simple hooks, e.g. CMD_FOLDER_HOOK.
Definition parse.c:49
+ Here is the call graph for this function:

◆ parse_charset_hook()

enum CommandResult parse_charset_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse charset Hook commands - Implements Command::parse() -.

Parse:

  • charset-hook <alias> <charset>
  • iconv-hook <charset> <local-charset>

Definition at line 64 of file parse.c.

66{
67 struct Buffer *err = pe->message;
68
69 if (!MoreArgs(line))
70 {
71 buf_printf(err, _("%s: too few arguments"), cmd->name);
72 return MUTT_CMD_WARNING;
73 }
74
75 struct Buffer *alias = buf_pool_get();
76 struct Buffer *charset = buf_pool_get();
78
79 if (parse_extract_token(alias, line, TOKEN_NO_FLAGS) < 0)
80 goto done;
81 if (parse_extract_token(charset, line, TOKEN_NO_FLAGS) < 0)
82 goto done;
83
84 const enum LookupType type = (cmd->id == CMD_ICONV_HOOK) ? MUTT_LOOKUP_ICONV :
86
87 if (buf_is_empty(alias) || buf_is_empty(charset))
88 {
89 buf_printf(err, _("%s: too few arguments"), cmd->name);
91 }
92 else if (MoreArgs(line))
93 {
94 buf_printf(err, _("%s: too many arguments"), cmd->name);
95 buf_reset(line); // clean up buffer to avoid a mess with further rcfile processing
97 }
98 else if (mutt_ch_lookup_add(type, buf_string(alias), buf_string(charset), err))
99 {
100 rc = MUTT_CMD_SUCCESS;
101 }
102
103done:
104 buf_pool_release(&alias);
105 buf_pool_release(&charset);
106
107 return rc;
108}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition buffer.c:76
@ CMD_ICONV_HOOK
:iconv-hook
Definition command.h:82
bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err)
Add a new character set lookup.
Definition charset.c:495
LookupType
Types of character set lookups.
Definition charset.h:61
@ MUTT_LOOKUP_ICONV
Character set conversion.
Definition charset.h:63
@ MUTT_LOOKUP_CHARSET
Alias for another character set.
Definition charset.h:62
+ Here is the call graph for this function:

◆ parse_global_hook()

enum CommandResult parse_global_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse global Hook commands - Implements Command::parse() -.

Parse:

  • shutdown-hook <command>
  • startup-hook <command>
  • timeout-hook <command>

Definition at line 118 of file parse.c.

120{
121 struct Buffer *err = pe->message;
122
123 struct Hook *hook = NULL;
125
126 struct Buffer *command = buf_pool_get();
127
128 // TOKEN_SPACE allows the command to contain whitespace, without quoting
129 parse_extract_token(command, line, TOKEN_SPACE);
130
131 if (buf_is_empty(command))
132 {
133 buf_printf(err, _("%s: too few arguments"), cmd->name);
134 rc = MUTT_CMD_WARNING;
135 goto cleanup;
136 }
137
138 if (MoreArgs(line))
139 {
140 buf_printf(err, _("%s: too many arguments"), cmd->name);
141 rc = MUTT_CMD_WARNING;
142 goto cleanup;
143 }
144
145 /* check to make sure that a matching Hook doesn't already exist */
146 TAILQ_FOREACH(hook, &Hooks, entries)
147 {
148 /* Ignore duplicate global Hooks */
149 if ((hook->id == cmd->id) && mutt_str_equal(hook->command, buf_string(command)))
150 {
151 rc = MUTT_CMD_SUCCESS;
152 goto cleanup;
153 }
154 }
155
156 hook = hook_new();
157 hook->id = cmd->id;
158 hook->command = buf_strdup(command);
160 hook->pattern = NULL;
161 hook->regex.pattern = NULL;
162 hook->regex.regex = NULL;
163 hook->regex.pat_not = false;
164 hook->expando = NULL;
165
166 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
167 rc = MUTT_CMD_SUCCESS;
168
169cleanup:
170 buf_pool_release(&command);
171 return rc;
172}
struct Hook * hook_new(void)
Create a Hook.
Definition hook.c:71
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition queue.h:866
char * mutt_get_sourced_cwd(void)
Get the current file path that is being parsed.
Definition source.c:314
A list of user hooks.
Definition hook.h:33
struct PatternList * pattern
Used for fcc,save,send-hook.
Definition hook.h:38
struct Regex regex
Regular expression.
Definition hook.h:35
char * command
Filename, command or pattern to execute.
Definition hook.h:36
struct Expando * expando
Used for format hooks.
Definition hook.h:39
enum CommandId id
Hook CommandId, e.g. CMD_FOLDER_HOOK.
Definition hook.h:34
char * source_file
Used for relative-directory source.
Definition hook.h:37
char * pattern
printable version
Definition regex3.h:86
bool pat_not
do not match
Definition regex3.h:88
regex_t * regex
compiled expression
Definition regex3.h:87
+ Here is the call graph for this function:

◆ parse_pattern_hook()

enum CommandResult parse_pattern_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse pattern-based Hook commands - Implements Command::parse() -.

Parse:

  • message-hook <pattern> <command>
  • reply-hook <pattern> <command>
  • send-hook <pattern> <command>
  • send2-hook <pattern> <command>

Definition at line 183 of file parse.c.

185{
186 struct Buffer *err = pe->message;
187
188 struct Hook *hook = NULL;
190 bool pat_not = false;
191 struct PatternList *pat = NULL;
192
193 struct Buffer *command = buf_pool_get();
194 struct Buffer *pattern = buf_pool_get();
195
196 if (*line->dptr == '!')
197 {
198 line->dptr++;
199 SKIPWS(line->dptr);
200 pat_not = true;
201 }
202
203 parse_extract_token(pattern, line, TOKEN_NO_FLAGS);
204
205 if (!MoreArgs(line))
206 {
207 buf_printf(err, _("%s: too few arguments"), cmd->name);
208 rc = MUTT_CMD_WARNING;
209 goto cleanup;
210 }
211
212 // TOKEN_SPACE allows the command to contain whitespace, without quoting
213 parse_extract_token(command, line, TOKEN_SPACE);
214
215 if (buf_is_empty(command))
216 {
217 buf_printf(err, _("%s: too few arguments"), cmd->name);
218 rc = MUTT_CMD_WARNING;
219 goto cleanup;
220 }
221
222 if (MoreArgs(line))
223 {
224 buf_printf(err, _("%s: too many arguments"), cmd->name);
225 rc = MUTT_CMD_WARNING;
226 goto cleanup;
227 }
228
229 const char *const c_default_hook = cs_subset_string(NeoMutt->sub, "default_hook");
230 if (c_default_hook)
231 {
232 mutt_check_simple(pattern, c_default_hook);
233 }
234
235 /* check to make sure that a matching hook doesn't already exist */
236 TAILQ_FOREACH(hook, &Hooks, entries)
237 {
238 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
239 mutt_str_equal(buf_string(pattern), hook->regex.pattern))
240 {
241 /* these hooks allow multiple commands with the same pattern,
242 * so if we've already seen this pattern/command pair,
243 * just ignore it instead of creating a duplicate */
244 if (mutt_str_equal(hook->command, buf_string(command)))
245 {
246 rc = MUTT_CMD_SUCCESS;
247 goto cleanup;
248 }
249 }
250 }
251
252 PatternCompFlags comp_flags;
253 if (cmd->id == CMD_SEND2_HOOK)
254 comp_flags = MUTT_PC_SEND_MODE_SEARCH;
255 else if (cmd->id == CMD_SEND_HOOK)
256 comp_flags = MUTT_PC_NO_FLAGS;
257 else
258 comp_flags = MUTT_PC_FULL_MSG;
259
260 struct MailboxView *mv_cur = get_current_mailbox_view();
261 pat = mutt_pattern_comp(mv_cur, buf_string(pattern), comp_flags, err);
262 if (!pat)
263 goto cleanup;
264
265 hook = hook_new();
266 hook->id = cmd->id;
267 hook->command = buf_strdup(command);
269 hook->pattern = pat;
271 hook->regex.regex = NULL;
272 hook->regex.pat_not = pat_not;
273 hook->expando = NULL;
274
275 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
276 rc = MUTT_CMD_SUCCESS;
277
278cleanup:
279 buf_pool_release(&command);
281 return rc;
282}
@ CMD_SEND_HOOK
:send-hook
Definition command.h:107
@ CMD_SEND2_HOOK
:send2-hook
Definition command.h:106
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
#define MUTT_PC_SEND_MODE_SEARCH
Allow send-mode body searching.
Definition lib.h:72
uint8_t PatternCompFlags
Flags for mutt_pattern_comp(), e.g. MUTT_PC_FULL_MSG.
Definition lib.h:68
#define MUTT_PC_FULL_MSG
Enable body and header matching.
Definition lib.h:70
void mutt_check_simple(struct Buffer *s, const char *simple)
Convert a simple search into a real request.
Definition pattern.c:107
char * pattern
Limit pattern string.
Definition mview.h:42
+ Here is the call graph for this function:

◆ parse_mailbox_hook()

enum CommandResult parse_mailbox_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse mailbox pattern hook commands - Implements Command::parse() -.

Parse:

  • fcc-hook <pattern> <mailbox>
  • fcc-save-hook <pattern> <mailbox>
  • save-hook <pattern> <mailbox>

Definition at line 353 of file parse.c.

355{
356 struct Buffer *err = pe->message;
357
359 bool pat_not = false;
360
361 struct Buffer *pattern = buf_pool_get();
362 struct Buffer *mailbox = buf_pool_get();
363
364 if (*line->dptr == '!')
365 {
366 line->dptr++;
367 SKIPWS(line->dptr);
368 pat_not = true;
369 }
370
371 parse_extract_token(pattern, line, TOKEN_NO_FLAGS);
372
373 if (!MoreArgs(line))
374 {
375 buf_printf(err, _("%s: too few arguments"), cmd->name);
376 rc = MUTT_CMD_WARNING;
377 goto cleanup;
378 }
379
380 parse_extract_token(mailbox, line, TOKEN_NO_FLAGS);
381
382 if (buf_is_empty(mailbox))
383 {
384 buf_printf(err, _("%s: too few arguments"), cmd->name);
385 rc = MUTT_CMD_WARNING;
386 goto cleanup;
387 }
388
389 if (MoreArgs(line))
390 {
391 buf_printf(err, _("%s: too many arguments"), cmd->name);
392 rc = MUTT_CMD_WARNING;
393 goto cleanup;
394 }
395
396 const char *const c_default_hook = cs_subset_string(NeoMutt->sub, "default_hook");
397 if (c_default_hook)
398 {
399 mutt_check_simple(pattern, c_default_hook);
400 }
401
402 expand_path(mailbox, false);
403
404 if ((cmd->id == CMD_FCC_HOOK) || (cmd->id == CMD_FCC_SAVE_HOOK))
405 {
406 rc = add_mailbox_hook(CMD_FCC_HOOK, mailbox, pattern, pat_not, err);
407 if (rc != MUTT_CMD_SUCCESS)
408 goto cleanup;
409 }
410
411 if ((cmd->id == CMD_SAVE_HOOK) || (cmd->id == CMD_FCC_SAVE_HOOK))
412 {
413 rc = add_mailbox_hook(CMD_SAVE_HOOK, mailbox, pattern, pat_not, err);
414 if (rc != MUTT_CMD_SUCCESS)
415 goto cleanup;
416 }
417
418 rc = MUTT_CMD_SUCCESS;
419
420cleanup:
421 buf_pool_release(&pattern);
422 buf_pool_release(&mailbox);
423 return rc;
424}
@ CMD_FCC_SAVE_HOOK
:fcc-save-hook
Definition command.h:76
@ CMD_FCC_HOOK
:fcc-hook
Definition command.h:75
@ CMD_SAVE_HOOK
:save-hook
Definition command.h:104
enum CommandResult add_mailbox_hook(enum CommandId id, struct Buffer *mailbox, struct Buffer *pattern, bool pat_not, struct Buffer *err)
Add a Mailbox Hook.
Definition parse.c:293
+ Here is the call graph for this function:

◆ parse_regex_hook()

enum CommandResult parse_regex_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse regex-based hook command - Implements Command::parse() -.

Parse:

  • account-hook <regex> <command>

Definition at line 432 of file parse.c.

434{
435 struct Buffer *err = pe->message;
436
437 struct Hook *hook = NULL;
439 bool pat_not = false;
440 regex_t *rx = NULL;
441
442 struct Buffer *regex = buf_pool_get();
443 struct Buffer *command = buf_pool_get();
444
445 if (*line->dptr == '!')
446 {
447 line->dptr++;
448 SKIPWS(line->dptr);
449 pat_not = true;
450 }
451
453
454 if (!MoreArgs(line))
455 {
456 buf_printf(err, _("%s: too few arguments"), cmd->name);
457 rc = MUTT_CMD_WARNING;
458 goto cleanup;
459 }
460
461 parse_extract_token(command, line, TOKEN_SPACE);
462
463 if (buf_is_empty(command))
464 {
465 buf_printf(err, _("%s: too few arguments"), cmd->name);
466 rc = MUTT_CMD_WARNING;
467 goto cleanup;
468 }
469
470 if (MoreArgs(line))
471 {
472 buf_printf(err, _("%s: too many arguments"), cmd->name);
473 rc = MUTT_CMD_WARNING;
474 goto cleanup;
475 }
476
477 /* check to make sure that a matching hook doesn't already exist */
478 TAILQ_FOREACH(hook, &Hooks, entries)
479 {
480 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
481 mutt_str_equal(buf_string(regex), hook->regex.pattern))
482 {
483 // Ignore duplicate hooks
484 if (mutt_str_equal(hook->command, buf_string(command)))
485 {
486 rc = MUTT_CMD_SUCCESS;
487 goto cleanup;
488 }
489 }
490 }
491
492 /* Hooks not allowing full patterns: Check syntax of regex */
493 rx = MUTT_MEM_CALLOC(1, regex_t);
494 int rc2 = REG_COMP(rx, buf_string(regex), 0);
495 if (rc2 != 0)
496 {
497 regerror(rc2, rx, err->data, err->dsize);
498 buf_fix_dptr(err);
499 FREE(&rx);
500 goto cleanup;
501 }
502
503 hook = hook_new();
504 hook->id = cmd->id;
505 hook->command = buf_strdup(command);
507 hook->pattern = NULL;
508 hook->regex.pattern = buf_strdup(regex);
509 hook->regex.regex = rx;
510 hook->regex.pat_not = pat_not;
511 hook->expando = NULL;
512
513 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
514 rc = MUTT_CMD_SUCCESS;
515
516cleanup:
517 buf_pool_release(&regex);
518 buf_pool_release(&command);
519 return rc;
520}
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
Definition buffer.c:182
#define REG_COMP(preg, regex, cflags)
Compile a regular expression.
Definition regex3.h:49
size_t dsize
Length of data.
Definition buffer.h:39
+ Here is the call graph for this function:

◆ parse_folder_hook()

enum CommandResult parse_folder_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse folder hook command - Implements Command::parse() -.

Parse:

  • folder-hook [ -noregex ] <regex> <command>

Definition at line 528 of file parse.c.

530{
531 struct Buffer *err = pe->message;
532
533 struct Hook *hook = NULL;
535 bool pat_not = false;
536 bool use_regex = true;
537 regex_t *rx = NULL;
538
539 struct Buffer *regex = buf_pool_get();
540 struct Buffer *command = buf_pool_get();
541
542 if (*line->dptr == '!')
543 {
544 line->dptr++;
545 SKIPWS(line->dptr);
546 pat_not = true;
547 }
548
550 if (mutt_str_equal(buf_string(regex), "-noregex"))
551 {
552 use_regex = false;
553 if (!MoreArgs(line))
554 {
555 buf_printf(err, _("%s: too few arguments"), cmd->name);
556 rc = MUTT_CMD_WARNING;
557 goto cleanup;
558 }
560 }
561
562 if (!MoreArgs(line))
563 {
564 buf_printf(err, _("%s: too few arguments"), cmd->name);
565 rc = MUTT_CMD_WARNING;
566 goto cleanup;
567 }
568
569 parse_extract_token(command, line, TOKEN_SPACE);
570
571 if (buf_is_empty(command))
572 {
573 buf_printf(err, _("%s: too few arguments"), cmd->name);
574 rc = MUTT_CMD_WARNING;
575 goto cleanup;
576 }
577
578 if (MoreArgs(line))
579 {
580 buf_printf(err, _("%s: too many arguments"), cmd->name);
581 rc = MUTT_CMD_WARNING;
582 goto cleanup;
583 }
584
585 /* Accidentally using the ^ mailbox shortcut in the .neomuttrc is a
586 * common mistake */
587 if ((buf_at(regex, 0) == '^') && !CurrentFolder)
588 {
589 buf_strcpy(err, _("current mailbox shortcut '^' is unset"));
590 goto cleanup;
591 }
592
593 struct Buffer *tmp = buf_pool_get();
594 buf_copy(tmp, regex);
595 expand_path(tmp, use_regex);
596
597 /* Check for other mailbox shortcuts that expand to the empty string.
598 * This is likely a mistake too */
599 if (buf_is_empty(tmp) && !buf_is_empty(regex))
600 {
601 buf_strcpy(err, _("mailbox shortcut expanded to empty regex"));
602 buf_pool_release(&tmp);
603 goto cleanup;
604 }
605
606 if (use_regex)
607 {
608 buf_copy(regex, tmp);
609 }
610 else
611 {
613 }
614 buf_pool_release(&tmp);
615
616 /* check to make sure that a matching hook doesn't already exist */
617 TAILQ_FOREACH(hook, &Hooks, entries)
618 {
619 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
620 mutt_str_equal(buf_string(regex), hook->regex.pattern))
621 {
622 // Ignore duplicate hooks
623 if (mutt_str_equal(hook->command, buf_string(command)))
624 {
625 rc = MUTT_CMD_SUCCESS;
626 goto cleanup;
627 }
628 }
629 }
630
631 /* Hooks not allowing full patterns: Check syntax of regex */
632 rx = MUTT_MEM_CALLOC(1, regex_t);
633 int rc2 = REG_COMP(rx, buf_string(regex), 0);
634 if (rc2 != 0)
635 {
636 regerror(rc2, rx, err->data, err->dsize);
637 buf_fix_dptr(err);
638 FREE(&rx);
639 goto cleanup;
640 }
641
642 hook = hook_new();
643 hook->id = cmd->id;
644 hook->command = buf_strdup(command);
646 hook->pattern = NULL;
647 hook->regex.pattern = buf_strdup(regex);
648 hook->regex.regex = rx;
649 hook->regex.pat_not = pat_not;
650 hook->expando = NULL;
651
652 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
653 rc = MUTT_CMD_SUCCESS;
654
655cleanup:
656 buf_pool_release(&regex);
657 buf_pool_release(&command);
658 return rc;
659}
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
Definition buffer.c:668
int mutt_file_sanitize_regex(struct Buffer *dest, const char *src)
Escape any regex-magic characters in a string.
Definition file.c:624
char * CurrentFolder
Currently selected mailbox.
Definition globals.c:38
+ Here is the call graph for this function:

◆ parse_crypt_hook()

enum CommandResult parse_crypt_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse crypt hook commands - Implements Command::parse() -.

Parse:

  • crypt-hook <regex> <keyid>
  • pgp-hook is a deprecated synonym for crypt-hook

Definition at line 668 of file parse.c.

670{
671 struct Buffer *err = pe->message;
672
673 struct Hook *hook = NULL;
675 bool pat_not = false;
676 regex_t *rx = NULL;
677
678 struct Buffer *regex = buf_pool_get();
679 struct Buffer *keyid = buf_pool_get();
680
681 if (*line->dptr == '!')
682 {
683 line->dptr++;
684 SKIPWS(line->dptr);
685 pat_not = true;
686 }
687
689
690 if (!MoreArgs(line))
691 {
692 buf_printf(err, _("%s: too few arguments"), cmd->name);
693 rc = MUTT_CMD_WARNING;
694 goto cleanup;
695 }
696
698
699 if (buf_is_empty(keyid))
700 {
701 buf_printf(err, _("%s: too few arguments"), cmd->name);
702 rc = MUTT_CMD_WARNING;
703 goto cleanup;
704 }
705
706 if (MoreArgs(line))
707 {
708 buf_printf(err, _("%s: too many arguments"), cmd->name);
709 rc = MUTT_CMD_WARNING;
710 goto cleanup;
711 }
712
713 /* check to make sure that a matching hook doesn't already exist */
714 TAILQ_FOREACH(hook, &Hooks, entries)
715 {
716 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
717 mutt_str_equal(buf_string(regex), hook->regex.pattern))
718 {
719 // Ignore duplicate hooks
720 if (mutt_str_equal(hook->command, buf_string(keyid)))
721 {
722 rc = MUTT_CMD_SUCCESS;
723 goto cleanup;
724 }
725 }
726 }
727
728 /* Hooks not allowing full patterns: Check syntax of regex */
729 rx = MUTT_MEM_CALLOC(1, regex_t);
730 int rc2 = REG_COMP(rx, buf_string(regex), REG_ICASE);
731 if (rc2 != 0)
732 {
733 regerror(rc2, rx, err->data, err->dsize);
734 buf_fix_dptr(err);
735 FREE(&rx);
736 goto cleanup;
737 }
738
739 hook = hook_new();
740 hook->id = cmd->id;
741 hook->command = buf_strdup(keyid);
743 hook->pattern = NULL;
744 hook->regex.pattern = buf_strdup(regex);
745 hook->regex.regex = rx;
746 hook->regex.pat_not = pat_not;
747 hook->expando = NULL;
748
749 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
750 rc = MUTT_CMD_SUCCESS;
751
752cleanup:
753 buf_pool_release(&regex);
754 buf_pool_release(&keyid);
755 return rc;
756}
+ Here is the call graph for this function:

◆ parse_mbox_hook()

enum CommandResult parse_mbox_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse mbox hook command - Implements Command::parse() -.

Parse:

  • mbox-hook [ -noregex ] <regex> <mailbox>

Definition at line 764 of file parse.c.

766{
767 struct Buffer *err = pe->message;
768
769 struct Hook *hook = NULL;
771 bool pat_not = false;
772 bool use_regex = true;
773 regex_t *rx = NULL;
774
775 struct Buffer *regex = buf_pool_get();
776 struct Buffer *command = buf_pool_get();
777
778 if (*line->dptr == '!')
779 {
780 line->dptr++;
781 SKIPWS(line->dptr);
782 pat_not = true;
783 }
784
786 if (mutt_str_equal(buf_string(regex), "-noregex"))
787 {
788 use_regex = false;
789 if (!MoreArgs(line))
790 {
791 buf_printf(err, _("%s: too few arguments"), cmd->name);
792 rc = MUTT_CMD_WARNING;
793 goto cleanup;
794 }
796 }
797
798 if (!MoreArgs(line))
799 {
800 buf_printf(err, _("%s: too few arguments"), cmd->name);
801 rc = MUTT_CMD_WARNING;
802 goto cleanup;
803 }
804
805 parse_extract_token(command, line, TOKEN_NO_FLAGS);
806
807 if (buf_is_empty(command))
808 {
809 buf_printf(err, _("%s: too few arguments"), cmd->name);
810 rc = MUTT_CMD_WARNING;
811 goto cleanup;
812 }
813
814 if (MoreArgs(line))
815 {
816 buf_printf(err, _("%s: too many arguments"), cmd->name);
817 rc = MUTT_CMD_WARNING;
818 goto cleanup;
819 }
820
821 /* Accidentally using the ^ mailbox shortcut in the .neomuttrc is a
822 * common mistake */
823 if ((buf_at(regex, 0) == '^') && !CurrentFolder)
824 {
825 buf_strcpy(err, _("current mailbox shortcut '^' is unset"));
826 goto cleanup;
827 }
828
829 struct Buffer *tmp = buf_pool_get();
830 buf_copy(tmp, regex);
831 expand_path(tmp, use_regex);
832
833 /* Check for other mailbox shortcuts that expand to the empty string.
834 * This is likely a mistake too */
835 if (buf_is_empty(tmp) && !buf_is_empty(regex))
836 {
837 buf_strcpy(err, _("mailbox shortcut expanded to empty regex"));
838 buf_pool_release(&tmp);
839 goto cleanup;
840 }
841
842 if (use_regex)
843 {
844 buf_copy(regex, tmp);
845 }
846 else
847 {
849 }
850 buf_pool_release(&tmp);
851
852 expand_path(command, false);
853
854 /* check to make sure that a matching hook doesn't already exist */
855 TAILQ_FOREACH(hook, &Hooks, entries)
856 {
857 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
858 mutt_str_equal(buf_string(regex), hook->regex.pattern))
859 {
860 // Update an existing hook
861 FREE(&hook->command);
862 hook->command = buf_strdup(command);
863 FREE(&hook->source_file);
865
866 expando_free(&hook->expando);
867 hook->expando = expando_parse(buf_string(command), IndexFormatDef, err);
868
869 rc = MUTT_CMD_SUCCESS;
870 goto cleanup;
871 }
872 }
873
874 /* Hooks not allowing full patterns: Check syntax of regex */
875 rx = MUTT_MEM_CALLOC(1, regex_t);
876 int rc2 = REG_COMP(rx, buf_string(regex), 0);
877 if (rc2 != 0)
878 {
879 regerror(rc2, rx, err->data, err->dsize);
880 buf_fix_dptr(err);
881 FREE(&rx);
882 goto cleanup;
883 }
884
885 struct Expando *exp = expando_parse(buf_string(command), IndexFormatDef, err);
886
887 hook = hook_new();
888 hook->id = cmd->id;
889 hook->command = buf_strdup(command);
891 hook->pattern = NULL;
892 hook->regex.pattern = buf_strdup(regex);
893 hook->regex.regex = rx;
894 hook->regex.pat_not = pat_not;
895 hook->expando = exp;
896
897 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
898 rc = MUTT_CMD_SUCCESS;
899
900cleanup:
901 buf_pool_release(&regex);
902 buf_pool_release(&command);
903 return rc;
904}
const struct ExpandoDefinition IndexFormatDef[]
Expando definitions.
struct Expando * expando_parse(const char *str, const struct ExpandoDefinition *defs, struct Buffer *err)
Parse an Expando string.
Definition expando.c:81
void expando_free(struct Expando **ptr)
Free an Expando object.
Definition expando.c:61
Parsed Expando trees.
Definition expando.h:41
+ Here is the call graph for this function:

◆ parse_compress_hook()

enum CommandResult parse_compress_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse compress hook commands - Implements Command::parse() -.

Parse:

  • append-hook <regex> <shell-command>
  • close-hook <regex> <shell-command>
  • open-hook <regex> <shell-command>

Definition at line 914 of file parse.c.

916{
917 struct Buffer *err = pe->message;
918
919 struct Hook *hook = NULL;
921 bool pat_not = false;
922 regex_t *rx = NULL;
923
924 struct Buffer *regex = buf_pool_get();
925 struct Buffer *command = buf_pool_get();
926
927 if (*line->dptr == '!')
928 {
929 line->dptr++;
930 SKIPWS(line->dptr);
931 pat_not = true;
932 }
933
935
936 if (!MoreArgs(line))
937 {
938 buf_printf(err, _("%s: too few arguments"), cmd->name);
939 rc = MUTT_CMD_WARNING;
940 goto cleanup;
941 }
942
943 // TOKEN_SPACE allows the command to contain whitespace, without quoting
944 parse_extract_token(command, line, TOKEN_SPACE);
945
946 if (buf_is_empty(command))
947 {
948 buf_printf(err, _("%s: too few arguments"), cmd->name);
949 rc = MUTT_CMD_WARNING;
950 goto cleanup;
951 }
952
953 if (MoreArgs(line))
954 {
955 buf_printf(err, _("%s: too many arguments"), cmd->name);
956 rc = MUTT_CMD_WARNING;
957 goto cleanup;
958 }
959
960 if (mutt_comp_valid_command(buf_string(command)) == 0)
961 {
962 buf_strcpy(err, _("badly formatted command string"));
963 goto cleanup;
964 }
965
966 /* check to make sure that a matching hook doesn't already exist */
967 TAILQ_FOREACH(hook, &Hooks, entries)
968 {
969 if ((hook->id == cmd->id) && (hook->regex.pat_not == pat_not) &&
970 mutt_str_equal(buf_string(regex), hook->regex.pattern))
971 {
972 // Update an existing hook
973 FREE(&hook->command);
974 hook->command = buf_strdup(command);
975 FREE(&hook->source_file);
977
978 rc = MUTT_CMD_SUCCESS;
979 goto cleanup;
980 }
981 }
982
983 /* Hooks not allowing full patterns: Check syntax of regex */
984 rx = MUTT_MEM_CALLOC(1, regex_t);
985 int rc2 = REG_COMP(rx, buf_string(regex), 0);
986 if (rc2 != 0)
987 {
988 regerror(rc2, rx, err->data, err->dsize);
989 buf_fix_dptr(err);
990 FREE(&rx);
991 goto cleanup;
992 }
993
994 hook = hook_new();
995 hook->id = cmd->id;
996 hook->command = buf_strdup(command);
998 hook->pattern = NULL;
999 hook->regex.pattern = buf_strdup(regex);
1000 hook->regex.regex = rx;
1001 hook->regex.pat_not = pat_not;
1002 hook->expando = NULL;
1003
1004 TAILQ_INSERT_TAIL(&Hooks, hook, entries);
1005 rc = MUTT_CMD_SUCCESS;
1006
1007cleanup:
1008 buf_pool_release(&regex);
1009 buf_pool_release(&command);
1010 return rc;
1011}
int mutt_comp_valid_command(const char *cmd)
Is this command string allowed?
Definition compress.c:387
+ Here is the call graph for this function:

◆ parse_index_hook()

enum CommandResult parse_index_hook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the index format hook command - Implements Command::parse() -.

Parse:

  • index-format-hook <name> [!]<pattern> <format-string>

Definition at line 1066 of file parse.c.

1068{
1069 struct Buffer *err = pe->message;
1070
1071 if (!MoreArgs(line))
1072 {
1073 buf_printf(err, _("%s: too few arguments"), cmd->name);
1074 return MUTT_CMD_WARNING;
1075 }
1076
1077 enum CommandResult rc = MUTT_CMD_ERROR;
1078 bool pat_not = false;
1079
1080 struct Buffer *name = buf_pool_get();
1081 struct Buffer *pattern = buf_pool_get();
1082 struct Buffer *fmt = buf_pool_get();
1083 struct Expando *exp = NULL;
1084
1085 if (!IdxFmtHooks)
1086 {
1089 }
1090
1092 struct HookList *hl = mutt_hash_find(IdxFmtHooks, buf_string(name));
1093
1094 if (*line->dptr == '!')
1095 {
1096 line->dptr++;
1097 SKIPWS(line->dptr);
1098 pat_not = true;
1099 }
1100 parse_extract_token(pattern, line, TOKEN_NO_FLAGS);
1101
1102 if (!MoreArgs(line))
1103 {
1104 buf_printf(err, _("%s: too few arguments"), cmd->name);
1105 goto out;
1106 }
1108
1109 exp = expando_parse(buf_string(fmt), IndexFormatDef, err);
1110 if (!exp)
1111 goto out;
1112
1113 if (MoreArgs(line))
1114 {
1115 buf_printf(err, _("%s: too many arguments"), cmd->name);
1116 goto out;
1117 }
1118
1119 const char *const c_default_hook = cs_subset_string(NeoMutt->sub, "default_hook");
1120 if (c_default_hook)
1121 mutt_check_simple(pattern, c_default_hook);
1122
1123 /* check to make sure that a matching hook doesn't already exist */
1124 struct Hook *hook = NULL;
1125 if (hl)
1126 {
1127 TAILQ_FOREACH(hook, hl, entries)
1128 {
1129 // Update an existing hook
1130 if ((hook->regex.pat_not == pat_not) &&
1132 {
1133 expando_free(&hook->expando);
1134 hook->expando = exp;
1135 exp = NULL;
1136 rc = MUTT_CMD_SUCCESS;
1137 goto out;
1138 }
1139 }
1140 }
1141
1142 /* MUTT_PC_PATTERN_DYNAMIC sets so that date ranges are regenerated during
1143 * matching. This of course is slower, but index-format-hook is commonly
1144 * used for date ranges, and they need to be evaluated relative to "now", not
1145 * the hook compilation time. */
1146 struct MailboxView *mv_cur = get_current_mailbox_view();
1147 struct PatternList *pat = mutt_pattern_comp(mv_cur, buf_string(pattern),
1149 err);
1150 if (!pat)
1151 goto out;
1152
1153 hook = hook_new();
1154 hook->id = CMD_INDEX_FORMAT_HOOK;
1155 hook->command = NULL;
1157 hook->pattern = pat;
1158 hook->regex.pattern = buf_strdup(pattern);
1159 hook->regex.regex = NULL;
1160 hook->regex.pat_not = pat_not;
1161 hook->expando = exp;
1162 exp = NULL;
1163
1164 if (!hl)
1165 {
1166 hl = MUTT_MEM_CALLOC(1, struct HookList);
1167 TAILQ_INIT(hl);
1169 }
1170
1171 TAILQ_INSERT_TAIL(hl, hook, entries);
1172 rc = MUTT_CMD_SUCCESS;
1173
1174out:
1175 buf_pool_release(&name);
1176 buf_pool_release(&pattern);
1177 buf_pool_release(&fmt);
1178 expando_free(&exp);
1179
1180 return rc;
1181}
@ CMD_INDEX_FORMAT_HOOK
:index-format-hook
Definition command.h:86
static void idxfmt_hashelem_free(int type, void *obj, intptr_t data)
Free our hash table data - Implements hash_hdata_free_t -.
Definition parse.c:1037
struct HashTable * mutt_hash_new(size_t num_elems, HashFlags flags)
Create a new Hash Table (with string keys)
Definition hash.c:261
void mutt_hash_set_destructor(struct HashTable *table, hash_hdata_free_t fn, intptr_t fn_data)
Set the destructor for a Hash Table.
Definition hash.c:303
#define MUTT_HASH_STRDUP_KEYS
make a copy of the keys
Definition hash.h:113
struct HashTable * IdxFmtHooks
All Index Format hooks.
Definition parse.c:52
#define MUTT_PC_PATTERN_DYNAMIC
Enable runtime date range evaluation.
Definition lib.h:71
#define TAILQ_INIT(head)
Definition queue.h:822
+ Here is the call graph for this function:

◆ parse_unhook()

enum CommandResult parse_unhook ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the unhook command - Implements Command::parse() -.

Parse:

  • unhook { * | <hook-type> }

Definition at line 1189 of file parse.c.

1191{
1192 struct Buffer *err = pe->message;
1193
1194 if (!MoreArgs(line))
1195 {
1196 buf_printf(err, _("%s: too few arguments"), cmd->name);
1197 return MUTT_CMD_WARNING;
1198 }
1199
1200 struct Buffer *token = buf_pool_get();
1202
1203 while (MoreArgs(line))
1204 {
1205 parse_extract_token(token, line, TOKEN_NO_FLAGS);
1206 if (mutt_str_equal("*", buf_string(token)))
1207 {
1208 if (CurrentHookId != CMD_NONE)
1209 {
1210 buf_addstr(err, _("unhook: Can't do unhook * from within a hook"));
1211 goto done;
1212 }
1216 }
1217 else
1218 {
1219 const struct Command *hook = command_find_by_name(&NeoMutt->commands,
1220 buf_string(token));
1221 if (!hook)
1222 {
1223 buf_printf(err, _("unhook: unknown hook type: %s"), buf_string(token));
1224 rc = MUTT_CMD_ERROR;
1225 goto done;
1226 }
1227
1228 if ((hook->id == CMD_CHARSET_HOOK) || (hook->id == CMD_ICONV_HOOK))
1229 {
1231 rc = MUTT_CMD_SUCCESS;
1232 goto done;
1233 }
1234 if (CurrentHookId == hook->id)
1235 {
1236 buf_printf(err, _("unhook: Can't delete a %s from within a %s"),
1237 buf_string(token), buf_string(token));
1238 rc = MUTT_CMD_WARNING;
1239 goto done;
1240 }
1241 if (hook->id == CMD_INDEX_FORMAT_HOOK)
1243 else
1244 mutt_delete_hooks(hook->id);
1245 }
1246 }
1247
1248 rc = MUTT_CMD_SUCCESS;
1249
1250done:
1251 buf_pool_release(&token);
1252 return rc;
1253}
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition buffer.c:226
@ CMD_CHARSET_HOOK
:charset-hook
Definition command.h:69
@ CMD_NONE
No Command.
Definition command.h:59
const struct Command * command_find_by_name(const struct CommandArray *ca, const char *name)
Find a NeoMutt Command by its name.
Definition commands.c:171
enum CommandId CurrentHookId
The ID of the Hook currently being executed, e.g. CMD_SAVE_HOOK.
Definition parse.c:55
void mutt_delete_hooks(enum CommandId id)
Delete matching hooks.
Definition parse.c:1019
static void delete_idxfmt_hooks(void)
Delete all the index-format-hooks.
Definition parse.c:1055
void mutt_ch_lookup_remove(void)
Remove all the character set lookups.
Definition charset.c:527
+ Here is the call graph for this function:

◆ parse_subscribe_to()

enum CommandResult parse_subscribe_to ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'subscribe-to' command - Implements Command::parse() -.

The 'subscribe-to' command allows to subscribe to an IMAP-Mailbox. Patterns are not supported.

Parse:

  • subscribe-to <imap-folder-uri>

Definition at line 93 of file imap.c.

95{
96 struct Buffer *err = pe->message;
97
98 if (!MoreArgs(line))
99 {
100 buf_printf(err, _("%s: too few arguments"), cmd->name);
101 return MUTT_CMD_WARNING;
102 }
103
104 struct Buffer *token = buf_pool_get();
106
107 buf_reset(err);
108
110
111 if (MoreArgs(line))
112 {
113 buf_printf(err, _("%s: too many arguments"), cmd->name);
114 goto done;
115 }
116
117 // Expand and subscribe
118 expand_path(token, false);
119 if (imap_subscribe(buf_string(token), true) != 0)
120 {
121 buf_printf(err, _("Could not subscribe to %s"), buf_string(token));
122 rc = MUTT_CMD_ERROR;
123 goto done;
124 }
125
126 mutt_message(_("Subscribed to %s"), buf_string(token));
127 rc = MUTT_CMD_SUCCESS;
128
129done:
130 buf_pool_release(&token);
131 return rc;
132}
int imap_subscribe(const char *path, bool subscribe)
Subscribe to a mailbox.
Definition imap.c:1405
+ Here is the call graph for this function:

◆ parse_unsubscribe_from()

enum CommandResult parse_unsubscribe_from ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unsubscribe-from' command - Implements Command::parse() -.

The 'unsubscribe-from' command allows to unsubscribe from an IMAP-Mailbox. Patterns are not supported.

Parse:

  • unsubscribe-from <imap-folder-uri>

Definition at line 143 of file imap.c.

146{
147 struct Buffer *err = pe->message;
148
149 if (!MoreArgs(line))
150 {
151 buf_printf(err, _("%s: too few arguments"), cmd->name);
152 return MUTT_CMD_WARNING;
153 }
154
155 struct Buffer *token = buf_pool_get();
157
159
160 if (MoreArgs(line))
161 {
162 buf_printf(err, _("%s: too many arguments"), cmd->name);
163 goto done;
164 }
165
166 // Expand and unsubscribe
167 expand_path(token, false);
168 if (imap_subscribe(buf_string(token), false) != 0)
169 {
170 buf_printf(err, _("Could not unsubscribe from %s"), buf_string(token));
171 rc = MUTT_CMD_ERROR;
172 goto done;
173 }
174
175 mutt_message(_("Unsubscribed from %s"), buf_string(token));
176 rc = MUTT_CMD_SUCCESS;
177
178done:
179 buf_pool_release(&token);
180 return rc;
181}
+ Here is the call graph for this function:

◆ parse_subjectrx_list()

enum CommandResult parse_subjectrx_list ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'subject-regex' command - Implements Command::parse() -.

Parse:

  • subject-regex <regex> <replacement>

Definition at line 192 of file subjectrx.c.

195{
196 struct Buffer *err = pe->message;
197
198 if (!MoreArgs(line))
199 {
200 buf_printf(err, _("%s: too few arguments"), cmd->name);
201 return MUTT_CMD_WARNING;
202 }
203
205 ASSERT(md);
206
207 enum CommandResult rc;
208
209 rc = parse_replace_list(cmd, line, &md->subject_rx_list, err);
210 if (rc == MUTT_CMD_SUCCESS)
211 {
212 mutt_debug(LL_NOTIFY, "NT_SUBJECTRX_ADD: %s\n", cmd->name);
214 }
215 return rc;
216}
@ MODULE_ID_INDEX
ModuleIndex, Index
Definition module_api.h:72
@ NT_SUBJECTRX
Subject Regex has changed, NotifySubjectRx.
Definition notify_type.h:55
Index private Module data.
Definition module_data.h:32
struct Notify * subject_rx_notify
List of subject-regex rules for modifying the Subject:
Definition module_data.h:34
struct ReplaceList subject_rx_list
Definition module_data.h:33
static enum CommandResult parse_replace_list(const struct Command *cmd, struct Buffer *line, struct ReplaceList *list, struct Buffer *err)
Parse a string replacement rule.
Definition subjectrx.c:104
@ NT_SUBJECTRX_ADD
Subject Regex has been added.
Definition subjectrx.h:45
+ Here is the call graph for this function:

◆ parse_unsubjectrx_list()

enum CommandResult parse_unsubjectrx_list ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unsubject-regex' command - Implements Command::parse() -.

Parse:

  • unsubject-regex { * | <regex> }

Definition at line 224 of file subjectrx.c.

227{
228 struct Buffer *err = pe->message;
229
230 if (!MoreArgs(line))
231 {
232 buf_printf(err, _("%s: too few arguments"), cmd->name);
233 return MUTT_CMD_WARNING;
234 }
235
237 ASSERT(md);
238
239 enum CommandResult rc;
240
241 rc = parse_unreplace_list(cmd, line, &md->subject_rx_list, err);
242 if (rc == MUTT_CMD_SUCCESS)
243 {
244 mutt_debug(LL_NOTIFY, "NT_SUBJECTRX_DELETE: %s\n", cmd->name);
246 }
247 return rc;
248}
static enum CommandResult parse_unreplace_list(const struct Command *cmd, struct Buffer *line, struct ReplaceList *list, struct Buffer *err)
Remove a string replacement rule.
Definition subjectrx.c:68
@ NT_SUBJECTRX_DELETE
Subject Regex has been deleted.
Definition subjectrx.h:46
+ Here is the call graph for this function:

◆ parse_dump()

enum CommandResult parse_dump ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse 'bind' and 'macro' commands - Implements Command::parse() -.

Definition at line 63 of file commands.c.

65{
66 struct Buffer *err = pe->message;
67
68 struct Buffer *token = buf_pool_get();
69 const struct MenuDefinition *md = NULL;
71
72 if (MoreArgs(line))
73 {
75
76 if (MoreArgs(line))
77 {
78 /* More arguments potentially means the user is using the
79 * ::command_t :bind command thus we delegate the task. */
80 goto done;
81 }
82
83 if (!mutt_str_equal(buf_string(token), "all"))
84 {
85 md = menu_find_by_name(buf_string(token));
86 if (!md)
87 {
88 // L10N: '%s' is the (misspelled) name of the menu, e.g. 'index' or 'pager'
89 buf_printf(err, _("%s: no such menu"), buf_string(token));
90 goto done;
91 }
92 }
93 }
94
95 dump_bind_macro(cmd, md, token, err);
97
98done:
99 buf_pool_release(&token);
100 return rc;
101}
void dump_bind_macro(const struct Command *cmd, const struct MenuDefinition *md, struct Buffer *buf, struct Buffer *err)
Dump a Menu's binds or macros to the Pager.
Definition dump.c:387
struct MenuDefinition * menu_find_by_name(const char *name)
Find a Menu Definition by its name.
Definition menu.c:264
Functions for a Dialog or Window.
Definition menu.h:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_push()

enum CommandResult parse_push ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'push' command - Implements Command::parse() -.

Parse:

  • push <string>

Definition at line 204 of file commands.c.

206{
207 struct Buffer *err = pe->message;
208
209 if (!MoreArgs(line))
210 {
211 buf_printf(err, _("%s: too few arguments"), cmd->name);
212 return MUTT_CMD_WARNING;
213 }
214
215 struct Buffer *token = buf_pool_get();
217
219 if (MoreArgs(line))
220 {
221 buf_printf(err, _("%s: too many arguments"), cmd->name);
222 goto done;
223 }
224
226 rc = MUTT_CMD_SUCCESS;
227
228done:
229 buf_pool_release(&token);
230 return rc;
231}
#define TOKEN_CONDENSE
^(char) to control chars (macros)
Definition extract.h:47
void generic_tokenize_push_string(char *s)
Parse and queue a 'push' command.
Definition get.c:309
+ Here is the call graph for this function:

◆ parse_bind()

enum CommandResult parse_bind ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'bind' command - Implements Command::parse() -.

bind menu-name <key_sequence> function-name

Parse:

  • bind <map>[,<map> ... ] <key> <function>

Definition at line 241 of file commands.c.

243{
244 struct Buffer *err = pe->message;
245
246 if (StartupComplete)
247 {
248 // Save and restore the offset in `line` because parse_dump() might change it
249 char *dptr = line->dptr;
250 if (parse_dump(cmd, line, pc, pe) == MUTT_CMD_SUCCESS)
251 {
252 return MUTT_CMD_SUCCESS;
253 }
254 if (!buf_is_empty(err))
255 {
256 return MUTT_CMD_ERROR;
257 }
258 line->dptr = dptr;
259 }
260
261 struct Buffer *token = buf_pool_get();
262 struct Buffer *keystr = NULL;
263
264 struct MenuDefinitionArray mda = ARRAY_HEAD_INITIALIZER;
266
267 char *key = parse_keymap(cmd, &mda, line, err);
268 if (!key)
269 goto done;
270
271 /* function to execute */
273 if (MoreArgs(line))
274 {
275 buf_printf(err, _("%s: too many arguments"), cmd->name);
276 goto done;
277 }
278
279 rc = MUTT_CMD_SUCCESS;
280
281 if (mutt_istr_equal("noop", buf_string(token)))
282 {
283 keystr = buf_pool_get();
284 struct MenuDefinition **mdp = NULL;
285 ARRAY_FOREACH(mdp, &mda)
286 {
287 struct MenuDefinition *md = *mdp;
288
289 km_bind(md, key, OP_NULL, NULL, NULL, NULL); /* the 'unbind' command */
290
291 buf_reset(keystr);
292 keymap_expand_string(key, keystr);
293 mutt_debug(LL_NOTIFY, "NT_BINDING_DELETE: %s %s\n", md->name, buf_string(keystr));
294
295 int op = km_get_op_menu(md->id, buf_string(token));
296
297 struct EventBinding ev_b = { md, key, op };
299 }
300 }
301 else
302 {
303 keystr = buf_pool_get();
304 struct MenuDefinition **mdp = NULL;
305 ARRAY_FOREACH(mdp, &mda)
306 {
307 struct MenuDefinition *md = *mdp;
308
309 int op = OP_NULL;
310 struct SubMenu **ptr = NULL;
311 ARRAY_FOREACH(ptr, &md->submenus)
312 {
313 struct SubMenu *sm = *ptr;
314 const struct MenuFuncOp *mfo = NULL;
315 for (int j = 0; sm->functions[j].name; j++)
316 {
317 mfo = &sm->functions[j];
318 if (mutt_str_equal(buf_string(token), mfo->name))
319 {
320 op = mfo->op;
321 break;
322 }
323 }
324 }
325
326 rc = km_bind(md, key, op, NULL, NULL, err);
327 if (rc == MUTT_CMD_SUCCESS)
328 {
329 buf_reset(keystr);
330 keymap_expand_string(key, keystr);
331 mutt_debug(LL_NOTIFY, "NT_BINDING_NEW: %s %s\n", md->name, buf_string(keystr));
332
333 struct EventBinding ev_b = { md, key, op };
335 }
336 }
337 }
338
339done:
340 FREE(&key);
341 ARRAY_FREE(&mda);
342 buf_pool_release(&keystr);
343 buf_pool_release(&token);
344 return rc;
345}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
enum CommandResult parse_dump(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse 'bind' and 'macro' commands - Implements Command::parse() -.
Definition commands.c:63
char * parse_keymap(const struct Command *cmd, struct MenuDefinitionArray *mda, struct Buffer *line, struct Buffer *err)
Parse a user-config key binding.
Definition commands.c:115
enum CommandResult km_bind(struct MenuDefinition *md, const char *key_str, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
Definition menu.c:51
void keymap_expand_string(const char *str, struct Buffer *buf)
Get a human-readable key string.
Definition keymap.c:247
int km_get_op_menu(int mtype, const char *func)
Get the OpCode for a Function from a Menu.
Definition menu.c:213
@ NT_BINDING_DELETE
Key binding has been deleted.
Definition notify.h:48
@ NT_BINDING_ADD
Key binding has been added.
Definition notify.h:47
@ NT_BINDING
Key binding has changed, NotifyBinding, EventBinding.
Definition notify_type.h:40
A key binding Event.
Definition notify.h:32
const char * key
Key string being bound (for new bind/macro)
Definition notify.h:34
int op
Operation the key's bound to (for bind), e.g. OP_DELETE.
Definition notify.h:35
const char * name
Menu name, e.g. "alias".
Definition menu.h:82
int id
Menu ID, e.g. MENU_ALIAS.
Definition menu.h:81
struct SubMenuPArray submenus
Parts making up the Menu.
Definition menu.h:83
Mapping between a function and an operation.
Definition menu.h:38
const char * name
Name of the function.
Definition menu.h:39
int op
Operation, e.g. OP_DELETE.
Definition menu.h:40
Collection of related functions.
Definition menu.h:68
const struct MenuFuncOp * functions
All available functions.
Definition menu.h:70
+ Here is the call graph for this function:

◆ parse_unbind()

enum CommandResult parse_unbind ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unbind' and 'unmacro' commands - Implements Command::parse() -.

Parse:

  • unbind { * | <map>[,<map> ... ] } [ <key> ]
  • unmacro { * | <map>[,<map> ... ] } [ <key> ]

Definition at line 644 of file commands.c.

646{
647 struct Buffer *err = pe->message;
648
649 struct ParseUnbind args = { 0 };
651
652 if (!parse_unbind_args(cmd, line, err, &args))
653 goto done;
654
655 rc = MUTT_CMD_ERROR;
656 if (parse_unbind_exec(cmd, &args, err))
657 rc = MUTT_CMD_SUCCESS;
658
659done:
660 ARRAY_FREE(&args.mda);
661 FREE(&args.key);
662 return rc;
663}
bool parse_unbind_exec(const struct Command *cmd, struct ParseUnbind *args, struct Buffer *err)
Execute the 'unbind' or 'unmacro' command.
Definition commands.c:537
bool parse_unbind_args(const struct Command *cmd, struct Buffer *line, struct Buffer *err, struct ParseUnbind *args)
Parse the 'unbind' and 'unmacro' commands.
Definition commands.c:449
Parsed 'unbind' or 'unmacro' command.
Definition commands.c:53
struct MenuDefinitionArray mda
Menus to work on.
Definition commands.c:54
const char * key
Key string to be removed.
Definition commands.c:57
+ Here is the call graph for this function:

◆ parse_macro()

enum CommandResult parse_macro ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'macro' command - Implements Command::parse() -.

Parse:

  • macro <map>[,<map> ... ] <key> <sequence> [ <description> ]

Definition at line 671 of file commands.c.

673{
674 struct Buffer *err = pe->message;
675
676 if (StartupComplete)
677 {
678 // Save and restore the offset in `line` because parse_dump() might change it
679 char *dptr = line->dptr;
680 if (parse_dump(cmd, line, pc, pe) == MUTT_CMD_SUCCESS)
681 {
682 return MUTT_CMD_SUCCESS;
683 }
684 if (!buf_is_empty(err))
685 {
686 return MUTT_CMD_ERROR;
687 }
688 line->dptr = dptr;
689 }
690
691 struct MenuDefinitionArray mda = ARRAY_HEAD_INITIALIZER;
692 struct Buffer *token = buf_pool_get();
693 struct Buffer *keystr = NULL;
695
696 char *key = parse_keymap(cmd, &mda, line, err);
697 if (!key)
698 goto done;
699
701 /* make sure the macro sequence is not an empty string */
702 if (buf_at(token, 0) == '\0')
703 {
704 buf_strcpy(err, _("macro: empty key sequence"));
705 }
706 else
707 {
708 if (MoreArgs(line))
709 {
710 char *seq = mutt_str_dup(buf_string(token));
712
713 if (MoreArgs(line))
714 {
715 buf_printf(err, _("%s: too many arguments"), cmd->name);
716 }
717 else
718 {
719 keystr = buf_pool_get();
720 struct MenuDefinition **mdp = NULL;
721 ARRAY_FOREACH(mdp, &mda)
722 {
723 struct MenuDefinition *md = *mdp;
724
725 rc = km_bind(md, key, OP_MACRO, seq, token->data, NULL);
726 if (rc == MUTT_CMD_SUCCESS)
727 {
728 buf_reset(keystr);
729 keymap_expand_string(key, keystr);
730 mutt_debug(LL_NOTIFY, "NT_MACRO_NEW: %s %s\n", md->name, buf_string(keystr));
731
732 struct EventBinding ev_b = { md, key, OP_MACRO };
734 continue;
735 }
736 }
737 }
738
739 FREE(&seq);
740 }
741 else
742 {
743 keystr = buf_pool_get();
744 struct MenuDefinition **mdp = NULL;
745 ARRAY_FOREACH(mdp, &mda)
746 {
747 struct MenuDefinition *md = *mdp;
748
749 rc = km_bind(md, key, OP_MACRO, token->data, NULL, NULL);
750 if (rc == MUTT_CMD_SUCCESS)
751 {
752 buf_reset(keystr);
753 keymap_expand_string(key, keystr);
754 mutt_debug(LL_NOTIFY, "NT_MACRO_NEW: %s %s\n", md->name, buf_string(keystr));
755
756 struct EventBinding ev_b = { md, key, OP_MACRO };
758 continue;
759 }
760 }
761 }
762 }
763
764done:
765 FREE(&key);
766 ARRAY_FREE(&mda);
767 buf_pool_release(&keystr);
768 buf_pool_release(&token);
769 return rc;
770}
@ NT_MACRO_ADD
Key macro has been added.
Definition notify.h:49
+ Here is the call graph for this function:

◆ parse_exec()

enum CommandResult parse_exec ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'exec' command - Implements Command::parse() -.

Parse:

  • exec <function> [ <function> ... ]

Definition at line 778 of file commands.c.

780{
781 struct Buffer *err = pe->message;
782
783 if (!MoreArgs(line))
784 {
785 buf_printf(err, _("%s: too few arguments"), cmd->name);
786 return MUTT_CMD_WARNING;
787 }
788
789 struct Buffer *token = buf_pool_get();
791
792 int ops[128];
793 int nops = 0;
794 char *function = NULL;
795
796 do
797 {
799 function = token->data;
800
801 const enum MenuType mtype = menu_get_current_type();
802 ops[nops] = km_get_op_menu(mtype, function);
803 if (ops[nops] == OP_NULL)
804 {
806 mutt_error(_("%s: no such function"), function);
807 goto done;
808 }
809 nops++;
810 } while (MoreArgs(line) && nops < countof(ops));
811
812 while (nops)
813 mutt_push_macro_event(0, ops[--nops]);
814
815 rc = MUTT_CMD_SUCCESS;
816
817done:
818 buf_pool_release(&token);
819 return rc;
820}
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition get.c:65
void mutt_push_macro_event(int ch, int op)
Add the character/operation to the macro buffer.
Definition get.c:146
#define countof(x)
Definition memory.h:49
enum MenuType menu_get_current_type(void)
Get the type of the current Window.
Definition menu.c:91
MenuType
Types of GUI selections.
Definition type.h:33
+ Here is the call graph for this function:

◆ parse_lua()

enum CommandResult parse_lua ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'lua' command - Implements Command::parse() -.

Parse:

  • lua <lua-command>

Definition at line 57 of file commands.c.

59{
60 struct Buffer *err = pe->message;
61
62 if (!MoreArgs(line))
63 {
64 buf_printf(err, _("%s: too few arguments"), cmd->name);
65 return MUTT_CMD_WARNING;
66 }
67
68 // From here on, use the remainder of `line`, raw
70
72 mutt_debug(LL_DEBUG2, "%s\n", line->dptr);
73
74 if (luaL_dostring(LuaState, line->dptr) != LUA_OK)
75 {
76 mutt_debug(LL_DEBUG2, "%s -> failure\n", line->dptr);
77 buf_printf(err, "%s: %s", line->dptr, lua_tostring(LuaState, -1));
78 /* pop error message from the stack */
79 lua_pop(LuaState, 1);
80 goto done;
81 }
82 mutt_debug(LL_DEBUG2, "%s -> success\n", line->dptr);
83 buf_reset(line); // Clear the rest of the line
84
86
87done:
88 return rc;
89}
@ LL_DEBUG2
Log at debug level 2.
Definition logging2.h:46
bool lua_init_state(lua_State **l)
Initialise a Lua State.
Definition lua.c:446
lua_State * LuaState
Global Lua State.
Definition lua.c:56
+ Here is the call graph for this function:

◆ parse_lua_source()

enum CommandResult parse_lua_source ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'lua-source' command - Implements Command::parse() -.

Parse:

  • lua-source <filename>

Definition at line 97 of file commands.c.

99{
100 struct Buffer *err = pe->message;
101
102 if (!MoreArgs(line))
103 {
104 buf_printf(err, _("%s: too few arguments"), cmd->name);
105 return MUTT_CMD_WARNING;
106 }
107
108 struct Buffer *token = buf_pool_get();
110
111 mutt_debug(LL_DEBUG2, "enter\n");
112
114
115 if (parse_extract_token(token, line, TOKEN_NO_FLAGS) != 0)
116 {
117 buf_printf(err, _("source: error at %s"), line->dptr);
118 goto done;
119 }
120 if (MoreArgs(line))
121 {
122 buf_printf(err, _("%s: too many arguments"), cmd->name);
123 rc = MUTT_CMD_WARNING;
124 goto done;
125 }
126
127 expand_path(token, false);
128
129 if (luaL_dofile(LuaState, buf_string(token)) != LUA_OK)
130 {
131 mutt_error(_("Couldn't source lua source: %s"), lua_tostring(LuaState, -1));
132 lua_pop(LuaState, 1);
133 goto done;
134 }
135
136 rc = MUTT_CMD_SUCCESS;
137
138done:
139 buf_pool_release(&token);
140 return rc;
141}
+ Here is the call graph for this function:

◆ parse_set()

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() -.

Parse:

  • reset <variable> [ <variable> ... ]
  • set [ no | inv | & ] <variable> [?] | <variable> [=|+=|-=] <value> [...]
  • toggle <variable> [ <variable> ... ]
  • unset <variable> [ <variable> ... ]

Definition at line 488 of file set.c.

490{
491 struct Buffer *err = pe->message;
492
493 struct Buffer *token = buf_pool_get();
495
496 do
497 {
498 bool prefix = false;
499 bool query = false;
500 bool inv = (cmd->id == CMD_TOGGLE);
501 bool reset = (cmd->id == CMD_RESET);
502 bool unset = (cmd->id == CMD_UNSET);
503
504 if (*line->dptr == '?')
505 {
506 prefix = true;
507 query = true;
508 line->dptr++;
509 }
510 else if (mutt_str_startswith(line->dptr, "no"))
511 {
512 prefix = true;
513 unset = !unset;
514 line->dptr += 2;
515 }
516 else if (mutt_str_startswith(line->dptr, "inv"))
517 {
518 prefix = true;
519 inv = !inv;
520 line->dptr += 3;
521 }
522 else if (*line->dptr == '&')
523 {
524 prefix = true;
525 reset = true;
526 line->dptr++;
527 }
528
529 if (prefix && (cmd->id != CMD_SET))
530 {
531 buf_printf(err, _("Can't use 'inv', 'no', '&' or '?' with the '%s' command"),
532 cmd->name);
533 goto done;
534 }
535
536 // get the variable name. Note that token might be empty if no additional
537 // argument was given.
538 int ret = parse_extract_token(token, line,
540 if (ret == -1)
541 {
542 buf_pool_release(&token);
543 return MUTT_CMD_ERROR;
544 }
545
546 bool bool_or_quad = false;
547 bool invertible = false;
548 bool equals = false;
549 bool increment = false;
550 bool decrement = false;
551
552 struct HashElem *he = cs_subset_lookup(NeoMutt->sub, buf_string(token));
553 if (he)
554 {
555 // Use the correct name if a synonym is used
556 buf_strcpy(token, he->key.strkey);
557 bool_or_quad = ((CONFIG_TYPE(he->type) == DT_BOOL) ||
558 (CONFIG_TYPE(he->type) == DT_QUAD));
559 invertible = (bool_or_quad || (CONFIG_TYPE(he->type) == DT_NUMBER));
560 }
561
562 if (*line->dptr == '?')
563 {
564 if (prefix)
565 {
566 buf_printf(err, _("Can't use a prefix when querying a variable"));
567 goto done;
568 }
569
570 if (reset || unset || inv)
571 {
572 buf_printf(err, _("Can't query option with the '%s' command"), cmd->name);
573 goto done;
574 }
575
576 query = true;
577 line->dptr++;
578 }
579 else if ((*line->dptr == '+') || (*line->dptr == '-'))
580 {
581 if (prefix)
582 {
583 buf_printf(err, _("Can't use prefix when incrementing or decrementing a variable"));
584 goto done;
585 }
586
587 if (reset || unset || inv)
588 {
589 buf_printf(err, _("Can't set option with the '%s' command"), cmd->name);
590 goto done;
591 }
592 if (*line->dptr == '+')
593 increment = true;
594 else
595 decrement = true;
596
597 line->dptr++;
598 if (*line->dptr == '=')
599 {
600 equals = true;
601 line->dptr++;
602 }
603 else
604 {
605 buf_printf(err, _("'+' and '-' must be followed by '='"));
606 goto done;
607 }
608 }
609 else if (*line->dptr == '=')
610 {
611 if (prefix)
612 {
613 buf_printf(err, _("Can't use prefix when setting a variable"));
614 goto done;
615 }
616
617 if (reset || unset || inv)
618 {
619 buf_printf(err, _("Can't set option with the '%s' command"), cmd->name);
620 goto done;
621 }
622
623 equals = true;
624 line->dptr++;
625 }
626
627 if (!invertible && (inv || (unset && prefix)))
628 {
629 if (cmd->id == CMD_SET)
630 {
631 buf_printf(err, _("Prefixes 'no' and 'inv' may only be used with bool/quad/number variables"));
632 }
633 else
634 {
635 buf_printf(err, _("Command '%s' can only be used with bool/quad/number variables"),
636 cmd->name);
637 }
638 goto done;
639 }
640
641 // sanity checks for the above
642 // Each of inv, unset reset, query, equals implies that the others are not set.
643 // If none of them are set, then we are dealing with a "set foo" command.
644 // clang-format off
645 ASSERT(!inv || !( unset || reset || query || equals ));
646 ASSERT(!unset || !(inv || reset || query || equals ));
647 ASSERT(!reset || !(inv || unset || query || equals ));
648 ASSERT(!query || !(inv || unset || reset || equals ));
649 ASSERT(!equals || !(inv || unset || reset || query || prefix));
650 // clang-format on
651 ASSERT(!(increment && decrement)); // only one of increment or decrement is set
652 ASSERT(!(increment || decrement) || equals); // increment/decrement implies equals
653 ASSERT(!inv || invertible); // inv (aka toggle) implies bool or quad
654
655 rc = MUTT_CMD_ERROR;
656 if (query)
657 {
658 rc = command_set_query(token, err);
659 goto done; // We can only do one query even if multiple config names are given
660 }
661 else if (reset)
662 {
663 rc = command_set_reset(token, err);
664 }
665 else if (unset)
666 {
667 rc = command_set_unset(token, err);
668 }
669 else if (inv)
670 {
671 rc = command_set_toggle(token, err);
672 }
673 else if (equals)
674 {
675 // These three cases all need a value, since 'increment'/'decrement'
676 // implies 'equals', we can group them in this single case guarded by
677 // 'equals'.
678 struct Buffer *value = buf_pool_get();
680 if (increment)
681 rc = command_set_increment(token, value, err);
682 else if (decrement)
683 rc = command_set_decrement(token, value, err);
684 else
685 rc = command_set_set(token, value, err);
686 buf_pool_release(&value);
687 }
688 else
689 {
690 // This is the "set foo" case which has different meanings depending on
691 // the type of the config variable
692 if (bool_or_quad)
693 {
694 struct Buffer *yes = buf_pool_get();
695 buf_addstr(yes, "yes");
696 rc = command_set_set(token, yes, err);
697 buf_pool_release(&yes);
698 }
699 else
700 {
701 rc = command_set_query(token, err);
702 goto done; // We can only do one query even if multiple config names are given
703 }
704 }
705 // Short circuit (i.e. skipping further config variable names) if the action on
706 // the current variable failed.
707 if (rc != MUTT_CMD_SUCCESS)
708 goto done;
709 } while (MoreArgs(line));
710
711 rc = MUTT_CMD_SUCCESS;
712
713done:
714 buf_pool_release(&token);
715 return rc;
716}
@ CMD_RESET
:reset
Definition command.h:103
@ CMD_TOGGLE
:toggle
Definition command.h:122
@ CMD_UNSET
:unset
Definition command.h:142
@ CMD_SET
:set
Definition command.h:108
#define TOKEN_PLUS
Treat '+' as a special.
Definition extract.h:56
#define TOKEN_MINUS
Treat '-' as a special.
Definition extract.h:57
enum CommandResult command_set_increment(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Increment a variable by a value.
Definition set.c:164
enum CommandResult command_set_decrement(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Decrement a variable by a value.
Definition set.c:225
enum CommandResult command_set_toggle(struct Buffer *name, struct Buffer *err)
Toggle a boolean, quad, or number variable.
Definition set.c:365
enum CommandResult command_set_reset(struct Buffer *name, struct Buffer *err)
Reset a variable.
Definition set.c:306
enum CommandResult command_set_query(struct Buffer *name, struct Buffer *err)
Query a variable.
Definition set.c:411
enum CommandResult command_set_unset(struct Buffer *name, struct Buffer *err)
Unset a variable.
Definition set.c:261
enum CommandResult command_set_set(struct Buffer *name, struct Buffer *value, struct Buffer *err)
Set a variable to the given value.
Definition set.c:100
The item stored in a Hash Table.
Definition hash.h:44
union HashKey key
Key representing the data.
Definition hash.h:46
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition hash.h:45
#define CONFIG_TYPE(t)
Extract the type from the flags.
Definition types.h:50
@ DT_NUMBER
a number
Definition types.h:38
@ DT_BOOL
boolean option
Definition types.h:32
@ DT_QUAD
quad-option (no/yes/ask-no/ask-yes)
Definition types.h:40
const char * strkey
String key.
Definition hash.h:36
+ Here is the call graph for this function:

◆ parse_my_header()

enum CommandResult parse_my_header ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'my-header' command - Implements Command::parse() -.

Parse:

  • my-header <string>

Definition at line 52 of file my_header.c.

54{
55 struct Buffer *err = pe->message;
56
57 if (!MoreArgs(line))
58 {
59 buf_printf(err, _("%s: too few arguments"), cmd->name);
60 return MUTT_CMD_WARNING;
61 }
62
63 struct Buffer *token = buf_pool_get();
65
67 char *p = strpbrk(buf_string(token), ": \t");
68 if (!p || (*p != ':'))
69 {
70 buf_strcpy(err, _("invalid header field"));
71 goto done;
72 }
73
75 ASSERT(md);
76
77 struct EventHeader ev_h = { token->data };
78 struct ListNode *node = header_find(&md->user_header, buf_string(token));
79
80 if (node)
81 {
82 header_update(node, buf_string(token));
83 mutt_debug(LL_NOTIFY, "NT_HEADER_CHANGE: %s\n", buf_string(token));
85 }
86 else
87 {
88 header_add(&md->user_header, buf_string(token));
89 mutt_debug(LL_NOTIFY, "NT_HEADER_ADD: %s\n", buf_string(token));
91 }
92
94
95done:
96 buf_pool_release(&token);
97 return rc;
98}
struct ListNode * header_add(struct ListHead *hdrlist, const char *header)
Add a header to a list.
Definition email.c:160
struct ListNode * header_update(struct ListNode *hdr, const char *header)
Update an existing header.
Definition email.c:174
struct ListNode * header_find(const struct ListHead *hdrlist, const char *header)
Find a header, matching on its field, in a list of headers.
Definition email.c:137
@ NT_HEADER_CHANGE
An existing header has been changed.
Definition email.h:210
@ NT_HEADER_ADD
Header has been added.
Definition email.h:208
@ MODULE_ID_SEND
ModuleSend, Send
Definition module_api.h:90
@ NT_HEADER
A header has changed, NotifyHeader EventHeader.
Definition notify_type.h:47
An event that happened to a header.
Definition email.h:217
A List node for strings.
Definition list.h:37
Send private Module data.
Definition module_data.h:32
struct ListHead user_header
Custom headers to add to outgoing emails.
Definition module_data.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_unmy_header()

enum CommandResult parse_unmy_header ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'unmy-header' command - Implements Command::parse() -.

Parse:

  • unmy-header { * | <field> ... }

Definition at line 106 of file my_header.c.

108{
109 struct Buffer *err = pe->message;
110
111 if (!MoreArgs(line))
112 {
113 buf_printf(err, _("%s: too few arguments"), cmd->name);
114 return MUTT_CMD_WARNING;
115 }
116
117 struct Buffer *token = buf_pool_get();
118
119 struct ListNode *np = NULL, *tmp = NULL;
120 size_t l;
121
123 ASSERT(md);
124
125 do
126 {
128 if (mutt_str_equal("*", buf_string(token)))
129 {
130 /* Clear all headers, send a notification for each header */
131 STAILQ_FOREACH(np, &md->user_header, entries)
132 {
133 mutt_debug(LL_NOTIFY, "NT_HEADER_DELETE: %s\n", np->data);
134 struct EventHeader ev_h = { np->data };
136 }
138 continue;
139 }
140
141 l = mutt_str_len(buf_string(token));
142 if (buf_at(token, l - 1) == ':')
143 l--;
144
145 STAILQ_FOREACH_SAFE(np, &md->user_header, entries, tmp)
146 {
147 if (mutt_istrn_equal(buf_string(token), np->data, l) && (np->data[l] == ':'))
148 {
149 mutt_debug(LL_NOTIFY, "NT_HEADER_DELETE: %s\n", np->data);
150 struct EventHeader ev_h = { np->data };
152
153 header_free(&md->user_header, np);
154 }
155 }
156 } while (MoreArgs(line));
157 buf_pool_release(&token);
158 return MUTT_CMD_SUCCESS;
159}
void header_free(struct ListHead *hdrlist, struct ListNode *target)
Free and remove a header from a header list.
Definition email.c:202
@ NT_HEADER_DELETE
Header has been removed.
Definition email.h:209
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition string.c:503
bool mutt_istrn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings ignoring case (to a maximum), safely.
Definition string.c:457
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
#define STAILQ_FOREACH_SAFE(var, head, field, tvar)
Definition queue.h:400
char * data
String.
Definition list.h:38
+ Here is the call graph for this function:

◆ parse_sidebar_pin()

enum CommandResult parse_sidebar_pin ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'sidebar-pin' command - Implements Command::parse() -.

Parse:

  • sidebar-pin <mailbox> [ <mailbox> ... ]

Definition at line 44 of file commands.c.

46{
47 struct Buffer *err = pe->message;
48
49 if (!MoreArgs(line))
50 {
51 buf_printf(err, _("%s: too few arguments"), cmd->name);
52 return MUTT_CMD_WARNING;
53 }
54
55 struct Buffer *path = buf_pool_get();
56
57 do
58 {
60 expand_path(path, false);
62 } while (MoreArgs(line));
63 buf_pool_release(&path);
64
65 return MUTT_CMD_SUCCESS;
66}
struct ListHead SidebarPinned
List of mailboxes to always display in the sidebar.
Definition sidebar.c:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_sidebar_unpin()

enum CommandResult parse_sidebar_unpin ( const struct Command * cmd,
struct Buffer * line,
const struct ParseContext * pc,
struct ParseError * pe )

Parse the 'sidebar-unpin' command - Implements Command::parse() -.

Parse:

  • sidebar-unpin { * | <mailbox> ... }

Definition at line 74 of file commands.c.

76{
77 struct Buffer *err = pe->message;
78
79 if (!MoreArgs(line))
80 {
81 buf_printf(err, _("%s: too few arguments"), cmd->name);
82 return MUTT_CMD_WARNING;
83 }
84
85 struct Buffer *path = buf_pool_get();
86
87 do
88 {
90 /* Check for deletion of entire list */
91 if (mutt_str_equal(buf_string(path), "*"))
92 {
94 break;
95 }
96 expand_path(path, false);
98 } while (MoreArgs(line));
99 buf_pool_release(&path);
100
101 return MUTT_CMD_SUCCESS;
102}
+ Here is the call graph for this function:
+ Here is the caller graph for this function: