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

Definition of the Email Module. More...

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

Go to the source code of this file.

Functions

static bool email_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool email_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool email_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool email_cleanup (struct NeoMutt *n)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef EmailVars []
 Config definitions for the Email library.
 
const struct Command EmailCommands []
 Email Commands.
 
const struct Module ModuleEmail
 Module for the Email library.
 

Detailed Description

Definition of the Email Module.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file module.c.

Function Documentation

◆ email_init()

static bool email_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 45 of file module.c.

46{
47 struct EmailModuleData *md = MUTT_MEM_CALLOC(1, struct EmailModuleData);
49
50 md->auto_subscribe_cache = NULL;
51
55 STAILQ_INIT(&md->ignore);
56 STAILQ_INIT(&md->mail);
58 STAILQ_INIT(&md->no_spam);
59 STAILQ_INIT(&md->spam);
62 STAILQ_INIT(&md->unmail);
64
65 /* RFC2368, "4. Unsafe headers"
66 * The creator of a mailto URL can't expect the resolver of a URL to
67 * understand more than the "subject" and "body" headers. Clients that
68 * resolve mailto URLs into mail messages should be able to correctly create
69 * RFC822-compliant mail messages using the "subject" and "body" headers. */
70 add_to_stailq(&md->mail_to_allow, "body");
71 add_to_stailq(&md->mail_to_allow, "subject");
72 // Cc, In-Reply-To, and References help with not breaking threading on mailing lists
73 add_to_stailq(&md->mail_to_allow, "cc");
74 add_to_stailq(&md->mail_to_allow, "in-reply-to");
75 add_to_stailq(&md->mail_to_allow, "references");
76
78
79 return true;
80}
void add_to_stailq(struct ListHead *head, const char *str)
Add a string to a list.
Definition list.c:316
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_EMAIL
ModuleEmail, Email code
Definition module_api.h:64
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:599
#define STAILQ_INIT(head)
Definition queue.h:410
Email private Module data.
Definition module_data.h:32
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
struct ListHead unignore
Header patterns to unignore.
Definition module_data.h:45
struct ListHead ignore
Header patterns to ignore.
Definition module_data.h:37
struct ReplaceList spam
Regexes and patterns to match spam emails.
Definition module_data.h:41
struct RegexList unmail
Regexes to exclude false matches in mail.
Definition module_data.h:46
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 RegexList no_spam
Regexes to identify non-spam emails.
Definition module_data.h:40
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
struct HashTable * auto_subscribe_cache
Hash Table: "mailto:" (no value)
Definition module_data.h:34
struct RegexList mail
Regexes to match mailing lists.
Definition module_data.h:38
void driver_tags_init(struct EmailModuleData *md)
Initialize structures used for tags.
Definition tags.c:235
+ Here is the call graph for this function:

◆ email_config_define_variables()

static bool email_config_define_variables ( struct NeoMutt * n,
struct ConfigSet * cs )
static

Define the Config Variables - Implements Module::config_define_variables()

Definition at line 85 of file module.c.

86{
88}
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
struct ConfigDef EmailVars[]
Config definitions for the Email library.
Definition config.c:56
+ Here is the call graph for this function:

◆ email_commands_register()

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

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 93 of file module.c.

94{
96}
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
const struct Command EmailCommands[]
Email Commands.
Definition commands.c:222
+ Here is the call graph for this function:

◆ email_cleanup()

static bool email_cleanup ( struct NeoMutt * n)
static

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

Definition at line 101 of file module.c.

102{
104 ASSERT(md);
105
107
114
120
122
124
125 FREE(&md);
126 return true;
127}
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition hash.c:459
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition list.c:123
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void 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
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
#define ASSERT(COND)
Definition signal2.h:59
void driver_tags_cleanup(struct EmailModuleData *md)
Deinitialize structures used for tags.
Definition tags.c:248
+ Here is the call graph for this function:

Variable Documentation

◆ EmailVars

struct ConfigDef EmailVars[]
extern

Config definitions for the Email library.

Definition at line 56 of file config.c.

56 {
57 // clang-format off
58 { "auto_subscribe", DT_BOOL, false, 0, NULL,
59 "Automatically check if the user is subscribed to a mailing list"
60 },
61 { "honor_disposition", DT_BOOL, false, 0, NULL,
62 "Don't display MIME parts inline if they have a disposition of 'attachment'"
63 },
64 { "hidden_tags", DT_SLIST|D_SLIST_SEP_COMMA, IP "unread,draft,flagged,passed,replied,attachment,signed,encrypted", 0, NULL,
65 "List of tags that shouldn't be displayed on screen (comma-separated)"
66 },
67 { "implicit_auto_view", DT_BOOL, false, 0, NULL,
68 "Display MIME attachments inline if a 'copiousoutput' mailcap entry exists"
69 },
70 { "include_encrypted", DT_BOOL, false, 0, NULL,
71 "Whether to include encrypted content when replying"
72 },
73 { "include_only_first", DT_BOOL, false, 0, NULL,
74 "Only include the first attachment when replying"
75 },
76 { "mailcap_path", DT_SLIST|D_SLIST_SEP_COLON, IP "~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap", 0, NULL,
77 "List of mailcap files (colon-separated)"
78 },
79 { "mailcap_sanitize", DT_BOOL, true, 0, NULL,
80 "Restrict the possible characters in mailcap expandos"
81 },
82 { "preferred_languages", DT_SLIST|D_SLIST_SEP_COMMA, 0, 0, NULL,
83 "List of Preferred Languages for multilingual MIME (comma-separated)"
84 },
85 { "reflow_space_quotes", DT_BOOL, true, 0, NULL,
86 "Insert spaces into reply quotes for 'format=flowed' messages"
87 },
88 { "reflow_text", DT_BOOL, true, 0, NULL,
89 "Reformat paragraphs of 'format=flowed' text"
90 },
91 { "reflow_wrap", DT_NUMBER, 78, 0, NULL,
92 "Maximum paragraph width for reformatting 'format=flowed' text"
93 },
94 // L10N: $reply_regex default format
95 //
96 // This is a regular expression that matches reply subject lines.
97 // By default, it only matches an initial "Re: ", which is the
98 // standardized Latin prefix.
99 //
100 // However, many locales have other prefixes that are commonly used
101 // too, such as Aw in Germany. To add other prefixes, modify the first
102 // parenthesized expression, such as:
103 // "^(re|aw)
104 // you can add multiple values, for example:
105 // "^(re|aw|sv)
106 //
107 // Important:
108 // - Use all lower case letters.
109 // - Don't remove the 're' prefix from the list of choices.
110 // - Please test the value you use inside Mutt. A mistake here will break
111 // NeoMutt's threading behavior. Note: the header cache can interfere with
112 // testing, so be sure to test with $header_cache unset.
113 { "reply_regex", DT_REGEX|D_L10N_STRING, IP N_("^((re)(\\[[0-9]+\\])*:[ \t]*)*"), 0, NULL,
114 "Regex to match message reply subjects like 're: '"
115 },
116 { "score", DT_BOOL, true, 0, NULL,
117 "Use message scoring"
118 },
119 { "score_threshold_delete", DT_NUMBER, -1, 0, NULL,
120 "Messages with a lower score will be automatically deleted"
121 },
122 { "score_threshold_flag", DT_NUMBER, 9999, 0, NULL,
123 "Messages with a greater score will be automatically flagged"
124 },
125 { "score_threshold_read", DT_NUMBER, -1, 0, NULL,
126 "Messages with a lower score will be automatically marked read"
127 },
128 { "show_multipart_alternative", DT_STRING, 0, 0, multipart_validator,
129 "How to display 'multipart/alternative' MIME parts"
130 },
131 { "reverse_alias", DT_BOOL, false, 0, NULL,
132 "Display the alias in the index, rather than the message's sender"
133 },
134 { "rfc2047_parameters", DT_BOOL, true, 0, NULL,
135 "Decode RFC2047-encoded MIME parameters"
136 },
137 { "spam_separator", DT_STRING, IP ",", 0, NULL,
138 "Separator for multiple spam headers"
139 },
140
141 { "implicit_autoview", DT_SYNONYM, IP "implicit_auto_view", IP "2023-01-25" },
142 { "include_onlyfirst", DT_SYNONYM, IP "include_only_first", IP "2021-03-21" },
143 { "reply_regexp", DT_SYNONYM, IP "reply_regex", IP "2021-03-21" },
144 { NULL },
145 // clang-format on
146};
#define IP
Definition set.h:54
static int multipart_validator(const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "show_multipart_alternative" config variable - Implements ConfigDef::validator() -.
Definition config.c:39
#define N_(a)
Definition message.h:32
#define D_SLIST_SEP_COMMA
Slist items are comma-separated.
Definition types.h:111
#define D_SLIST_SEP_COLON
Slist items are colon-separated.
Definition types.h:112
#define D_L10N_STRING
String can be localised.
Definition types.h:82
@ DT_NUMBER
a number
Definition types.h:38
@ DT_SLIST
a list of strings
Definition types.h:42
@ DT_BOOL
boolean option
Definition types.h:32
@ DT_SYNONYM
synonym for another variable
Definition types.h:45
@ DT_STRING
a string
Definition types.h:44
@ DT_REGEX
regular expressions
Definition types.h:41

◆ EmailCommands

const struct Command EmailCommands[]
extern

Email Commands.

Definition at line 222 of file commands.c.

222 {
223 // clang-format off
224 { "alternative-order", CMD_ALTERNATIVE_ORDER, parse_list,
225 N_("Set preference order for multipart alternatives"),
226 N_("alternative-order <mime-type>[/<mime-subtype> ] [ ... ]"),
227 "mimesupport.html#alternative-order" },
228 { "auto-view", CMD_AUTO_VIEW, parse_list,
229 N_("Automatically display specified MIME types inline"),
230 N_("auto-view <mime-type>[/<mime-subtype> ] [ ... ]"),
231 "mimesupport.html#auto-view" },
232 { "group", CMD_GROUP, parse_group,
233 N_("Add addresses to an address group"),
234 N_("group [ -group <name> ... ] { -rx <regex> ... | -addr <address> ... }"),
235 "configuration.html#addrgroup" },
236 { "header-order", CMD_HEADER_ORDER, parse_list,
237 N_("Define custom order of headers displayed"),
238 N_("header-order <header> [ <header> ... ]"),
239 "configuration.html#header-order" },
240 { "ignore", CMD_IGNORE, parse_ignore,
241 N_("Hide specified headers when displaying messages"),
242 N_("ignore <string> [ <string> ...]"),
243 "configuration.html#ignore" },
244 { "lists", CMD_LISTS, parse_lists,
245 N_("Add address to the list of mailing lists"),
246 N_("lists [ -group <name> ... ] <regex> [ ... ]"),
247 "configuration.html#lists" },
248 { "mailto-allow", CMD_MAILTO_ALLOW, parse_list,
249 N_("Permit specific header-fields in mailto URL processing"),
250 N_("mailto-allow { * | <header-field> ... }"),
251 "configuration.html#mailto-allow" },
252 { "nospam", CMD_NOSPAM, parse_nospam,
253 N_("Remove a spam detection rule"),
254 N_("nospam { * | <regex> }"),
255 "configuration.html#spam" },
256 { "score", CMD_SCORE, parse_score,
257 N_("Set a score value on emails matching a pattern"),
258 N_("score <pattern> <value>"),
259 "configuration.html#score-command" },
260 { "spam", CMD_SPAM, parse_spam,
261 N_("Define rules to parse spam detection headers"),
262 N_("spam <regex> [ <format> ]"),
263 "configuration.html#spam" },
264 { "tag-formats", CMD_TAG_FORMATS, parse_tag_formats,
265 N_("Define expandos tags"),
266 N_("tag-formats <tag> <format-string> [ ... ] }"),
267 "optionalfeatures.html#custom-tags" },
268 { "tag-transforms", CMD_TAG_TRANSFORMS, parse_tag_transforms,
269 N_("Rules to transform tags into icons"),
270 N_("tag-transforms <tag> <transformed-string> [ ... ]"),
271 "optionalfeatures.html#custom-tags" },
272 { "unalternative-order", CMD_UNALTERNATIVE_ORDER, parse_unlist,
273 N_("Remove MIME types from preference order"),
274 N_("unalternative-order { * | [ <mime-type>[/<mime-subtype> ] ... ] }"),
275 "mimesupport.html#alternative-order" },
276 { "unauto-view", CMD_UNAUTO_VIEW, parse_unlist,
277 N_("Remove MIME types from `auto-view` list"),
278 N_("unauto-view { * | [ <mime-type>[/<mime-subtype> ] ... ] }"),
279 "mimesupport.html#auto-view" },
280 { "ungroup", CMD_UNGROUP, parse_group,
281 N_("Remove addresses from an address `group`"),
282 N_("ungroup [ -group <name> ... ] { * | -rx <regex> ... | -addr <address> ... }"),
283 "configuration.html#addrgroup" },
284 { "unheader-order", CMD_UNHEADER_ORDER, parse_unlist,
285 N_("Remove header from `header-order` list"),
286 N_("unheader-order { * | <header> ... }"),
287 "configuration.html#header-order" },
288 { "unignore", CMD_UNIGNORE, parse_unignore,
289 N_("Remove a header from the `header-order` list"),
290 N_("unignore { * | <string> ... }"),
291 "configuration.html#ignore" },
292 { "unlists", CMD_UNLISTS, parse_unlists,
293 N_("Remove address from the list of mailing lists"),
294 N_("unlists { * | <regex> ... }"),
295 "configuration.html#lists" },
296 { "unmailto-allow", CMD_UNMAILTO_ALLOW, parse_unlist,
297 N_("Disallow header-fields in mailto processing"),
298 N_("unmailto-allow { * | <header-field> ... }"),
299 "configuration.html#mailto-allow" },
300 { "unscore", CMD_UNSCORE, parse_unscore,
301 N_("Remove scoring rules for matching patterns"),
302 N_("unscore { * | <pattern> ... }"),
303 "configuration.html#score-command" },
304
305 // Deprecated
306 { "alternative_order", CMD_NONE, NULL, "alternative-order", NULL, NULL, CF_SYNONYM },
307 { "auto_view", CMD_NONE, NULL, "auto-view", NULL, NULL, CF_SYNONYM },
308 { "hdr_order", CMD_NONE, NULL, "header-order", NULL, NULL, CF_SYNONYM },
309 { "mailto_allow", CMD_NONE, NULL, "mailto-allow", NULL, NULL, CF_SYNONYM },
310 { "unalternative_order", CMD_NONE, NULL, "unalternative-order", NULL, NULL, CF_SYNONYM },
311 { "unauto_view", CMD_NONE, NULL, "unauto-view", NULL, NULL, CF_SYNONYM },
312 { "unhdr_order", CMD_NONE, NULL, "unheader-order", NULL, NULL, CF_SYNONYM },
313 { "unmailto_allow", CMD_NONE, NULL, "unmailto-allow", NULL, NULL, CF_SYNONYM },
314
315 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NO_FLAGS },
316 // clang-format on
317};
#define CF_SYNONYM
Command is a synonym for another command.
Definition command.h:49
#define CF_NO_FLAGS
No flags are set.
Definition command.h:48
@ CMD_SPAM
:spam
Definition command.h:114
@ CMD_IGNORE
:ignore
Definition command.h:85
@ CMD_GROUP
:group
Definition command.h:79
@ CMD_TAG_TRANSFORMS
:tag-transforms
Definition command.h:120
@ CMD_SCORE
:score
Definition command.h:105
@ CMD_MAILTO_ALLOW
:mailto-allow
Definition command.h:92
@ CMD_LISTS
:lists
Definition command.h:87
@ CMD_AUTO_VIEW
:auto-view
Definition command.h:66
@ 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_NOSPAM
:nospam
Definition command.h:99
@ CMD_UNGROUP
:ungroup
Definition command.h:130
@ CMD_NONE
No Command.
Definition command.h:59
@ CMD_TAG_FORMATS
:tag-formats
Definition command.h:119
@ CMD_UNIGNORE
:unignore
Definition command.h:133
@ CMD_UNLISTS
:unlists
Definition command.h:134
@ CMD_ALTERNATIVE_ORDER
:alternative-order
Definition command.h:63
@ CMD_UNSCORE
:unscore
Definition command.h:141
@ CMD_HEADER_ORDER
:header-order
Definition command.h:80
@ CMD_UNMAILTO_ALLOW
:unmailto-allow
Definition command.h:137
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() -.
Definition commands.c:175
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() -.
Definition spam.c:51
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() -.
Definition commands.c:87
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() -.
Definition commands.c:124
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() -.
Definition group.c:288
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() -.
Definition group.c:188
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() -.
Definition group.c:90
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() -.
Definition score.c:146
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_spam(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'spam' command - Implements Command::parse() -.
Definition spam.c:113
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
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() -.
Definition score.c:57
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() -.
Definition commands.c:51

◆ ModuleEmail

const struct Module ModuleEmail
Initial value:
= {
"email",
NULL,
NULL,
NULL,
}
static bool email_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:93
static bool email_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:45
static bool email_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:85
static bool email_cleanup(struct NeoMutt *n)
Clean up a Module - Implements Module::cleanup()
Definition module.c:101

Module for the Email library.

Definition at line 132 of file module.c.

132 {
134 "email",
136 NULL, // config_define_types
139 NULL, // gui_init
140 NULL, // gui_cleanup
142};