NeoMutt  2025-12-11-435-g4ac674
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
ignore.c
Go to the documentation of this file.
1
30
36
37#include "config.h"
38#include "mutt/lib.h"
39#include "core/lib.h"
40#include "ignore.h"
41#include "parse/lib.h"
42#include "module_data.h"
43
50enum CommandResult parse_ignore(const struct Command *cmd, struct Buffer *line,
51 const struct ParseContext *pc, struct ParseError *pe)
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}
76
83enum CommandResult parse_unignore(const struct Command *cmd, struct Buffer *line,
84 const struct ParseContext *pc, struct ParseError *pe)
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}
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_WARNING
Warning: Help given to the user.
Definition command.h:39
Convenience wrapper for the core headers.
Email private Module data.
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
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() -.
Definition ignore.c:83
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() -.
Definition ignore.c:50
Parse Ignore Commands.
void remove_from_stailq(struct ListHead *head, const char *str)
Remove an item, matching a string, from a List.
Definition list.c:341
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition list.c:316
@ MODULE_ID_EMAIL
ModuleEmail, Email code
Definition module_api.h:64
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:662
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
Text parsing functions.
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 ASSERT(COND)
Definition signal2.h:59
String manipulation buffer.
Definition buffer.h:36
const char * name
Name of the Command.
Definition command.h:159
Email private Module data.
Definition module_data.h:32
struct ListHead unignore
Header patterns to unignore.
Definition module_data.h:45
struct ListHead ignore
Header patterns to ignore.
Definition module_data.h:37
Container for Accounts, Notifications.
Definition neomutt.h:41
Context for config parsing (history/backtrace)
Definition pcontext.h:34
Detailed error information from config parsing.
Definition perror.h:34
struct Buffer * message
Error message.
Definition perror.h:35