NeoMutt  2025-12-11-980-ge38c27
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 postpone_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_quit (struct PostponeData *pd, const struct KeyEvent *event)
 Save changes and exit this dialog - 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 MailboxViewpostpone_get_mailbox_view (struct MuttWindow *dlg)
 Extract the Mailbox from the Postponed Dialog.
 

Variables

static const struct MenuFuncOp OpPostpone []
 Functions for the Postpone Menu.
 
static const struct MenuOpSeq PostponeDefaultBindings []
 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

◆ postpone_init_keys()

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

Initialise the Postponed Keybindings - Implements ::init_keys_api.

Definition at line 69 of file functions.c.

70{
71 struct MenuDefinition *md = NULL;
72 struct SubMenu *sm = NULL;
73
75 md = km_register_menu(MENU_POSTPONE, "postpone");
76 km_menu_add_submenu(md, sm);
77 km_menu_add_submenu(md, sm_generic);
79
81 ASSERT(mod_data);
82 mod_data->menu_postpone = md;
83}
void km_menu_add_submenu(struct MenuDefinition *md, struct SubMenu *sm)
Add a SubMenu to a Menu Definition.
Definition init.c:123
struct SubMenu * km_register_submenu(const struct MenuFuncOp functions[])
Register a submenu.
Definition init.c:88
struct MenuDefinition * km_register_menu(int menu, const char *name)
Register a menu.
Definition init.c:105
void km_menu_add_bindings(struct MenuDefinition *md, const struct MenuOpSeq bindings[])
Add Keybindings to a Menu.
Definition init.c:136
@ MODULE_ID_POSTPONE
ModulePostpone, Postponed Emails
Definition module_api.h:89
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
static const struct MenuFuncOp OpPostpone[]
Functions for the Postpone Menu.
Definition functions.c:49
static const struct MenuOpSeq PostponeDefaultBindings[]
Key bindings for the Postpone Menu.
Definition functions.c:58
#define ASSERT(COND)
Definition signal2.h:59
Functions for a Dialog or Window.
Definition menudef.h:44
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 menudef.h:33
@ MENU_POSTPONE
Select a postponed email.
Definition type.h:49
+ 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 100 of file functions.c.

102{
103 if (!ea || !menu || !m || !m->emails)
104 return 0;
105
106 if (tagged)
107 {
108 for (int i = 0; i < m->msg_count; i++)
109 {
110 struct Email *e = m->emails[i];
111 if (e && e->tagged)
112 ARRAY_ADD(ea, e);
113 }
114 }
115 else
116 {
117 const int index = menu_get_index(menu);
118 if ((index < 0) || (index >= m->msg_count))
119 return 0;
120
121 int n = (count > 1) ? count : 1;
122 if ((index + n) > m->msg_count)
123 n = m->msg_count - index;
124
125 for (int i = 0; i < n; i++)
126 {
127 struct Email *e = m->emails[index + i];
128 if (e)
129 ARRAY_ADD(ea, e);
130 }
131 }
132
133 return ARRAY_SIZE(ea);
134}
#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:153
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 144 of file functions.c.

145{
146 if (!m || !ea)
147 return;
148
149 struct Email **ep = NULL;
150 ARRAY_FOREACH(ep, ea)
151 {
152 if (*ep)
153 mutt_set_flag(m, *ep, MUTT_DELETE, deleted, true);
154 }
155
157 if (mod_data)
158 mod_data->post_count = m->msg_count - m->msg_deleted;
159}
#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:

◆ postpone_get_mailbox_view()

struct MailboxView * postpone_get_mailbox_view ( struct MuttWindow * dlg)

Extract the Mailbox from the Postponed Dialog.

Parameters
dlgPostponed Dialog
Return values
ptrMailbox view

Definition at line 330 of file functions.c.

331{
332 if (!dlg)
333 return NULL;
334
335 struct Menu *menu = dlg->wdata;
336 struct PostponeData *pd = menu->mdata;
337 if (!pd)
338 return NULL;
339
340 return pd->mailbox_view;
341}
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

◆ OpPostpone

const struct MenuFuncOp OpPostpone[]
static
Initial value:
= {
{ "delete-entry", OP_DELETE },
{ "undelete-entry", OP_UNDELETE },
{ NULL, 0 },
}

Functions for the Postpone Menu.

Definition at line 49 of file functions.c.

49 { /* map: postpone */
50 { "delete-entry", OP_DELETE },
51 { "undelete-entry", OP_UNDELETE },
52 { NULL, 0 },
53};

◆ PostponeDefaultBindings

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

Key bindings for the Postpone Menu.

Definition at line 58 of file functions.c.

58 { /* map: postpone */
59 { OP_DELETE, "d" },
60 { OP_TAG, "t" },
61 { OP_UNDELETE, "u" },
62 { 0, NULL },
63};

◆ PostponeFunctions

const struct PostponeFunction PostponeFunctions[]
static
Initial value:
= {
{ OP_DELETE, op_delete },
{ OP_EXIT, op_quit },
{ OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
{ OP_QUIT, op_quit },
{ 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_quit(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Save changes and exit this dialog - Implements alias_function_t -.
Definition functions.c:308
static int op_delete(struct AliasFunctionData *fdata, const struct KeyEvent *event)
delete the current entry - Implements alias_function_t -
Definition functions.c:270
static int op_search(struct AliasFunctionData *fdata, const struct KeyEvent *event)
search for a regular expression - Implements alias_function_t -
Definition functions.c:519
static int op_generic_select_entry(struct AliasFunctionData *fdata, const struct KeyEvent *event)
select the current entry - Implements alias_function_t -
Definition functions.c:388

All the NeoMutt functions that the Postpone supports.

Definition at line 267 of file functions.c.

267 {
268 // clang-format off
269 { OP_DELETE, op_delete },
270 { OP_EXIT, op_quit },
271 { OP_GENERIC_SELECT_ENTRY, op_generic_select_entry },
272 { OP_QUIT, op_quit },
273 { OP_SEARCH, op_search },
274 { OP_SEARCH_NEXT, op_search },
275 { OP_SEARCH_OPPOSITE, op_search },
276 { OP_SEARCH_REVERSE, op_search },
277 { OP_UNDELETE, op_delete },
278 { 0, NULL },
279 // clang-format on
280};