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

Definition of the Pattern Module. More...

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

Go to the source code of this file.

Functions

static bool pattern_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool pattern_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool pattern_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef PatternVars []
 Config definitions for the pattern library.
 
const struct Module ModulePattern
 Module for the Pattern library.
 

Detailed Description

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

◆ pattern_init()

static bool pattern_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 43 of file module.c.

44{
45 struct PatternModuleData *mod_data = MUTT_MEM_CALLOC(1, struct PatternModuleData);
46
47 // clang-format off
48 mod_data->range_regexes[RANGE_K_REL] = (struct RangeRegex){ RANGE_REL_RX, 1, 3, 0, { 0 } };
49 mod_data->range_regexes[RANGE_K_ABS] = (struct RangeRegex){ RANGE_ABS_RX, 1, 3, 0, { 0 } };
50 mod_data->range_regexes[RANGE_K_LT] = (struct RangeRegex){ RANGE_LT_RX, 1, 2, 0, { 0 } };
51 mod_data->range_regexes[RANGE_K_GT] = (struct RangeRegex){ RANGE_GT_RX, 2, 1, 0, { 0 } };
52 mod_data->range_regexes[RANGE_K_BARE] = (struct RangeRegex){ RANGE_BARE_RX, 1, 1, 0, { 0 } };
53 // clang-format on
54
56
57 mod_data->notify = notify_new();
58 notify_set_parent(mod_data->notify, n->notify);
59
60 return true;
61}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_PATTERN
ModulePattern, Pattern
Definition module_api.h:85
struct Notify * notify_new(void)
Create a new notifications handler.
Definition notify.c:62
void notify_set_parent(struct Notify *notify, struct Notify *parent)
Set the parent notification handler.
Definition notify.c:95
void neomutt_set_module_data(struct NeoMutt *n, enum ModuleId id, void *data)
Set the private data for a Module.
Definition neomutt.c:677
#define RANGE_GT_RX
Regex for greater-than range (e.g., ">50")
Definition private.h:117
#define RANGE_ABS_RX
Regex for absolute range (e.g., "1-5")
Definition private.h:112
#define RANGE_LT_RX
Regex for less-than range (e.g., "<100")
Definition private.h:115
#define RANGE_BARE_RX
Regex for bare number range.
Definition private.h:120
#define RANGE_REL_RX
Regex for relative range (e.g., "1,5" or "-3,.")
Definition private.h:107
@ RANGE_K_REL
Relative range.
Definition private.h:93
@ RANGE_K_ABS
Absolute range.
Definition private.h:94
@ RANGE_K_LT
Less-than range.
Definition private.h:95
@ RANGE_K_BARE
Single symbol.
Definition private.h:97
@ RANGE_K_GT
Greater-than range.
Definition private.h:96
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
Pattern private Module data.
Definition module_data.h:32
struct Notify * notify
Notifications.
Definition module_data.h:33
struct RangeRegex range_regexes[RANGE_K_INVALID]
Set of Regexes for various range types.
Definition module_data.h:34
Regular expression representing a range.
Definition private.h:80
+ Here is the call graph for this function:

◆ pattern_config_define_variables()

static bool pattern_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}
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
struct ConfigDef PatternVars[]
Config definitions for the pattern library.
Definition config.c:57
+ Here is the call graph for this function:

◆ pattern_cleanup()

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

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

Definition at line 74 of file module.c.

75{
76 struct PatternModuleData *mod_data = data;
77
78 notify_free(&mod_data->notify);
79
80 for (int i = 0; i < RANGE_K_INVALID; i++)
81 {
82 if (mod_data->range_regexes[i].ready)
83 regfree(&mod_data->range_regexes[i].cooked);
84 }
85
86 FREE(&mod_data);
87 return true;
88}
#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
@ RANGE_K_INVALID
Range is invalid.
Definition private.h:99
regex_t cooked
Compiled form.
Definition private.h:85
bool ready
Compiled yet?
Definition private.h:84
+ Here is the call graph for this function:

Variable Documentation

◆ PatternVars

struct ConfigDef PatternVars[]
extern

Config definitions for the pattern library.

Definition at line 57 of file config.c.

57 {
58 // clang-format off
59 { "external_search_command", DT_STRING|D_STRING_COMMAND, 0, 0, NULL,
60 "External search command"
61 },
62 { "pattern_format", DT_EXPANDO, IP "%2n %-15e %d", IP &PatternFormatDef, NULL,
63 "printf-like format string for the pattern completion menu"
64 },
65 { "simple_search", DT_STRING, IP "~f %s | ~s %s", 0, NULL,
66 "Pattern to search for when search doesn't contain ~'s"
67 },
68 { "thorough_search", DT_BOOL, true, 0, NULL,
69 "Decode headers and messages before searching them"
70 },
71 { NULL },
72 // clang-format on
73};
#define IP
Definition set.h:55
static const struct ExpandoDefinition PatternFormatDef[]
Expando definitions.
Definition config.c:42
#define D_STRING_COMMAND
A command.
Definition types.h:99
@ DT_BOOL
boolean option
Definition types.h:32
@ DT_STRING
a string
Definition types.h:44
@ DT_EXPANDO
an expando
Definition types.h:34

◆ ModulePattern

const struct Module ModulePattern
Initial value:
= {
"pattern",
NULL,
NULL,
NULL,
NULL,
}
static bool pattern_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:66
static bool pattern_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:74
static bool pattern_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:43

Module for the Pattern library.

Definition at line 93 of file module.c.

93 {
95 "pattern",
97 NULL, // config_define_types
99 NULL, // commands_register
100 NULL, // gui_init
101 NULL, // gui_cleanup
103};