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

Definition of the Notmuch 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 dependency graph for module.c:

Go to the source code of this file.

Functions

static bool notmuch_init (struct NeoMutt *n)
 Initialise a Module - Implements Module::init()
 
static bool notmuch_config_define_variables (struct NeoMutt *n, struct ConfigSet *cs)
 Define the Config Variables - Implements Module::config_define_variables()
 
static bool notmuch_commands_register (struct NeoMutt *n, struct CommandArray *ca)
 Register NeoMutt Commands - Implements Module::commands_register()
 
static bool notmuch_gui_init (struct NeoMutt *n)
 Initialise the GUI - Implements Module::gui_init()
 
static void notmuch_gui_cleanup (struct NeoMutt *n)
 Clean up the GUI - Implements Module::gui_cleanup()
 
static bool notmuch_cleanup (struct NeoMutt *n, void *data)
 Clean up a Module - Implements Module::cleanup()
 

Variables

struct ConfigDef NotmuchVars []
 Config definitions for the Notmuch library.
 
const struct Command NmCommands []
 Notmuch Commands.
 
const struct Module ModuleNotmuch
 Module for the Notmuch library.
 

Detailed Description

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

◆ notmuch_init()

static bool notmuch_init ( struct NeoMutt * n)
static

Initialise a Module - Implements Module::init()

Definition at line 44 of file module.c.

45{
46 struct NotmuchModuleData *mod_data = MUTT_MEM_CALLOC(1, struct NotmuchModuleData);
48
49 mod_data->notify = notify_new();
50 notify_set_parent(mod_data->notify, n->notify);
51
52 return true;
53}
#define MUTT_MEM_CALLOC(n, type)
Definition memory.h:52
@ MODULE_ID_NOTMUCH
ModuleNotmuch, Notmuch
Definition module_api.h:82
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
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
Notmuch private Module data.
Definition module_data.h:30
struct Notify * notify
Notifications.
Definition module_data.h:31
+ Here is the call graph for this function:

◆ notmuch_config_define_variables()

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

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

Definition at line 58 of file module.c.

59{
60 bool rc = false;
61
62#if defined(USE_NOTMUCH)
64#endif
65
66 return rc;
67}
bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[])
Register a set of config items.
Definition set.c:290
struct ConfigDef NotmuchVars[]
Config definitions for the Notmuch library.
Definition config.c:75
+ Here is the call graph for this function:

◆ notmuch_commands_register()

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

Register NeoMutt Commands - Implements Module::commands_register()

Definition at line 72 of file module.c.

73{
74 return commands_register(ca, NmCommands);
75}
bool commands_register(struct CommandArray *ca, const struct Command *cmds)
Add commands to Commands array.
Definition command.c:51
const struct Command NmCommands[]
Notmuch Commands.
Definition notmuch.c:91
+ Here is the call graph for this function:

◆ notmuch_gui_init()

static bool notmuch_gui_init ( struct NeoMutt * n)
static

Initialise the GUI - Implements Module::gui_init()

Definition at line 80 of file module.c.

81{
82 const bool c_virtual_spool_file = cs_subset_bool(n->sub, "virtual_spool_file");
83 if (c_virtual_spool_file)
84 {
85 /* Find the first virtual folder and open it */
86 struct MailboxArray ma = neomutt_mailboxes_get(n, MUTT_NOTMUCH);
87 struct Mailbox **mp = ARRAY_FIRST(&ma);
88 if (mp)
89 cs_str_string_set(n->cs, "spool_file", mailbox_path(*mp), NULL);
90 ARRAY_FREE(&ma); // Clean up the ARRAY, but not the Mailboxes
91 }
92 return true;
93}
#define ARRAY_FIRST(head)
Convenience method to get the first element.
Definition array.h:136
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
int cs_str_string_set(const struct ConfigSet *cs, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
Definition set.c:693
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
struct MailboxArray neomutt_mailboxes_get(struct NeoMutt *n, enum MailboxType type)
Get an Array of matching Mailboxes.
Definition neomutt.c:604
A mailbox.
Definition mailbox.h:81
struct ConfigSet * cs
Config set.
Definition neomutt.h:48
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:

◆ notmuch_gui_cleanup()

static void notmuch_gui_cleanup ( struct NeoMutt * n)
static

Clean up the GUI - Implements Module::gui_cleanup()

Definition at line 98 of file module.c.

99{
100}

◆ notmuch_cleanup()

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

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

Definition at line 105 of file module.c.

106{
107 struct NotmuchModuleData *mod_data = data;
108
109 notify_free(&mod_data->notify);
110
111 FREE(&mod_data);
112 return true;
113}
#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
+ Here is the call graph for this function:

Variable Documentation

◆ NotmuchVars

struct ConfigDef NotmuchVars[]
extern

Config definitions for the Notmuch library.

Definition at line 75 of file config.c.

75 {
76 // clang-format off
77 { "nm_config_file", DT_PATH|D_PATH_FILE, IP "auto", 0, NULL,
78 "(notmuch) Configuration file for notmuch. Use 'auto' to detect configuration."
79 },
80 { "nm_config_profile", DT_STRING, 0, 0, NULL,
81 "(notmuch) Configuration profile for notmuch."
82 },
83 { "nm_db_limit", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 0, 0, NULL,
84 "(notmuch) Default limit for Notmuch queries"
85 },
86 { "nm_default_url", DT_STRING, 0, 0, nm_default_url_validator,
87 "(notmuch) Path to the Notmuch database"
88 },
89 { "nm_exclude_tags", DT_STRING, 0, 0, NULL,
90 "(notmuch) Exclude messages with these tags"
91 },
92 { "nm_flagged_tag", DT_STRING, IP "flagged", 0, NULL,
93 "(notmuch) Tag to use for flagged messages"
94 },
95 { "nm_open_timeout", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 5, 0, NULL,
96 "(notmuch) Database timeout"
97 },
98 { "nm_query_type", DT_ENUM, NM_QUERY_TYPE_MESSAGES, IP &NmQueryTypeDef, NULL,
99 "(notmuch) Default query type: 'threads' or 'messages'"
100 },
101 { "nm_query_window_current_position", DT_NUMBER, 0, 0, NULL,
102 "(notmuch) Position of current search window"
103 },
104 { "nm_query_window_current_search", DT_STRING, 0, 0, NULL,
105 "(notmuch) Current search parameters"
106 },
107 { "nm_query_window_duration", DT_NUMBER|D_INTEGER_NOT_NEGATIVE, 0, 0, NULL,
108 "(notmuch) Time duration of the current search window"
109 },
110 { "nm_query_window_enable", DT_BOOL, false, 0, NULL,
111 "(notmuch) Enable query windows"
112 },
113 { "nm_query_window_or_terms", DT_STRING, 0, 0, NULL,
114 "(notmuch) Additional notmuch search terms for messages to be shown regardless of date"
115 },
116 { "nm_query_window_timebase", DT_ENUM, NMTB_WEEK, IP &NmQueryWindowTimebaseDef, NULL,
117 "(notmuch) Units for the time duration"
118 },
119 { "nm_record_tags", DT_STRING, 0, 0, NULL,
120 "(notmuch) Tags to apply to the 'record' mailbox (sent mail)"
121 },
122 { "nm_replied_tag", DT_STRING, IP "replied", 0, NULL,
123 "(notmuch) Tag to use for replied messages"
124 },
125 { "nm_unread_tag", DT_STRING, IP "unread", 0, NULL,
126 "(notmuch) Tag to use for unread messages"
127 },
128 { "virtual_spool_file", DT_BOOL, false, 0, NULL,
129 "(notmuch) Use the first virtual mailbox as a spool file"
130 },
131
132 { "vfolder_format", D_INTERNAL_DEPRECATED|DT_STRING, 0, IP "2018-11-01" },
133
134 { "nm_default_uri", DT_SYNONYM, IP "nm_default_url", IP "2021-02-11" },
135 { "virtual_spoolfile", DT_SYNONYM, IP "virtual_spool_file", IP "2025-12-08" },
136 { NULL },
137 // clang-format on
138};
#define IP
Definition set.h:55
static int nm_default_url_validator(const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Validate the "nm_default_url" config variable - Implements ConfigDef::validator() -.
Definition config.c:58
const struct EnumDef NmQueryWindowTimebaseDef
Data for the $nm_query_window_timebase enumeration.
Definition query.c:73
const struct EnumDef NmQueryTypeDef
Data for the $nm_query_type enumeration.
Definition query.c:52
@ NM_QUERY_TYPE_MESSAGES
Default: Messages only.
Definition query.h:37
@ NMTB_WEEK
Weeks.
Definition query.h:49
#define D_INTERNAL_DEPRECATED
Config item shouldn't be used any more.
Definition types.h:88
#define D_PATH_FILE
Path is a file.
Definition types.h:104
@ DT_NUMBER
a number
Definition types.h:38
@ 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_ENUM
an enumeration
Definition types.h:33
@ DT_PATH
a path to a file/directory
Definition types.h:39
#define D_INTEGER_NOT_NEGATIVE
Negative numbers are not allowed.
Definition types.h:101

◆ NmCommands

const struct Command NmCommands[]
extern

Notmuch Commands.

Definition at line 91 of file notmuch.c.

91 {
92 // clang-format off
93 // Deprecated
94 { "unvirtual-mailboxes", CMD_NONE, NULL, "unmailboxes", NULL, NULL, CF_SYNONYM },
95 { "virtual-mailboxes", CMD_NONE, NULL, "named-mailboxes", NULL, NULL, CF_SYNONYM },
96
97 { NULL, CMD_NONE, NULL, NULL, NULL, NULL, CF_NONE },
98 // clang-format on
99};
@ CF_SYNONYM
Command is a synonym for another command.
Definition command.h:50
@ CF_NONE
No flags are set.
Definition command.h:49
@ CMD_NONE
No Command.
Definition command.h:62

◆ ModuleNotmuch

const struct Module ModuleNotmuch
Initial value:
= {
"notmuch",
NULL,
}
static bool notmuch_config_define_variables(struct NeoMutt *n, struct ConfigSet *cs)
Define the Config Variables - Implements Module::config_define_variables()
Definition module.c:58
static bool notmuch_gui_init(struct NeoMutt *n)
Initialise the GUI - Implements Module::gui_init()
Definition module.c:80
static void notmuch_gui_cleanup(struct NeoMutt *n)
Clean up the GUI - Implements Module::gui_cleanup()
Definition module.c:98
static bool notmuch_init(struct NeoMutt *n)
Initialise a Module - Implements Module::init()
Definition module.c:44
static bool notmuch_cleanup(struct NeoMutt *n, void *data)
Clean up a Module - Implements Module::cleanup()
Definition module.c:105
static bool notmuch_commands_register(struct NeoMutt *n, struct CommandArray *ca)
Register NeoMutt Commands - Implements Module::commands_register()
Definition module.c:72

Module for the Notmuch library.

Definition at line 118 of file module.c.

118 {
120 "notmuch",
122 NULL, // config_define_types
128};