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

Definition of the Alias Module. More...

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

Go to the source code of this file.

Functions

static bool alias_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool alias_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool alias_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool alias_cleanup (struct NeoMutt *n)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef AliasVars []
 Config definitions for the alias library.
 
const struct Command AliasCommands []
 Alias Commands.
 
const struct Module ModuleAlias
 Module for the Alias library.
 

Detailed Description

Definition of the Alias 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

◆ alias_init()

static bool alias_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 46 of file module.c.

47{
48 struct AliasModuleData *md = MUTT_MEM_CALLOC(1, struct AliasModuleData);
50
53
56
57 ARRAY_INIT(&md->aliases);
59
60 return true;
61}
#define ARRAY_INIT(head)
Initialize an array.
Definition array.h:65
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_ALIAS
ModuleAlias, Alias
Definition module_api.h:48
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:599
#define STAILQ_INIT(head)
Definition queue.h:410
struct HashTable * alias_reverse_init(void)
Set up the Reverse Alias Hash Table.
Definition reverse.c:43
Alias private Module data.
Definition module_data.h:33
struct AliasArray aliases
User's email aliases.
Definition module_data.h:34
struct HashTable * reverse_aliases
Hash Table of aliases (email address -> alias)
Definition module_data.h:35
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
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:

◆ alias_config_define_variables()

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

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

Definition at line 66 of file module.c.

67{
69}
struct ConfigDef AliasVars[]
Config definitions for the alias library.
Definition config.c:112
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
+ Here is the call graph for this function:

◆ alias_commands_register()

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

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 74 of file module.c.

75{
77}
const struct Command AliasCommands[]
Alias Commands.
Definition commands.c:321
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
+ Here is the call graph for this function:

◆ alias_cleanup()

static bool alias_cleanup ( struct NeoMutt * n)
static

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

Definition at line 82 of file module.c.

83{
85 ASSERT(md);
86
88
91
92 struct Alias **ap = NULL;
93 ARRAY_FOREACH(ap, &md->aliases)
94 {
96 }
98
100
101 FREE(&md);
102 return true;
103}
void aliaslist_clear(struct AliasArray *aa)
Empty a List of Aliases.
Definition alias.c:698
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
void notify_free(struct Notify **ptr)
Free a notification handler.
Definition notify.c:75
void mutt_regexlist_free(struct RegexList *rl)
Free a RegexList object.
Definition regex.c:179
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:585
void alias_reverse_cleanup(struct HashTable **reverse)
Clear up the Reverse Alias Hash Table.
Definition reverse.c:53
void alias_reverse_delete(struct Alias *alias)
Remove an email address lookup for an Alias.
Definition reverse.c:87
#define ASSERT(COND)
Definition signal2.h:59
A shortcut for an email address or addresses.
Definition alias.h:35
+ Here is the call graph for this function:

Variable Documentation

◆ AliasVars

struct ConfigDef AliasVars[]
extern

Config definitions for the alias library.

Definition at line 112 of file config.c.

112 {
113 // clang-format off
114 { "alias_file", DT_PATH|D_PATH_FILE, IP "~/.neomuttrc", 0, NULL,
115 "Save new aliases to this file"
116 },
117 { "alias_format", DT_EXPANDO|D_NOT_EMPTY, IP "%3i %f%t %-15a %-56A | %C%> %Y", IP &AliasFormatDef, NULL,
118 "printf-like format string for the alias menu"
119 },
121 "Sort method for the alias menu"
122 },
123 { "query_command", DT_STRING|D_STRING_COMMAND, 0, 0, NULL,
124 "External command to query and external address book"
125 },
126 { "query_format", DT_EXPANDO|D_NOT_EMPTY, IP "%3i %t %-25N %-25E | %C%> %Y", IP &QueryFormatDef, NULL,
127 "printf-like format string for the query menu (address book)"
128 },
129
130 { "sort_alias", DT_SYNONYM, IP "alias_sort", IP "2024-11-19" },
131
132 { NULL },
133 // clang-format on
134};
static const struct Mapping AliasSortMethods[]
Sort methods for email aliases.
Definition config.c:42
static const struct ExpandoDefinition QueryFormatDef[]
Expando definitions.
Definition config.c:88
static const struct ExpandoDefinition AliasFormatDef[]
Expando definitions.
Definition config.c:60
@ ALIAS_SORT_ALIAS
Sort by Alias short name.
Definition sort.h:31
#define IP
Definition set.h:54
#define D_STRING_COMMAND
A command.
Definition types.h:99
#define D_PATH_FILE
Path is a file.
Definition types.h:104
@ DT_SYNONYM
synonym for another variable
Definition types.h:45
@ DT_STRING
a string
Definition types.h:44
@ DT_SORT
sorting methods
Definition types.h:43
@ DT_EXPANDO
an expando
Definition types.h:34
@ DT_PATH
a path to a file/directory
Definition types.h:39
#define D_SORT_REVERSE
Sort flag for -reverse prefix.
Definition types.h:120
#define D_NOT_EMPTY
Empty strings are not allowed.
Definition types.h:80

◆ AliasCommands

const struct Command AliasCommands[]
extern

Alias Commands.

Definition at line 321 of file commands.c.

321 {
322 // clang-format off
323 { "alias", CMD_ALIAS, parse_alias,
324 N_("Define an alias (name to email address)"),
325 N_("alias [ -group <name> ... ] <key> <address> [,...] [ # <comments> ]"),
326 "configuration.html#alias" },
327 { "alternates", CMD_ALTERNATES, parse_alternates,
328 N_("Define a list of alternate email addresses for the user"),
329 N_("alternates [ -group <name> ... ] <regex> [ <regex> ... ]"),
330 "configuration.html#alternates" },
331 { "unalias", CMD_UNALIAS, parse_unalias,
332 N_("Remove an alias definition"),
333 N_("unalias { * | <key> ... }"),
334 "configuration.html#alias" },
335 { "unalternates", CMD_UNALTERNATES, parse_unalternates,
336 N_("Remove addresses from `alternates` list"),
337 N_("unalternates { * | <regex> ... }"),
338 "configuration.html#alternates" },
339
340 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NO_FLAGS },
341 // clang-format on
342};
#define CF_NO_FLAGS
No flags are set.
Definition command.h:48
@ CMD_UNALIAS
:unalias
Definition command.h:123
@ CMD_ALIAS
:alias
Definition command.h:61
@ CMD_NONE
No Command.
Definition command.h:59
@ CMD_ALTERNATES
:alternates
Definition command.h:62
@ CMD_UNALTERNATES
:unalternates
Definition command.h:124
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() -.
Definition commands.c:268
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() -.
Definition alternates.c:67
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() -.
Definition alternates.c:118
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() -.
Definition commands.c:138
#define N_(a)
Definition message.h:32

◆ ModuleAlias

const struct Module ModuleAlias
Initial value:
= {
"alias",
NULL,
NULL,
NULL,
}
void alias_cleanup(void)
void alias_init(void)
static bool alias_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:74
static bool alias_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:66

Module for the Alias library.

Definition at line 108 of file module.c.

108 {
110 "alias",
112 NULL, // config_define_types
115 NULL, // gui_init
116 NULL, // gui_cleanup
118};