Thanks to visit codestin.com
Credit goes to code.neomutt.org

NeoMutt  2025-12-11-189-gceedb6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mutt.h File Reference

Many unsorted constants and some structs. More...

#include "config.h"
#include "mutt.h"
#include "menu/lib.h"
#include <limits.h>
#include <stdbool.h>
+ Include dependency graph for mutt.h:

Go to the source code of this file.

Macros

#define PATH_MAX   4096
 

Enumerations

enum  XdgType { XDG_CONFIG_HOME , XDG_CONFIG_DIRS }
 XDG variable types. More...
 
enum  EvMessage { EVM_VIEW , EVM_EDIT }
 Edit or View a message. More...
 
enum  MessageType {
  MUTT_ALL = 1 , MUTT_NONE , MUTT_NEW , MUTT_OLD ,
  MUTT_REPLIED , MUTT_READ , MUTT_UNREAD , MUTT_DELETE ,
  MUTT_UNDELETE , MUTT_PURGE , MUTT_DELETED , MUTT_FLAG ,
  MUTT_TAG , MUTT_UNTAG , MUTT_LIMIT , MUTT_EXPIRED ,
  MUTT_SUPERSEDED , MUTT_TRASH , MUTT_MT_MAX
}
 To set flags or match patterns. More...
 

Functions

int mutt_ev_message (struct Mailbox *m, struct EmailArray *ea, enum EvMessage action)
 Edit or view a message.
 
int mutt_system (const char *cmd)
 Run an external command.
 
int mutt_set_xdg_path (enum XdgType type, struct Buffer *buf)
 Find an XDG path or its fallback.
 
void mutt_help (enum MenuType menu)
 Display the Help Page.
 
void mutt_set_flag (struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool upd_mbox)
 Set a flag on an email.
 
void mutt_signal_init (void)
 Initialise the signal handling.
 
void mutt_emails_set_flag (struct Mailbox *m, struct EmailArray *ea, enum MessageType flag, bool bf)
 Set flag on messages.
 
int mw_change_flag (struct Mailbox *m, struct EmailArray *ea, bool bf)
 Change the flag on a Message -.
 
int mutt_thread_set_flag (struct Mailbox *m, struct Email *e, enum MessageType flag, bool bf, bool subthread)
 Set a flag on an entire thread.
 
int mutt_reply_observer (struct NotifyCallback *nc)
 

Variables

bool StartupComplete
 When the config has been read.
 
short PostCount
 Number of postponed (draft) emails.
 

Detailed Description

Many unsorted constants and some structs.

Authors
  • Michael R. Elkins
  • g10 Code GmbH
  • 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 mutt.h.

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   4096

Definition at line 49 of file mutt.h.

Enumeration Type Documentation

◆ XdgType

enum XdgType

XDG variable types.

Enumerator
XDG_CONFIG_HOME 

XDG home dir: ~/.config.

XDG_CONFIG_DIRS 

XDG system dir: /etc/xdg.

Definition at line 65 of file mutt.h.

66{
69};
@ XDG_CONFIG_HOME
XDG home dir: ~/.config.
Definition mutt.h:67
@ XDG_CONFIG_DIRS
XDG system dir: /etc/xdg.
Definition mutt.h:68

◆ EvMessage

enum EvMessage

Edit or View a message.

Enumerator
EVM_VIEW 

View the message.

EVM_EDIT 

Edit the message.

Definition at line 74 of file mutt.h.

75{
76 EVM_VIEW,
77 EVM_EDIT,
78};
@ EVM_VIEW
View the message.
Definition mutt.h:76
@ EVM_EDIT
Edit the message.
Definition mutt.h:77

◆ MessageType

To set flags or match patterns.

See also
mutt_set_flag(), mutt_pattern_func()
Enumerator
MUTT_ALL 

All messages.

MUTT_NONE 

No messages.

MUTT_NEW 

New messages.

MUTT_OLD 

Old messages.

MUTT_REPLIED 

Messages that have been replied to.

MUTT_READ 

Messages that have been read.

MUTT_UNREAD 

Unread messages.

MUTT_DELETE 

Messages to be deleted.

MUTT_UNDELETE 

Messages to be un-deleted.

MUTT_PURGE 

Messages to be purged (bypass trash)

MUTT_DELETED 

Deleted messages.

MUTT_FLAG 

Flagged messages.

MUTT_TAG 

Tagged messages.

MUTT_UNTAG 

Messages to be un-tagged.

MUTT_LIMIT 

Messages in limited view.

MUTT_EXPIRED 

Expired messages.

MUTT_SUPERSEDED 

Superseded messages.

MUTT_TRASH 

Trashed messages.

MUTT_MT_MAX 

Definition at line 85 of file mutt.h.

86{
87 MUTT_ALL = 1,
88 MUTT_NONE,
89 MUTT_NEW,
90 MUTT_OLD,
92 MUTT_READ,
98 MUTT_FLAG,
99 MUTT_TAG,
100 MUTT_UNTAG,
101 MUTT_LIMIT,
104 MUTT_TRASH,
105
107};
@ MUTT_ALL
All messages.
Definition mutt.h:87
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition mutt.h:95
@ MUTT_TRASH
Trashed messages.
Definition mutt.h:104
@ MUTT_LIMIT
Messages in limited view.
Definition mutt.h:101
@ MUTT_UNTAG
Messages to be un-tagged.
Definition mutt.h:100
@ MUTT_SUPERSEDED
Superseded messages.
Definition mutt.h:103
@ MUTT_EXPIRED
Expired messages.
Definition mutt.h:102
@ MUTT_MT_MAX
Definition mutt.h:106
@ MUTT_READ
Messages that have been read.
Definition mutt.h:92
@ MUTT_OLD
Old messages.
Definition mutt.h:90
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition mutt.h:96
@ MUTT_NONE
No messages.
Definition mutt.h:88
@ MUTT_TAG
Tagged messages.
Definition mutt.h:99
@ MUTT_FLAG
Flagged messages.
Definition mutt.h:98
@ MUTT_DELETED
Deleted messages.
Definition mutt.h:97
@ MUTT_DELETE
Messages to be deleted.
Definition mutt.h:94
@ MUTT_NEW
New messages.
Definition mutt.h:89
@ MUTT_UNREAD
Unread messages.
Definition mutt.h:93
@ MUTT_REPLIED
Messages that have been replied to.
Definition mutt.h:91

Function Documentation

◆ mutt_ev_message()

int mutt_ev_message ( struct Mailbox * m,
struct EmailArray * ea,
enum EvMessage action )

Edit or view a message.

Parameters
mMailbox
eaArray of Emails
actionAction to perform, e.g. EVM_EDIT
Return values
1Message not modified
0Message edited successfully
-1Error

Definition at line 282 of file editmsg.c.

283{
284 struct Email **ep = NULL;
285 ARRAY_FOREACH(ep, ea)
286 {
287 struct Email *e = *ep;
288 if (ev_message(action, m, e) == -1)
289 return -1;
290 }
291
292 return 0;
293}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e)
Edit an email or view it in an external editor.
Definition editmsg.c:57
The envelope/body of an email.
Definition email.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_system()

int mutt_system ( const char * cmd)

Run an external command.

Parameters
cmdCommand and arguments
Return values
-1Error
>=0Success (command's return code)

Fork and run an external command with arguments.

Note
This function won't return until the command finishes.

Definition at line 51 of file system.c.

52{
53 int rc = -1;
54 struct sigaction act = { 0 };
55 struct sigaction oldtstp = { 0 };
56 struct sigaction oldcont = { 0 };
57 pid_t pid;
58
59 if (!cmd || (*cmd == '\0'))
60 return 0;
61
62 /* must ignore SIGINT and SIGQUIT */
63
65
66 act.sa_handler = SIG_DFL;
67/* we want to restart the waitpid() below */
68#ifdef SA_RESTART
69 act.sa_flags = SA_RESTART;
70#endif
71 sigemptyset(&act.sa_mask);
72 sigaction(SIGTSTP, &act, &oldtstp);
73 sigaction(SIGCONT, &act, &oldcont);
74
75 pid = fork();
76 if (pid == 0)
77 {
78 act.sa_flags = 0;
79
82
83 execle(EXEC_SHELL, "sh", "-c", cmd, NULL, NeoMutt->env);
84 _exit(127); /* execl error */
85 }
86 else if (pid != -1)
87 {
88 rc = imap_wait_keep_alive(pid);
89 }
90
91 sigaction(SIGCONT, &oldcont, NULL);
92 sigaction(SIGTSTP, &oldtstp, NULL);
93
94 /* reset SIGINT, SIGQUIT and SIGCHLD */
96
97 rc = (pid != -1) ? (WIFEXITED(rc) ? WEXITSTATUS(rc) : -1) : -1;
98
99 return rc;
100}
int imap_wait_keep_alive(pid_t pid)
Wait for a process to change state.
Definition util.c:1021
#define EXEC_SHELL
Definition filter.h:29
void mutt_sig_reset_child_signals(void)
Reset ignored signals back to the default.
Definition signal.c:336
void mutt_sig_block_system(void)
Block signals before calling exec()
Definition signal.c:260
void mutt_sig_unblock_system(bool restore)
Restore previously blocked signals.
Definition signal.c:284
Container for Accounts, Notifications.
Definition neomutt.h:128
char ** env
Private copy of the environment variables.
Definition neomutt.h:143
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_set_xdg_path()

int mutt_set_xdg_path ( enum XdgType type,
struct Buffer * buf )

Find an XDG path or its fallback.

Parameters
typeType of XDG variable, e.g. XDG_CONFIG_HOME
bufBuffer to save path
Return values
1An entry was found that actually exists on disk and 0 otherwise

Process an XDG environment variable or its fallback.

Definition at line 871 of file muttlib.c.

872{
873 const char *xdg_env = mutt_str_getenv(XdgEnvVars[type]);
874 char *xdg = xdg_env ? mutt_str_dup(xdg_env) : mutt_str_dup(XdgDefaults[type]);
875 char *x = xdg; /* mutt_str_sep() changes xdg, so free x instead later */
876 char *token = NULL;
877 int rc = 0;
878
879 while ((token = mutt_str_sep(&xdg, ":")))
880 {
881 if (buf_printf(buf, "%s/%s/neomuttrc", token, PACKAGE) < 0)
882 continue;
883 expand_path(buf, false);
884 if (access(buf_string(buf), F_OK) == 0)
885 {
886 rc = 1;
887 break;
888 }
889
890 if (buf_printf(buf, "%s/%s/Muttrc", token, PACKAGE) < 0)
891 continue;
892 expand_path(buf, false);
893 if (access(buf_string(buf), F_OK) == 0)
894 {
895 rc = 1;
896 break;
897 }
898 }
899
900 FREE(&x);
901 return rc;
902}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
#define FREE(x)
Definition memory.h:63
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
const char * mutt_str_getenv(const char *name)
Get an environment variable.
Definition string.c:728
char * mutt_str_sep(char **stringp, const char *delim)
Find first occurrence of any of delim characters in *stringp.
Definition string.c:190
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
Definition muttlib.c:121
static const char * XdgEnvVars[]
Accepted XDG environment variables.
Definition muttlib.c:64
static const char * XdgDefaults[]
XDG default locations.
Definition muttlib.c:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_help()

void mutt_help ( enum MenuType menu)

Display the Help Page.

Parameters
menuMenu type

Definition at line 147 of file help.c.

148{
149 struct BindingInfoArray bia_bind = ARRAY_HEAD_INITIALIZER;
150 struct BindingInfoArray bia_macro = ARRAY_HEAD_INITIALIZER;
151 struct BindingInfoArray bia_unbound = ARRAY_HEAD_INITIALIZER;
152 struct Buffer *banner = NULL;
153 struct Buffer *tempfile = NULL;
154 struct BindingInfo *bi = NULL;
155
156 // ---------------------------------------------------------------------------
157 // Gather the data
158
159 gather_menu(menu, &bia_bind, &bia_macro, false);
160
161 ARRAY_SORT(&bia_bind, binding_sort, NULL);
162 ARRAY_SORT(&bia_macro, binding_sort, NULL);
163
164 int wb0 = measure_column(&bia_bind, 0);
165 int wb1 = measure_column(&bia_bind, 1);
166
167 const int wm0 = measure_column(&bia_macro, 0);
168
169 gather_unbound(menu, &bia_unbound);
170
171 ARRAY_SORT(&bia_unbound, binding_sort, NULL);
172 const int wu1 = measure_column(&bia_unbound, 1);
173
174 // ---------------------------------------------------------------------------
175 // Save the data to a file
176
177 tempfile = buf_pool_get();
178 buf_mktemp(tempfile);
179 FILE *fp = mutt_file_fopen(buf_string(tempfile), "w");
180 if (!fp)
181 {
182 mutt_perror("%s", buf_string(tempfile));
183 goto cleanup;
184 }
185
186 const char *menu_name = NULL;
187 ARRAY_FOREACH(bi, &bia_bind)
188 {
189 if (!bi->a[0])
190 {
191 menu_name = bi->a[2];
192 continue;
193 }
194
195 if (menu_name)
196 {
197 if (ARRAY_FOREACH_IDX_bi > 0)
198 fprintf(fp, "\n");
199
200 fprintf(fp, "%s bindings\n", menu_name);
201 fprintf(fp, "\n");
202 menu_name = NULL;
203 }
204
205 // key text description
206 fprintf(fp, "%*s %*s %s\n", -wb0, bi->a[0], -wb1, bi->a[1], bi->a[2]);
207 }
208
209 ARRAY_FOREACH(bi, &bia_macro)
210 {
211 if (!bi->a[0])
212 {
213 menu_name = bi->a[2];
214 continue;
215 }
216
217 if (menu_name)
218 {
219 if (ARRAY_FOREACH_IDX_bi > 0)
220 fprintf(fp, "\n");
221
222 fprintf(fp, "%s macros\n", menu_name);
223 fprintf(fp, "\n");
224 menu_name = NULL;
225 }
226
227 if (bi->a[2]) // description
228 {
229 // key description, macro-text, blank line
230 fprintf(fp, "%*s %s\n", -wm0, bi->a[0], bi->a[2]);
231 fprintf(fp, "%s\n", bi->a[1]);
232 fprintf(fp, "\n");
233 }
234 else
235 {
236 // key macro-text
237 fprintf(fp, "%*s %s\n", -wm0, bi->a[0], bi->a[1]);
238 }
239 }
240 fprintf(fp, "\n");
241
242 fprintf(fp, "unbound functions\n");
243 fprintf(fp, "\n");
244 ARRAY_FOREACH(bi, &bia_unbound)
245 {
246 // function description
247 fprintf(fp, "%*s %s\n", -wu1, bi->a[1], bi->a[2]);
248 }
249
250 dump_message_flags(menu, fp);
251 mutt_file_fclose(&fp);
252
253 // ---------------------------------------------------------------------------
254 // Display data
255
256 struct PagerData pdata = { 0 };
257 struct PagerView pview = { &pdata };
258
259 pview.mode = PAGER_MODE_HELP;
261
263 menu_name = km_get_menu_name(menu);
264 buf_printf(banner, _("Help for %s"), menu_name);
265 pdata.fname = buf_string(tempfile);
266 pview.banner = buf_string(banner);
267 mutt_do_pager(&pview, NULL);
268
269cleanup:
270
271 ARRAY_FOREACH(bi, &bia_bind)
272 {
273 FREE(&bi->a[0]);
274 }
275
276 ARRAY_FOREACH(bi, &bia_macro)
277 {
278 FREE(&bi->a[0]);
279 FREE(&bi->a[1]);
280 }
281
283 buf_pool_release(&tempfile);
284 ARRAY_FREE(&bia_bind);
285 ARRAY_FREE(&bia_macro);
286 ARRAY_FREE(&bia_unbound);
287}
#define ARRAY_SORT(head, fn, sdata)
Sort an array.
Definition array.h:373
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition do_pager.c:122
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
#define mutt_perror(...)
Definition logging2.h:95
int binding_sort(const void *a, const void *b, void *sdata)
Compare two BindingInfo by their keybinding - Implements sort_t -.
Definition dump.c:237
static void dump_message_flags(enum MenuType menu, FILE *fp)
Write out all the message flags.
Definition help.c:103
int measure_column(struct BindingInfoArray *bia, int col)
Measure one column of a table.
Definition dump.c:423
void gather_menu(enum MenuType menu, struct BindingInfoArray *bia_bind, struct BindingInfoArray *bia_macro, bool one_submenu)
Gather info about one menu.
Definition dump.c:342
int gather_unbound(enum MenuType mtype, struct BindingInfoArray *bia_unbound)
Gather info about unbound functions for one menu.
Definition dump.c:443
const char * km_get_menu_name(int mtype)
Get the name of a Menu.
Definition menu.c:195
#define _(a)
Definition message.h:28
#define MUTT_PAGER_NOWRAP
Format for term width, ignore $wrap.
Definition lib.h:73
#define MUTT_PAGER_STRIPES
Striped highlighting.
Definition lib.h:76
#define MUTT_PAGER_MARKER
Use markers if option is set.
Definition lib.h:71
@ PAGER_MODE_HELP
Pager is invoked via 3rd path to show help.
Definition lib.h:141
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
Info about one keybinding.
Definition dump.h:41
const char * a[3]
Array of info.
Definition dump.h:43
String manipulation buffer.
Definition buffer.h:36
Data to be displayed by PagerView.
Definition lib.h:161
const char * fname
Name of the file to read.
Definition lib.h:165
Paged view into some data.
Definition lib.h:172
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:173
enum PagerMode mode
Pager mode.
Definition lib.h:174
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:175
const char * banner
Title to display in status bar.
Definition lib.h:176
#define buf_mktemp(buf)
Definition tmp.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_set_flag()

void mutt_set_flag ( struct Mailbox * m,
struct Email * e,
enum MessageType flag,
bool bf,
bool upd_mbox )

Set a flag on an email.

Parameters
mMailbox
eEmail
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag
upd_mboxtrue: update the Mailbox

Definition at line 54 of file flags.c.

56{
57 if (!m || !e)
58 return;
59
60 bool changed = e->changed;
61 int deleted = m->msg_deleted;
62 int tagged = m->msg_tagged;
63 int flagged = m->msg_flagged;
64 int update = false;
65
66 if (m->readonly && (flag != MUTT_TAG))
67 return; /* don't modify anything if we are read-only */
68
69 switch (flag)
70 {
71 case MUTT_DELETE:
72 {
73 if (!(m->rights & MUTT_ACL_DELETE))
74 return;
75
76 if (bf)
77 {
78 const bool c_flag_safe = cs_subset_bool(NeoMutt->sub, "flag_safe");
79 if (!e->deleted && !m->readonly && (!e->flagged || !c_flag_safe))
80 {
81 e->deleted = true;
82 update = true;
83 if (upd_mbox)
84 m->msg_deleted++;
85 /* deleted messages aren't treated as changed elsewhere so that the
86 * purge-on-sync option works correctly. This isn't applicable here */
87 if (m->type == MUTT_IMAP)
88 {
89 e->changed = true;
90 if (upd_mbox)
91 m->changed = true;
92 }
93 }
94 }
95 else if (e->deleted)
96 {
97 e->deleted = false;
98 update = true;
99 if (upd_mbox)
100 m->msg_deleted--;
101 /* see my comment above */
102 if (m->type == MUTT_IMAP)
103 {
104 e->changed = true;
105 if (upd_mbox)
106 m->changed = true;
107 }
108 /* If the user undeletes a message which is marked as
109 * "trash" in the maildir folder on disk, the folder has
110 * been changed, and is marked accordingly. However, we do
111 * _not_ mark the message itself changed, because trashing
112 * is checked in specific code in the maildir folder
113 * driver. */
114 if ((m->type == MUTT_MAILDIR) && upd_mbox && e->trash)
115 m->changed = true;
116 }
117 break;
118 }
119 case MUTT_PURGE:
120 {
121 if (!(m->rights & MUTT_ACL_DELETE))
122 return;
123
124 if (bf)
125 {
126 if (!e->purge && !m->readonly)
127 e->purge = true;
128 }
129 else if (e->purge)
130 {
131 e->purge = false;
132 }
133 break;
134 }
135 case MUTT_NEW:
136 {
137 if (!(m->rights & MUTT_ACL_SEEN))
138 return;
139
140 if (bf)
141 {
142 if (e->read || e->old)
143 {
144 update = true;
145 e->old = false;
146 if (upd_mbox)
147 m->msg_new++;
148 if (e->read)
149 {
150 e->read = false;
151 if (upd_mbox)
152 m->msg_unread++;
153 }
154 e->changed = true;
155 if (upd_mbox)
156 m->changed = true;
157 }
158 }
159 else if (!e->read)
160 {
161 update = true;
162 if (!e->old)
163 if (upd_mbox)
164 m->msg_new--;
165 e->read = true;
166 if (upd_mbox)
167 m->msg_unread--;
168 e->changed = true;
169 if (upd_mbox)
170 m->changed = true;
171 }
172 break;
173 }
174 case MUTT_OLD:
175 {
176 if (!(m->rights & MUTT_ACL_SEEN))
177 return;
178
179 if (bf)
180 {
181 if (!e->old)
182 {
183 update = true;
184 e->old = true;
185 if (!e->read)
186 if (upd_mbox)
187 m->msg_new--;
188 e->changed = true;
189 if (upd_mbox)
190 m->changed = true;
191 }
192 }
193 else if (e->old)
194 {
195 update = true;
196 e->old = false;
197 if (!e->read)
198 if (upd_mbox)
199 m->msg_new++;
200 e->changed = true;
201 if (upd_mbox)
202 m->changed = true;
203 }
204 break;
205 }
206 case MUTT_READ:
207 {
208 if (!(m->rights & MUTT_ACL_SEEN))
209 return;
210
211 if (bf)
212 {
213 if (!e->read)
214 {
215 update = true;
216 e->read = true;
217 if (upd_mbox)
218 m->msg_unread--;
219 if (!e->old)
220 if (upd_mbox)
221 m->msg_new--;
222 e->changed = true;
223 if (upd_mbox)
224 m->changed = true;
225 }
226 }
227 else if (e->read)
228 {
229 update = true;
230 e->read = false;
231 if (upd_mbox)
232 m->msg_unread++;
233 if (!e->old)
234 if (upd_mbox)
235 m->msg_new++;
236 e->changed = true;
237 if (upd_mbox)
238 m->changed = true;
239 }
240 break;
241 }
242 case MUTT_REPLIED:
243 {
244 if (!(m->rights & MUTT_ACL_WRITE))
245 return;
246
247 if (bf)
248 {
249 if (!e->replied)
250 {
251 update = true;
252 e->replied = true;
253 if (!e->read)
254 {
255 e->read = true;
256 if (upd_mbox)
257 m->msg_unread--;
258 if (!e->old)
259 if (upd_mbox)
260 m->msg_new--;
261 }
262 e->changed = true;
263 if (upd_mbox)
264 m->changed = true;
265 }
266 }
267 else if (e->replied)
268 {
269 update = true;
270 e->replied = false;
271 e->changed = true;
272 if (upd_mbox)
273 m->changed = true;
274 }
275 break;
276 }
277 case MUTT_FLAG:
278 {
279 if (!(m->rights & MUTT_ACL_WRITE))
280 return;
281
282 if (bf)
283 {
284 if (!e->flagged)
285 {
286 update = true;
287 e->flagged = bf;
288 if (upd_mbox)
289 m->msg_flagged++;
290 e->changed = true;
291 if (upd_mbox)
292 m->changed = true;
293 }
294 }
295 else if (e->flagged)
296 {
297 update = true;
298 e->flagged = false;
299 if (upd_mbox)
300 m->msg_flagged--;
301 e->changed = true;
302 if (upd_mbox)
303 m->changed = true;
304 }
305 break;
306 }
307 case MUTT_TAG:
308 {
309 if (bf)
310 {
311 if (!e->tagged)
312 {
313 update = true;
314 e->tagged = true;
315 if (upd_mbox)
316 m->msg_tagged++;
317 }
318 }
319 else if (e->tagged)
320 {
321 update = true;
322 e->tagged = false;
323 if (upd_mbox)
324 m->msg_tagged--;
325 }
326 break;
327 }
328 default:
329 {
330 break;
331 }
332 }
333
334 if (update)
335 {
336 email_set_color(m, e);
337 struct EventMailbox ev_m = { m };
339 }
340
341 /* if the message status has changed, we need to invalidate the cached
342 * search results so that any future search will match the current status
343 * of this message and not what it was at the time it was last searched. */
344 if (e->searched && ((changed != e->changed) || (deleted != m->msg_deleted) ||
345 (tagged != m->msg_tagged) || (flagged != m->msg_flagged)))
346 {
347 e->searched = false;
348 }
349}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:176
#define MUTT_ACL_DELETE
Delete a message.
Definition mailbox.h:63
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition mailbox.h:71
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:50
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition mailbox.h:48
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition mailbox.h:70
void email_set_color(struct Mailbox *m, struct Email *e)
Select an Index colour for an Email.
Definition dlg_index.c:1404
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
bool searched
Email has been searched.
Definition email.h:105
bool read
Email is read.
Definition email.h:50
bool purge
Skip trash folder when deleting.
Definition email.h:79
bool old
Email is seen, but unread.
Definition email.h:49
bool changed
Email has been edited.
Definition email.h:77
bool flagged
Marked important?
Definition email.h:47
bool replied
Email has been replied to.
Definition email.h:51
bool deleted
Email is deleted.
Definition email.h:78
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
Definition email.h:53
bool tagged
Email is tagged.
Definition email.h:107
An Event that happened to a Mailbox.
Definition mailbox.h:190
bool changed
Mailbox has been modified.
Definition mailbox.h:110
int msg_new
Number of new messages.
Definition mailbox.h:92
AclFlags rights
ACL bits, see AclFlags.
Definition mailbox.h:119
enum MailboxType type
Mailbox type.
Definition mailbox.h:102
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:145
int msg_deleted
Number of deleted messages.
Definition mailbox.h:93
int msg_flagged
Number of flagged messages.
Definition mailbox.h:90
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:116
int msg_tagged
How many messages are tagged?
Definition mailbox.h:94
int msg_unread
Number of unread messages.
Definition mailbox.h:89
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_signal_init()

void mutt_signal_init ( void )

Initialise the signal handling.

Definition at line 134 of file mutt_signal.c.

135{
137}
static void curses_signal_handler(int sig)
Catch signals and relay the info to the main program - Implements sig_handler_t -.
Definition mutt_signal.c:50
static void curses_segv_handler(int sig)
Catch a segfault and print a backtrace - Implements sig_handler_t -.
static void curses_exit_handler(int sig)
Notify the user and shutdown gracefully - Implements sig_handler_t -.
Definition mutt_signal.c:94
void mutt_sig_init(sig_handler_t sig_fn, sig_handler_t exit_fn, sig_handler_t segv_fn)
Initialise the signal handling.
Definition signal.c:163
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_emails_set_flag()

void mutt_emails_set_flag ( struct Mailbox * m,
struct EmailArray * ea,
enum MessageType flag,
bool bf )

Set flag on messages.

Parameters
mMailbox
eaArray of Emails to flag
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag

Definition at line 358 of file flags.c.

360{
361 if (!m || !ea || ARRAY_EMPTY(ea))
362 return;
363
364 struct Email **ep = NULL;
365 ARRAY_FOREACH(ep, ea)
366 {
367 struct Email *e = *ep;
368 mutt_set_flag(m, e, flag, bf, true);
369 }
370}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_thread_set_flag()

int mutt_thread_set_flag ( struct Mailbox * m,
struct Email * e,
enum MessageType flag,
bool bf,
bool subthread )

Set a flag on an entire thread.

Parameters
mMailbox
eEmail
flagFlag to set, e.g. MUTT_DELETE
bftrue: set the flag; false: clear the flag
subthreadIf true apply to all of the thread
Return values
0Success
-1Failure

Definition at line 382 of file flags.c.

384{
385 struct MuttThread *start = NULL;
386 struct MuttThread *cur = e->thread;
387
388 if (!mutt_using_threads())
389 {
390 mutt_error(_("Threading is not enabled"));
391 return -1;
392 }
393
394 if (!subthread)
395 while (cur->parent)
396 cur = cur->parent;
397
398 start = cur;
399
400 if (cur->message && (cur != e->thread))
401 mutt_set_flag(m, cur->message, flag, bf, true);
402
403 cur = cur->child;
404 if (!cur)
405 goto done;
406
407 while (true)
408 {
409 if (cur->message && (cur != e->thread))
410 mutt_set_flag(m, cur->message, flag, bf, true);
411
412 if (cur->child)
413 {
414 cur = cur->child;
415 }
416 else if (cur->next)
417 {
418 cur = cur->next;
419 }
420 else
421 {
422 while (!cur->next)
423 {
424 cur = cur->parent;
425 if (cur == start)
426 goto done;
427 }
428 cur = cur->next;
429 }
430 }
431done:
432 cur = e->thread;
433 if (cur->message)
434 mutt_set_flag(m, cur->message, flag, bf, true);
435 return 0;
436}
#define mutt_error(...)
Definition logging2.h:94
#define mutt_using_threads()
Definition thread.h:113
struct MuttThread * thread
Thread of Emails.
Definition email.h:119
An Email conversation.
Definition thread.h:34
struct MuttThread * parent
Parent of this Thread.
Definition thread.h:44
struct MuttThread * child
Child of this Thread.
Definition thread.h:45
struct Email * message
Email this Thread refers to.
Definition thread.h:49
struct MuttThread * next
Next sibling Thread.
Definition thread.h:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_reply_observer()

int mutt_reply_observer ( struct NotifyCallback * nc)

Variable Documentation

◆ StartupComplete

bool StartupComplete
extern

When the config has been read.

Definition at line 12 of file address.c.

◆ PostCount

short PostCount
extern

Number of postponed (draft) emails.

Definition at line 55 of file postpone.c.