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

Postponed Emails Functions. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "functions.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "pattern/lib.h"
#include "module_data.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

void postponed_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Postponed Keybindings - Implements ::init_keys_api.
 
static int postpone_add_selection (struct EmailArray *ea, struct Menu *menu, struct Mailbox *m, bool tagged, int count)
 Build a working set of Emails for an action.
 
static void postpone_apply_set_deleted (struct Mailbox *m, struct EmailArray *ea, bool deleted)
 Apply the deleted flag to a working set of Emails.
 
static int op_delete (struct PostponeData *pd, const struct KeyEvent *event)
 Delete the current entry - Implements postpone_function_t -.
 
static int op_exit (struct PostponeData *pd, const struct KeyEvent *event)
 Exit this menu - Implements postpone_function_t -.
 
static int op_generic_select_entry (struct PostponeData *pd, const struct KeyEvent *event)
 Select the current entry - Implements postpone_function_t -.
 
static int op_search (struct PostponeData *pd, const struct KeyEvent *event)
 Search for a regular expression - Implements postpone_function_t -.
 
int postpone_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a Postpone function - Implements function_dispatcher_t -.
 
struct MailboxViewpostponed_get_mailbox_view (struct MuttWindow *dlg)
 Extract the Mailbox from the Postponed Dialog.
 

Variables

static const struct MenuFuncOp OpPostponed []
 Functions for the Postpone Menu.
 
static const struct MenuOpSeq PostponedDefaultBindings []
 Key bindings for the Postpone Menu.
 
static const struct PostponeFunction PostponeFunctions []
 All the NeoMutt functions that the Postpone supports.
 

Detailed Description

Postponed Emails Functions.

Authors
  • Richard Russon
  • Dennis Schön

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 functions.c.

Function Documentation

◆ postponed_init_keys()

void postponed_init_keys ( struct NeoMutt * n,
struct SubMenu * sm_generic )

Initialise the Postponed Keybindings - Implements ::init_keys_api.

Definition at line 72 of file functions.c.

73{
74 struct MenuDefinition *md = NULL;
75 struct SubMenu *sm = NULL;
76
78 md = km_register_menu(MENU_POSTPONE, "postpone");
79 km_menu_add_submenu(md, sm);
80 km_menu_add_submenu(md, sm_generic);
82
84 ASSERT(mod_data);
85 mod_data->menu_postpone = md;
86}
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:121
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:87
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:104
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:134
@ MODULE_ID_POSTPONE
ModulePostpone, Postponed Emails
Definition module_api.h:87
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
static const struct MenuFuncOp OpPostponed[]
Functions for the Postpone Menu.
Definition functions.c:49
static const struct MenuOpSeq PostponedDefaultBindings[]
Key bindings for the Postpone Menu.
Definition functions.c:60
#define ASSERT(COND)
Definition signal2.h:59
Functions for a Dialog or Window.
Definition menu.h:77
Postpone private Module data.
Definition module_data.h:32
struct MenuDefinition * menu_postpone
Postpone menu definition.
Definition module_data.h:34
Collection of related functions.
Definition menu.h:65
@ MENU_POSTPONE
Select a postponed email.
Definition type.h:48
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postpone_add_selection()

static int postpone_add_selection ( struct EmailArray * ea,
struct Menu * menu,
struct Mailbox * m,
bool tagged,
int count )
static

Build a working set of Emails for an action.

Parameters
eaEmpty EmailArray to populate
menuPostpone Menu
mMailbox
taggedUse tagged emails (tag-prefix)
countRepeat-count (0 or 1 == just the current selection)
Return values
numNumber of emails added

If tagged is true, the array is filled with the tagged emails and count is ignored.

Otherwise the array is filled with the current selection and the next count - 1 emails. Overruns are silently capped at the end of the list.

Definition at line 103 of file functions.c.

105{
106 if (!ea || !menu || !m || !m->emails)
107 return 0;
108
109 if (tagged)
110 {
111 for (int i = 0; i < m->msg_count; i++)
112 {
113 struct Email *e = m->emails[i];
114 if (e && e->tagged)
115 ARRAY_ADD(ea, e);
116 }
117 }
118 else
119 {
120 const int index = menu_get_index(menu);
121 if ((index < 0) || (index >= m->msg_count))
122 return 0;
123
124 int n = (count > 1) ? count : 1;
125 if ((index + n) > m->msg_count)
126 n = m->msg_count - index;
127
128 for (int i = 0; i < n; i++)
129 {
130 struct Email *e = m->emails[index + i];
131 if (e)
132 ARRAY_ADD(ea, e);
133 }
134 }
135
136 return ARRAY_SIZE(ea);
137}
#define ARRAY_ADD(head, elem)
Add an element at the end of the array.
Definition array.h:157
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:155
The envelope/body of an email.
Definition email.h:39
int index
The absolute (unsorted) message number.
Definition email.h:110
bool tagged
Email is tagged.
Definition email.h:107
int msg_count
Total number of messages.
Definition mailbox.h:90
struct Email ** emails
Array of Emails.
Definition mailbox.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postpone_apply_set_deleted()

static void postpone_apply_set_deleted ( struct Mailbox * m,
struct EmailArray * ea,
bool deleted )
static

Apply the deleted flag to a working set of Emails.

Parameters
mMailbox
eaWorking set of Emails
deletedtrue to mark as deleted, false to undelete

Also updates the postponed message count.

Definition at line 147 of file functions.c.

148{
149 if (!m || !ea)
150 return;
151
152 struct Email **ep = NULL;
153 ARRAY_FOREACH(ep, ea)
154 {
155 if (*ep)
156 mutt_set_flag(m, *ep, MUTT_DELETE, deleted, true);
157 }
158
160 if (mod_data)
161 mod_data->post_count = m->msg_count - m->msg_deleted;
162}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
void mutt_set_flag(struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
Set a flag on an email.
Definition flags.c:54
@ MUTT_DELETE
Messages to be deleted.
Definition mutt.h:94
bool deleted
Email is deleted.
Definition email.h:78
int msg_deleted
Number of deleted messages.
Definition mailbox.h:95
Container for Accounts, Notifications.
Definition neomutt.h:41
short post_count
Number of postponed (draft) emails.
Definition module_data.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ postponed_get_mailbox_view()

struct MailboxView * postponed_get_mailbox_view ( struct MuttWindow * dlg)

Extract the Mailbox from the Postponed Dialog.

Parameters
dlgPostponed Dialog
Return values
ptrMailbox view

Definition at line 337 of file functions.c.

338{
339 if (!dlg)
340 return NULL;
341
342 struct Menu *menu = dlg->wdata;
343 struct PostponeData *pd = menu->mdata;
344 if (!pd)
345 return NULL;
346
347 return pd->mailbox_view;
348}
Definition lib.h:86
void * mdata
Private data.
Definition lib.h:155
void * wdata
Private data.
Data to pass to the Postpone Functions.
Definition functions.h:35
struct MailboxView * mailbox_view
Postponed Mailbox view.
Definition functions.h:36
struct Menu * menu
Postponed Menu.
Definition functions.h:37
+ Here is the caller graph for this function:

Variable Documentation

◆ OpPostponed

const struct MenuFuncOp OpPostponed[]
static
Initial value:
= {
{ "exit", OP_EXIT },
{ "delete-entry", OP_DELETE },
{ "undelete-entry", OP_UNDELETE },
{ "tag-entry", OP_TAG },
{ NULL, 0 },
}

Functions for the Postpone Menu.

Definition at line 49 of file functions.c.

49 { /* map: postpone */
50 { "exit", OP_EXIT },
51 { "delete-entry", OP_DELETE },
52 { "undelete-entry", OP_UNDELETE },
53 { "tag-entry", OP_TAG },
54 { NULL, 0 },
55};

◆ PostponedDefaultBindings

const struct MenuOpSeq PostponedDefaultBindings[]
static
Initial value:
= {
{ OP_DELETE, "d" },
{ OP_EXIT, "q" },
{ OP_TAG, "t" },
{ OP_UNDELETE, "u" },
{ 0, NULL },
}

Key bindings for the Postpone Menu.

Definition at line 60 of file functions.c.

60 { /* map: postpone */
61 { OP_DELETE, "d" },
62 { OP_EXIT, "q" },
63 { OP_TAG, "t" },
64 { OP_UNDELETE, "u" },
65 { 0, NULL },
66};

◆ PostponeFunctions

const struct PostponeFunction PostponeFunctions[]
static
Initial value:
= {
{ OP_DELETE, op_delete },
{ OP_EXIT, op_exit },
{ OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
{ OP_SEARCH, op_search },
{ OP_SEARCH_NEXT, op_search },
{ OP_SEARCH_OPPOSITE, op_search },
{ OP_SEARCH_REVERSE, op_search },
{ OP_UNDELETE, op_delete },
{ 0, NULL },
}
static int op_exit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
exit this menu - Implements alias_function_t -
Definition functions.c:312
static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
delete the current entry - Implements alias_function_t -
Definition functions.c:274
static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
search for a regular expression - Implements alias_function_t -
Definition functions.c:523
static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:392

All the NeoMutt functions that the Postpone supports.

Definition at line 275 of file functions.c.

275 {
276 // clang-format off
277 { OP_DELETE, op_delete },
278 { OP_EXIT, op_exit },
279 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
280 { OP_SEARCH, op_search },
281 { OP_SEARCH_NEXT, op_search },
282 { OP_SEARCH_OPPOSITE, op_search },
283 { OP_SEARCH_REVERSE, op_search },
284 { OP_UNDELETE, op_delete },
285 { 0, NULL },
286 // clang-format on
287};