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

Compose functions. More...

#include "config.h"
#include <errno.h>
#include <stdbool.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "conn/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "functions.h"
#include "lib.h"
#include "attach/lib.h"
#include "browser/lib.h"
#include "editor/lib.h"
#include "expando/lib.h"
#include "history/lib.h"
#include "hooks/lib.h"
#include "imap/lib.h"
#include "index/lib.h"
#include "key/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "nntp/lib.h"
#include "pop/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "attach_data.h"
#include "external.h"
#include "globals.h"
#include "module_data.h"
#include "mutt_logging.h"
#include "muttlib.h"
#include "mx.h"
#include "nntp/adata.h"
#include "shared_data.h"
#include <libintl.h>
Include dependency graph for functions.c:

Go to the source code of this file.

Data Structures

struct  SpellingCommandData
 Data for the spelling command. More...

Functions

void compose_init_keys (struct NeoMutt *n, struct SubMenu *sm_generic)
 Initialise the Compose Keybindings - Implements ::init_keys_api.
static bool check_count (struct AttachCtx *actx)
 Check if there are any attachments.
static char * gen_cid (void)
 Generate a random Content ID.
static bool check_cid (const char *cid)
 Check if a Content-ID is valid.
static bool content_id_exists (struct AttachCtx *actx, const struct Body *skip, const char *cid)
 Check whether a Content-ID is already in use.
static int check_attachments (struct AttachCtx *actx, struct ConfigSubset *sub)
 Check if any attachments have changed or been deleted.
static int delete_attachment (struct AttachCtx *actx, int aidx, struct ConfigSubset *sub)
 Delete an attachment.
static void update_idx (struct Menu *menu, struct AttachCtx *actx, struct AttachPtr *ap)
 Add a new attachment to the message.
static void compose_attach_swap (struct Email *e, struct AttachCtx *actx, int first, int second)
 Swap two adjacent entries in the attachment list.
static int body_index (struct AttachCtx *actx, const struct Body *b)
 Find the index of an attachment body.
static int prev_sibling (struct AttachCtx *actx, int index)
 Find the previous sibling of an attachment.
static int next_sibling (struct AttachCtx *actx, int index)
 Find the next sibling of an attachment.
static bool body_array_contains (struct BodyArray *ba, const struct Body *b)
 Does a selection contain a body?
static bool selected_attachments_are_siblings (struct Email *e, struct BodyArray *ba)
 Check whether selected attachments are siblings.
static MenuRedrawFlags selection_redraw_flags (size_t count)
 Choose redraw flags for a selection.
static void resolve_attachment (struct Menu *menu, const struct ConfigSubset *sub, int index, int num)
 Advance the Attachment List selection after an action.
static int move_attachment (struct ComposeSharedData *shared, bool up, int count)
 Move attachments in the attachment list.
static int group_attachments (struct ComposeSharedData *shared, char *subtype, struct BodyArray *ba)
 Group selected attachments into a multipart group.
static int op_attach_attach_file (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Attach files to this message - Implements compose_function_t -.
static int op_attach_attach_key (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Attach a PGP public key - Implements compose_function_t -.
static int op_attach_attach_message (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Attach messages to this message - Implements compose_function_t -.
static int op_attach_detach (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Delete the current entry - Implements compose_function_t -.
static int op_attach_edit_content_id (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit the 'Content-ID' of the attachment - Implements compose_function_t -.
static int op_attach_edit_description (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit attachment description - Implements compose_function_t -.
static int op_attach_edit_encoding (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit attachment transfer-encoding - Implements compose_function_t -.
static int op_attach_edit_language (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit the 'Content-Language' of the attachment - Implements compose_function_t -.
static int op_attach_edit_mime (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit attachment using mailcap entry - Implements compose_function_t -.
static int op_attach_edit_type (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit attachment content type - Implements compose_function_t -.
static int op_attach_filter (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Filter attachment through a shell command - Implements compose_function_t -.
static int op_attach_get_attachment (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Get a temporary copy of an attachment - Implements compose_function_t -.
static int op_attach_group_alts (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Group selected attachments as 'multipart/alternative' - Implements compose_function_t -.
static int op_attach_group_lingual (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Group selected attachments as 'multipart/multilingual' - Implements compose_function_t -.
static int op_attach_group_related (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Group selected attachments as 'multipart/related' - Implements compose_function_t -.
static int op_attach_move_down (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Move an attachment down in the attachment list - Implements compose_function_t -.
static int op_attach_move_up (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Move an attachment up in the attachment list - Implements compose_function_t -.
static int op_attach_new_mime (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Compose new attachment using mailcap entry - Implements compose_function_t -.
static int op_attach_print (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Print the current entry - Implements compose_function_t -.
static int op_attach_rename_attachment (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Send attachment with a different name - Implements compose_function_t -.
static int op_attach_save (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Save message/attachment to a mailbox/file - Implements compose_function_t -.
static int op_attach_toggle_disposition (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Toggle disposition between inline/attachment - Implements compose_function_t -.
static int op_attach_toggle_recode (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Toggle recoding of this attachment - Implements compose_function_t -.
static int op_attach_toggle_unlink (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Toggle whether to delete file after sending it - Implements compose_function_t -.
static int op_attach_ungroup (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Ungroup a 'multipart' attachment - Implements compose_function_t -.
static int op_attach_update_encoding (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Update an attachment's encoding info - Implements compose_function_t -.
static int op_envelope_edit_headers (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit the message with headers - Implements compose_function_t -.
static int op_compose_edit_file (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit the file to be attached - Implements compose_function_t -.
static int op_compose_edit_message (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Edit the message - Implements compose_function_t -.
static void spelling_command_file (const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
 Spelling command: Filename - Implements get_string_t -.
static int op_compose_check_spelling (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Check the spelling of the message - Implements compose_function_t -.
static int op_compose_postpone_message (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Save this message to send later - Implements compose_function_t -.
static int op_compose_rename_file (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Rename/move an attached file - Implements compose_function_t -.
static int op_compose_send_message (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Send the message - Implements compose_function_t -.
static int op_compose_write_message (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Write the message to a folder - Implements compose_function_t -.
static int op_display_headers (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Display message and toggle header weeding - Implements compose_function_t -.
static int op_quit (struct ComposeFunctionData *fdata, const struct KeyEvent *event)
 Save changes and exit this dialog - Implements compose_function_t -.
int compose_function_dispatcher (struct MuttWindow *win, const struct KeyEvent *event)
 Perform a Compose function - Implements function_dispatcher_t -.

Variables

static const struct MenuFuncOp OpCompose []
 Functions for the Compose Menu.
static const struct MenuOpSeq ComposeDefaultBindings []
 Key bindings for the Compose Menu.
static const struct ComposeFunction ComposeFunctions []
 All the NeoMutt functions that the Compose supports.

Detailed Description

Compose functions.

Authors
  • Pietro Cerutti
  • Richard Russon
  • David Purton

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

◆ compose_init_keys()

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

Initialise the Compose Keybindings - Implements ::init_keys_api.

Definition at line 213 of file functions.c.

214{
216 ASSERT(mod_data);
217
218 struct MenuDefinition *md = NULL;
219 struct SubMenu *sm = NULL;
220
222 md = km_register_menu(MENU_COMPOSE, "compose");
223 km_menu_add_submenu(md, sm);
224 km_menu_add_submenu(md, sm_generic);
226
227 mod_data->md_compose = md;
228}
static const struct MenuFuncOp OpCompose[]
Functions for the Compose Menu.
Definition functions.c:79
static const struct MenuOpSeq ComposeDefaultBindings[]
Key bindings for the Compose Menu.
Definition functions.c:151
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_COMPOSE
ModuleCompose, Compose an Email
Definition module_api.h:57
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
#define ASSERT(COND)
Definition signal2.h:59
Compose private Module data.
Definition module_data.h:30
struct MenuDefinition * md_compose
Compose Menu Definition.
Definition module_data.h:32
Functions for a Dialog or Window.
Definition menudef.h:44
Collection of related functions.
Definition menudef.h:33
@ MENU_COMPOSE
Compose an email.
Definition type.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_count()

bool check_count ( struct AttachCtx * actx)
static

Check if there are any attachments.

Parameters
actxAttachment context
Return values
trueThere are attachments

Definition at line 235 of file functions.c.

236{
237 if (actx->idxlen == 0)
238 {
239 mutt_error(_("There are no attachments"));
240 return false;
241 }
242
243 return true;
244}
#define mutt_error(...)
Definition logging2.h:94
#define _(a)
Definition message.h:28
short idxlen
Number of attachmentes.
Definition attach.h:70
Here is the caller graph for this function:

◆ gen_cid()

char * gen_cid ( void )
static

Generate a random Content ID.

Return values
ptrContent ID
Note
The caller should free the string

Definition at line 252 of file functions.c.

253{
254 char rndid[MUTT_RANDTAG_LEN + 1] = { 0 };
255
256 mutt_rand_base32(rndid, sizeof(rndid) - 1);
257 rndid[MUTT_RANDTAG_LEN] = 0;
258
259 return mutt_str_dup(rndid);
260}
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
void mutt_rand_base32(char *buf, size_t buflen)
Fill a buffer with a base32-encoded random string.
Definition random.c:106
#define MUTT_RANDTAG_LEN
Length of random tag for message boundaries.
Definition sendlib.h:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_cid()

bool check_cid ( const char * cid)
static

Check if a Content-ID is valid.

Parameters
cidContent-ID to check
Return values
trueContent-ID is valid
falseContent-ID is not valid

Definition at line 268 of file functions.c.

269{
270 static const char *check = "^[-\\.0-9@A-Z_a-z]+$";
271
272 struct Regex *check_cid_regex = mutt_regex_new(check, 0, NULL);
273
274 const bool valid = mutt_regex_match(check_cid_regex, cid);
275
276 mutt_regex_free(&check_cid_regex);
277
278 return valid;
279}
struct Regex * mutt_regex_new(const char *str, uint32_t flags, struct Buffer *err)
Create an Regex from a string.
Definition regex.c:80
void mutt_regex_free(struct Regex **ptr)
Free a Regex object.
Definition regex.c:118
bool mutt_regex_match(const struct Regex *regex, const char *str)
Shorthand to mutt_regex_capture().
Definition regex.c:621
Cached regular expression.
Definition regex3.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ content_id_exists()

bool content_id_exists ( struct AttachCtx * actx,
const struct Body * skip,
const char * cid )
static

Check whether a Content-ID is already in use.

Parameters
actxAttachment context
skipBody to ignore
cidContent-ID to check
Return values
trueContent-ID already exists

Definition at line 288 of file functions.c.

289{
290 if (!actx || !cid)
291 return false;
292
293 for (int i = 0; i < actx->idxlen; i++)
294 {
295 struct Body *b = actx->idx[i]->body;
296 if ((b == skip) || !b->content_id)
297 continue;
298
299 if (mutt_str_equal(b->content_id, cid))
300 return true;
301 }
302
303 return false;
304}
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition string.c:666
struct AttachPtr ** idx
Array of attachments.
Definition attach.h:69
struct Body * body
Attachment.
Definition attach.h:37
The body of an email.
Definition body.h:36
char * content_id
Content-Id (RFC2392).
Definition body.h:58
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_attachments()

int check_attachments ( struct AttachCtx * actx,
struct ConfigSubset * sub )
static

Check if any attachments have changed or been deleted.

Parameters
actxAttachment context
subConfigSubset
Return values
0Success
-1Error

Definition at line 313 of file functions.c.

314{
315 int rc = -1;
316 struct stat st = { 0 };
317 struct Buffer *pretty = NULL;
318 struct Buffer *msg = NULL;
319
320 for (int i = 0; i < actx->idxlen; i++)
321 {
322 if (actx->idx[i]->body->type == TYPE_MULTIPART)
323 continue;
324 if (stat(actx->idx[i]->body->filename, &st) != 0)
325 {
326 if (!pretty)
327 pretty = buf_pool_get();
328 buf_strcpy(pretty, actx->idx[i]->body->filename);
329 pretty_mailbox(pretty);
330 /* L10N: This message is displayed in the compose menu when an attachment
331 doesn't stat. %d is the attachment number and %s is the attachment
332 filename. The filename is located last to avoid a long path hiding
333 the error message. */
334 mutt_error(_("Attachment #%d no longer exists: %s"), i + 1, buf_string(pretty));
335 goto cleanup;
336 }
337
338 if (actx->idx[i]->body->stamp < st.st_mtime)
339 {
340 if (!pretty)
341 pretty = buf_pool_get();
342 buf_strcpy(pretty, actx->idx[i]->body->filename);
343 pretty_mailbox(pretty);
344
345 if (!msg)
346 msg = buf_pool_get();
347 /* L10N: This message is displayed in the compose menu when an attachment
348 is modified behind the scenes. %d is the attachment number and %s is
349 the attachment filename. The filename is located last to avoid a long
350 path hiding the prompt question. */
351 buf_printf(msg, _("Attachment #%d modified. Update encoding for %s?"),
352 i + 1, buf_string(pretty));
353
355 if (ans == MUTT_YES)
356 mutt_update_encoding(actx->idx[i]->body, sub);
357 else if (ans == MUTT_ABORT)
358 goto cleanup;
359 }
360 }
361
362 rc = 0;
363
364cleanup:
365 buf_pool_release(&pretty);
366 buf_pool_release(&msg);
367 return rc;
368}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:168
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:401
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition mime.h:37
void pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:431
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
QuadOption
Possible values for a quad-option.
Definition quad.h:36
@ MUTT_ABORT
User aborted the question (with Ctrl-G).
Definition quad.h:37
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition quad.h:39
enum QuadOption query_yesorno(const char *prompt, enum QuadOption def)
Ask the user a Yes/No question.
Definition question.c:329
void mutt_update_encoding(struct Body *b, struct ConfigSubset *sub)
Update the encoding type.
Definition sendlib.c:424
time_t stamp
Time stamp of last encoding update.
Definition body.h:77
unsigned int type
content-type primary type, ContentType
Definition body.h:40
char * filename
When sending a message, this is the file to which this structure refers.
Definition body.h:59
String manipulation buffer.
Definition buffer.h:36
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attachment()

int delete_attachment ( struct AttachCtx * actx,
int aidx,
struct ConfigSubset * sub )
static

Delete an attachment.

Parameters
actxAttachment context
aidxIndex number of attachment to delete
subConfig subset
Return values
0Success
-1Error

Definition at line 378 of file functions.c.

379{
380 if (!actx || (aidx < 0) || (aidx >= actx->idxlen))
381 return -1;
382
383 struct AttachPtr **idx = actx->idx;
384 struct Body *b_previous = NULL;
385 struct Body *b_parent = NULL;
386
387 if (aidx == 0)
388 {
389 struct Body *b = actx->idx[0]->body;
390 if (!b->next) // There's only one attachment left
391 {
392 mutt_error(_("You may not delete the only attachment"));
393 return -1;
394 }
395
396 if (cs_subset_bool(sub, "compose_confirm_detach_first"))
397 {
398 /* L10N: Prompt when trying to hit <detach-file> on the first entry in
399 the compose menu. This entry is most likely the message they just
400 typed. Hitting yes will remove the entry and unlink the file, so
401 it's worth confirming they really meant to do it. */
402 enum QuadOption ans = query_yesorno_help(_("Really delete the main message?"), MUTT_NO,
403 sub, "compose_confirm_detach_first");
404 if (ans == MUTT_NO)
405 {
406 idx[aidx]->body->tagged = false;
407 return -1;
408 }
409 }
410 }
411
412 if (idx[aidx]->level > 0)
413 {
414 if (attach_body_parent(idx[0]->body, NULL, idx[aidx]->body, &b_parent))
415 {
416 if (attach_body_count(b_parent->parts, false) < 3)
417 {
418 mutt_error(_("Can't leave group with only one attachment"));
419 return -1;
420 }
421 }
422 }
423
424 // reorder body pointers
425 if (aidx > 0)
426 {
427 if (attach_body_previous(idx[0]->body, idx[aidx]->body, &b_previous))
428 b_previous->next = idx[aidx]->body->next;
429 else if (attach_body_parent(idx[0]->body, NULL, idx[aidx]->body, &b_parent))
430 b_parent->parts = idx[aidx]->body->next;
431 }
432
433 // free memory
434 int part_count = 1;
435 if (aidx < (actx->idxlen - 1))
436 {
437 if ((idx[aidx]->body->type == TYPE_MULTIPART) &&
438 (idx[aidx + 1]->level > idx[aidx]->level))
439 {
440 part_count += attach_body_count(idx[aidx]->body->parts, true);
441 }
442 }
443 idx[aidx]->body->next = NULL;
444 mutt_body_free(&(idx[aidx]->body));
445 for (int i = 0; i < part_count; i++)
446 {
447 FREE(&idx[aidx + i]->tree);
448 FREE(&idx[aidx + i]);
449 }
450
451 // reorder attachment list
452 for (int i = aidx; i < (actx->idxlen - part_count); i++)
453 idx[i] = idx[i + part_count];
454 for (int i = 0; i < part_count; i++)
455 idx[actx->idxlen - i - 1] = NULL;
456 actx->idxlen -= part_count;
457
458 return 0;
459}
bool attach_body_parent(struct Body *start, struct Body *start_parent, struct Body *body, struct Body **body_parent)
Find the parent of a body.
Definition lib.c:71
int attach_body_count(struct Body *body, bool recurse)
Count bodies.
Definition lib.c:42
bool attach_body_previous(struct Body *start, struct Body *body, struct Body **previous)
Find the previous body of a body.
Definition lib.c:142
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition body.c:58
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition quad.h:38
enum QuadOption query_yesorno_help(const char *prompt, enum QuadOption def, struct ConfigSubset *sub, const char *name)
Ask the user a Yes/No question offering help.
Definition question.c:357
An email to which things will be attached.
Definition attach.h:36
struct Body * parts
parts of a multipart or message/rfc822
Definition body.h:73
bool tagged
This attachment is tagged.
Definition body.h:90
struct Body * next
next attachment in the list
Definition body.h:72
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_idx()

void update_idx ( struct Menu * menu,
struct AttachCtx * actx,
struct AttachPtr * ap )
static

Add a new attachment to the message.

Parameters
menuCurrent menu
actxAttachment context
apAttachment to add

Definition at line 467 of file functions.c.

468{
469 ap->level = 0;
470 for (int i = actx->idxlen; i > 0; i--)
471 {
472 if (ap->level == actx->idx[i - 1]->level)
473 {
474 actx->idx[i - 1]->body->next = ap->body;
475 break;
476 }
477 }
478
479 ap->body->aptr = ap;
480 mutt_actx_add_attach(actx, ap);
481 update_menu(actx, menu, false);
482 menu_set_index(menu, actx->vcount - 1);
483}
void mutt_actx_add_attach(struct AttachCtx *actx, struct AttachPtr *attach)
Add an Attachment to an Attachment Context.
Definition attach.c:65
void update_menu(struct AttachCtx *actx, struct Menu *menu, bool init)
Redraw the compose window.
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:167
short vcount
The number of virtual attachments.
Definition attach.h:74
int level
Nesting depth of attachment.
Definition attach.h:41
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition body.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compose_attach_swap()

void compose_attach_swap ( struct Email * e,
struct AttachCtx * actx,
int first,
int second )
static

Swap two adjacent entries in the attachment list.

Parameters
eEmail
actxAttachment information
firstIndex of first attachment to swap
secondIndex of second attachment to swap

Definition at line 492 of file functions.c.

493{
494 struct AttachPtr **idx = actx->idx;
495
496 // check that attachments really are adjacent
497 if (idx[first]->body->next != idx[second]->body)
498 return;
499
500 // reorder Body pointers
501 if (first == 0)
502 {
503 // first attachment is the fundamental part
504 idx[first]->body->next = idx[second]->body->next;
505 idx[second]->body->next = idx[first]->body;
506 e->body = idx[second]->body;
507 }
508 else
509 {
510 // find previous attachment
511 struct Body *b_previous = NULL;
512 struct Body *b_parent = NULL;
513 if (attach_body_previous(e->body, idx[first]->body, &b_previous))
514 {
515 idx[first]->body->next = idx[second]->body->next;
516 idx[second]->body->next = idx[first]->body;
517 b_previous->next = idx[second]->body;
518 }
519 else if (attach_body_parent(e->body, NULL, idx[first]->body, &b_parent))
520 {
521 idx[first]->body->next = idx[second]->body->next;
522 idx[second]->body->next = idx[first]->body;
523 b_parent->parts = idx[second]->body;
524 }
525 }
526
527 // reorder attachment list
528 struct AttachPtr *saved = idx[second];
529 for (int i = second; i > first; i--)
530 idx[i] = idx[i - 1];
531 idx[first] = saved;
532
533 // if moved attachment is a group then move subparts too
534 if ((idx[first]->body->type == TYPE_MULTIPART) && (second < actx->idxlen - 1))
535 {
536 int i = second + 1;
537 while (idx[i]->level > idx[first]->level)
538 {
539 saved = idx[i];
540 int destidx = i - second + first;
541 for (int j = i; j > destidx; j--)
542 idx[j] = idx[j - 1];
543 idx[destidx] = saved;
544 i++;
545 if (i >= actx->idxlen)
546 break;
547 }
548 }
549}
struct Body * body
List of MIME parts.
Definition email.h:69
Here is the call graph for this function:
Here is the caller graph for this function:

◆ body_index()

int body_index ( struct AttachCtx * actx,
const struct Body * b )
static

Find the index of an attachment body.

Parameters
actxAttachment context
bBody to find
Return values
numIndex of body
-1Body wasn't found

Definition at line 558 of file functions.c.

559{
560 if (!actx || !b)
561 return -1;
562
563 for (int i = 0; i < actx->idxlen; i++)
564 {
565 if (actx->idx[i]->body == b)
566 return i;
567 }
568
569 return -1;
570}
Here is the caller graph for this function:

◆ prev_sibling()

int prev_sibling ( struct AttachCtx * actx,
int index )
static

Find the previous sibling of an attachment.

Parameters
actxAttachment context
indexIndex of attachment
Return values
numIndex of previous sibling
-1No previous sibling

Definition at line 579 of file functions.c.

580{
581 if (!actx || (index <= 0) || (index >= actx->idxlen))
582 return -1;
583
584 const int level = actx->idx[index]->level;
585 int previdx = index - 1;
586 while ((previdx > 0) && (actx->idx[previdx]->level > level))
587 previdx--;
588
589 return (actx->idx[previdx]->level == level) ? previdx : -1;
590}
Here is the caller graph for this function:

◆ next_sibling()

int next_sibling ( struct AttachCtx * actx,
int index )
static

Find the next sibling of an attachment.

Parameters
actxAttachment context
indexIndex of attachment
Return values
numIndex of next sibling
-1No next sibling

Definition at line 599 of file functions.c.

600{
601 if (!actx || (index < 0) || (index >= actx->idxlen))
602 return -1;
603
604 const int level = actx->idx[index]->level;
605 int nextidx = index + 1;
606 while ((nextidx < actx->idxlen) && (actx->idx[nextidx]->level > level))
607 nextidx++;
608
609 if ((nextidx >= actx->idxlen) || (actx->idx[nextidx]->level != level))
610 return -1;
611
612 return nextidx;
613}
Here is the caller graph for this function:

◆ body_array_contains()

bool body_array_contains ( struct BodyArray * ba,
const struct Body * b )
static

Does a selection contain a body?

Parameters
baSelected attachments
bBody to find
Return values
trueBody is selected

Definition at line 621 of file functions.c.

622{
623 struct Body **bp = NULL;
624 ARRAY_FOREACH(bp, ba)
625 {
626 if (*bp == b)
627 return true;
628 }
629
630 return false;
631}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
Here is the caller graph for this function:

◆ selected_attachments_are_siblings()

bool selected_attachments_are_siblings ( struct Email * e,
struct BodyArray * ba )
static

Check whether selected attachments are siblings.

Parameters
eEmail
baSelected attachments
Return values
trueSelected attachments are siblings

Definition at line 639 of file functions.c.

640{
641 if (!e || !ba)
642 return false;
643
644 int level = -1;
645 struct Body *parent = NULL;
646 struct Body **bp = NULL;
647 ARRAY_FOREACH(bp, ba)
648 {
649 struct Body *this_parent = NULL;
650 struct Body *body = *bp;
651 if (body->aptr && (body->aptr->level > 0))
652 {
653 if (!attach_body_parent(e->body, NULL, body, &this_parent))
654 return false;
655 }
656
657 if (level == -1)
658 {
659 level = body->aptr ? body->aptr->level : 0;
660 parent = this_parent;
661 continue;
662 }
663
664 if ((level != (body->aptr ? body->aptr->level : 0)) || (parent != this_parent))
665 return false;
666 }
667
668 return true;
669}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ selection_redraw_flags()

MenuRedrawFlags selection_redraw_flags ( size_t count)
static

Choose redraw flags for a selection.

Parameters
countNumber of selected attachments
Return values
redrawflags for the selection

Definition at line 676 of file functions.c.

677{
678 return (count > 1) ? MENU_REDRAW_FULL : MENU_REDRAW_CURRENT;
679}
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
@ MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition lib.h:63
Here is the caller graph for this function:

◆ resolve_attachment()

void resolve_attachment ( struct Menu * menu,
const struct ConfigSubset * sub,
int index,
int num )
static

Advance the Attachment List selection after an action.

Parameters
menuMenu
subConfig subset
indexOriginal menu index, before the action
numNumber of selected attachment entries operated on

If $resolve is set, move the selection on by the number of items that were acted upon. Overruns are silently capped at the end of the list.

Nothing is moved when operating on a tag-prefix selection.

Definition at line 693 of file functions.c.

695{
696 if (!menu || menu->tag_prefix || (num <= 0))
697 return;
698
699 const bool c_resolve = cs_subset_bool(sub, "resolve");
700 if (!c_resolve)
701 return;
702
703 const int new_index = index + num;
704 if (new_index < menu->max)
705 menu_set_index(menu, new_index);
706}
bool tag_prefix
User has pressed <tag-prefix>.
Definition lib.h:92
Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_attachment()

int move_attachment ( struct ComposeSharedData * shared,
bool up,
int count )
static

Move attachments in the attachment list.

Parameters
sharedShared compose data
upIf true, move up, otherwise move down
countRepeat-count
Return values
enumFunctionRetval

Definition at line 715 of file functions.c.

716{
717 struct AttachCtx *actx = shared->adata->actx;
718 if (!check_count(actx))
719 return FR_ERROR;
720
721 struct Menu *menu = shared->adata->menu;
722 struct AttachPtr *cur_att = current_attachment(actx, menu);
723 if (!cur_att)
724 return FR_ERROR;
725
726 struct Body *cur_body = cur_att->body;
727 struct BodyArray ba = ARRAY_HEAD_INITIALIZER;
728 ba_add_selection(&ba, actx, menu, menu->tag_prefix, count);
729 if (ARRAY_EMPTY(&ba))
730 goto done;
731
732 if ((ARRAY_SIZE(&ba) > 1) && !selected_attachments_are_siblings(shared->email, &ba))
733 {
734 mutt_error(_("Selected attachments must be siblings"));
735 ARRAY_FREE(&ba);
736 return FR_ERROR;
737 }
738
739 bool moved = false;
740 if (up)
741 {
742 struct Body **bp = NULL;
743 ARRAY_FOREACH(bp, &ba)
744 {
745 const int index = body_index(actx, *bp);
746 const int previdx = prev_sibling(actx, index);
747 if (previdx < 0)
748 continue;
749 if (body_array_contains(&ba, actx->idx[previdx]->body))
750 continue;
751
752 compose_attach_swap(shared->email, actx, previdx, index);
753 moved = true;
754 }
755 }
756 else
757 {
758 for (int i = ARRAY_SIZE(&ba) - 1; i >= 0; i--)
759 {
760 struct Body **bp = ARRAY_GET(&ba, i);
761 const int index = body_index(actx, *bp);
762 const int nextidx = next_sibling(actx, index);
763 if (nextidx < 0)
764 continue;
765 if (body_array_contains(&ba, actx->idx[nextidx]->body))
766 continue;
767
768 compose_attach_swap(shared->email, actx, index, nextidx);
769 moved = true;
770 }
771 }
772
773 if (!moved)
774 {
775 mutt_error(up ? _("Attachment is already at top") : _("Attachment is already at bottom"));
776 goto done;
777 }
778
779 mutt_update_tree(actx);
782
783 const int index = body_index(actx, cur_body);
784 if (index >= 0)
785 menu_set_index(menu, index);
786
787 ARRAY_FREE(&ba);
788 return FR_SUCCESS;
789
790done:
791 ARRAY_FREE(&ba);
792 return FR_ERROR;
793}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
static bool check_count(struct AttachCtx *actx)
Check if there are any attachments.
Definition functions.c:235
static int body_index(struct AttachCtx *actx, const struct Body *b)
Find the index of an attachment body.
Definition functions.c:558
static int prev_sibling(struct AttachCtx *actx, int index)
Find the previous sibling of an attachment.
Definition functions.c:579
static void compose_attach_swap(struct Email *e, struct AttachCtx *actx, int first, int second)
Swap two adjacent entries in the attachment list.
Definition functions.c:492
static bool body_array_contains(struct BodyArray *ba, const struct Body *b)
Does a selection contain a body?
Definition functions.c:621
static int next_sibling(struct AttachCtx *actx, int index)
Find the next sibling of an attachment.
Definition functions.c:599
static bool selected_attachments_are_siblings(struct Email *e, struct BodyArray *ba)
Check whether selected attachments are siblings.
Definition functions.c:639
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
@ NT_EMAIL_CHANGE_ATTACH
Email's Attachments have changed.
Definition email.h:188
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:177
@ MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:61
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_EMAIL
Email has changed, NotifyEmail, EventEmail.
Definition notify_type.h:44
struct AttachPtr * current_attachment(struct AttachCtx *actx, struct Menu *menu)
Get the current attachment.
Definition recvattach.c:71
void mutt_update_tree(struct AttachCtx *actx)
Refresh the list of attachments.
Definition recvattach.c:118
int ba_add_selection(struct BodyArray *ba, struct AttachCtx *actx, struct Menu *menu, bool use_tagged, int count)
Build a working set of attachment bodies for an action.
Definition selection.c:164
A set of attachments.
Definition attach.h:65
struct Menu * menu
Menu displaying the attachments.
Definition attach_data.h:35
struct AttachCtx * actx
Set of attachments.
Definition attach_data.h:34
struct ComposeAttachData * adata
Attachments.
Definition shared_data.h:39
struct Email * email
Email being composed.
Definition shared_data.h:38
struct Notify * notify
Notifications: NotifyEmail, EventEmail.
Definition email.h:73
Definition lib.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ group_attachments()

int group_attachments ( struct ComposeSharedData * shared,
char * subtype,
struct BodyArray * ba )
static

Group selected attachments into a multipart group.

Parameters
sharedShared compose data
subtypeMIME subtype
baSelected attachments
Return values
FR_SUCCESSSuccess
FR_ERRORFailure

Definition at line 803 of file functions.c.

805{
806 struct AttachCtx *actx = shared->adata->actx;
807 int group_level = -1;
808 struct Body *bptr_parent = NULL;
809
810 // Attachments to be grouped must have the same parent
811 for (int i = 0; i < actx->idxlen; i++)
812 {
813 if (body_array_contains(ba, actx->idx[i]->body))
814 {
815 if (group_level == -1)
816 {
817 group_level = actx->idx[i]->level;
818 }
819 else
820 {
821 if (group_level != actx->idx[i]->level)
822 {
823 mutt_error(_("Attachments to be grouped must have the same parent"));
824 return FR_ERROR;
825 }
826 }
827 // if not at top level check if all tagged attachments have same parent
828 if (group_level > 0)
829 {
830 if (bptr_parent)
831 {
832 struct Body *bptr_test = NULL;
833 if (!attach_body_parent(actx->idx[0]->body, NULL, actx->idx[i]->body, &bptr_test))
834 mutt_debug(LL_DEBUG5, "can't find parent\n");
835 if (bptr_test != bptr_parent)
836 {
837 mutt_error(_("Attachments to be grouped must have the same parent"));
838 return FR_ERROR;
839 }
840 }
841 else
842 {
843 if (!attach_body_parent(actx->idx[0]->body, NULL, actx->idx[i]->body, &bptr_parent))
844 mutt_debug(LL_DEBUG5, "can't find parent\n");
845 }
846 }
847 }
848 }
849
850 // Can't group all attachments unless at top level
851 if (bptr_parent)
852 {
853 if (ARRAY_SIZE(ba) == attach_body_count(bptr_parent->parts, false))
854 {
855 mutt_error(_("Can't leave group with only one attachment"));
856 return FR_ERROR;
857 }
858 }
859
860 struct Body *group = mutt_body_new();
861 group->type = TYPE_MULTIPART;
862 group->subtype = mutt_str_dup(subtype);
863 group->encoding = ENC_7BIT;
864
865 struct Body *bptr_first = NULL; // first selected attachment
866 struct Body *bptr = NULL; // current selected attachment
867 struct Body *group_parent = NULL; // parent of group
868 struct Body *group_previous = NULL; // previous body to group
869 struct Body *group_part = NULL; // current attachment in group
870 int group_idx = 0; // index in attachment list where group will be inserted
871 int group_last_idx = 0; // index of last part of previous found group
872 int group_parent_type = TYPE_OTHER;
873
874 for (int i = 0; i < actx->idxlen; i++)
875 {
876 bptr = actx->idx[i]->body;
877 if (body_array_contains(ba, bptr))
878 {
879 // set group properties based on first selected attachment
880 if (!bptr_first)
881 {
882 group->disposition = bptr->disposition;
883 if (bptr->language && !mutt_str_equal(subtype, "multilingual"))
884 group->language = mutt_str_dup(bptr->language);
885 group_parent_type = bptr->aptr->parent_type;
886 bptr_first = bptr;
887 if (i > 0)
888 {
889 if (!attach_body_previous(shared->email->body, bptr, &group_previous))
890 {
891 mutt_debug(LL_DEBUG5, "couldn't find previous\n");
892 }
893 if (!attach_body_parent(shared->email->body, NULL, bptr, &group_parent))
894 {
895 mutt_debug(LL_DEBUG5, "couldn't find parent\n");
896 }
897 }
898 }
899
900 if (bptr->tagged)
901 {
902 shared->adata->menu->num_tagged--;
903 bptr->tagged = false;
904 }
905 bptr->aptr->level++;
907
908 // append bptr to the group parts list and remove from email body list
909 struct Body *bptr_previous = NULL;
910 if (attach_body_previous(shared->email->body, bptr, &bptr_previous))
911 bptr_previous->next = bptr->next;
912 else if (attach_body_parent(shared->email->body, NULL, bptr, &bptr_parent))
913 bptr_parent->parts = bptr->next;
914 else
915 shared->email->body = bptr->next;
916
917 if (group_part)
918 {
919 // add bptr to group parts list
920 group_part->next = bptr;
921 group_part = group_part->next;
922 group_part->next = NULL;
923
924 // reorder attachments and set levels
925 int bptr_attachments = attach_body_count(bptr, true);
926 for (int j = i + 1; j < (i + bptr_attachments); j++)
927 actx->idx[j]->level++;
928 if (i > (group_last_idx + 1))
929 {
930 for (int j = 0; j < bptr_attachments; j++)
931 {
932 struct AttachPtr *saved = actx->idx[i + bptr_attachments - 1];
933 for (int k = i + bptr_attachments - 1; k > (group_last_idx + 1); k--)
934 actx->idx[k] = actx->idx[k - 1];
935 actx->idx[group_last_idx + 1] = saved;
936 }
937 }
938 i += bptr_attachments - 1;
939 group_last_idx += bptr_attachments;
940 }
941 else
942 {
943 group_idx = i;
944 group->parts = bptr;
945 group_part = bptr;
946 group_part->next = NULL;
947 int bptr_attachments = attach_body_count(bptr, true);
948 for (int j = i + 1; j < (i + bptr_attachments); j++)
949 actx->idx[j]->level++;
950 i += bptr_attachments - 1;
951 group_last_idx = i;
952 }
953 }
954 }
955
956 if (!bptr_first)
957 {
958 mutt_body_free(&group);
959 return FR_ERROR;
960 }
961
962 // set group->next
963 int next_aidx = group_idx + attach_body_count(group->parts, true);
964 if (group_parent)
965 {
966 // find next attachment with the same parent as the group
967 struct Body *b = NULL;
968 struct Body *b_parent = NULL;
969 while (next_aidx < actx->idxlen)
970 {
971 b = actx->idx[next_aidx]->body;
972 b_parent = NULL;
973 if (attach_body_parent(shared->email->body, NULL, b, &b_parent))
974 {
975 if (group_parent == b_parent)
976 {
977 group->next = b;
978 break;
979 }
980 }
981 next_aidx++;
982 }
983 }
984 else if (next_aidx < actx->idxlen)
985 {
986 // group is at top level
987 group->next = actx->idx[next_aidx]->body;
988 }
989
990 // set previous or parent for group
991 if (group_previous)
992 group_previous->next = group;
993 else if (group_parent)
994 group_parent->parts = group;
995
997
998 struct AttachPtr *group_ap = mutt_aptr_new();
999 group_ap->body = group;
1000 group_ap->body->aptr = group_ap;
1001 group_ap->level = group_level;
1002 group_ap->parent_type = group_parent_type;
1003
1004 // insert group into attachment list
1005 mutt_actx_ins_attach(actx, group_ap, group_idx);
1006
1007 // update email body and last attachment pointers
1008 shared->email->body = actx->idx[0]->body;
1009 actx->idx[actx->idxlen - 1]->body->next = NULL;
1010
1011 update_menu(actx, shared->adata->menu, false);
1012 shared->adata->menu->current = group_idx;
1014
1015 exec_message_hook(NULL, shared->email, CMD_SEND2_HOOK);
1016 return FR_SUCCESS;
1017}
void mutt_actx_ins_attach(struct AttachCtx *actx, struct AttachPtr *attach, int aidx)
Insert an Attachment into an Attachment Context at Specified Index.
Definition attach.c:91
struct AttachPtr * mutt_aptr_new(void)
Create a new Attachment Pointer.
Definition attach.c:40
@ CMD_SEND2_HOOK
:send2-hook
Definition command.h:109
struct Body * mutt_body_new(void)
Create a new Body.
Definition body.c:44
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
void exec_message_hook(struct Mailbox *m, struct Email *e, enum CommandId id)
Perform a message hook.
Definition exec.c:137
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
@ ENC_7BIT
7-bit text
Definition mime.h:49
@ TYPE_OTHER
Unknown Content-Type.
Definition mime.h:31
void mutt_generate_boundary(struct ParameterList *pl)
Create a unique boundary id for a MIME part.
Definition multipart.c:93
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition attach.h:39
char * language
content-language (RFC8255)
Definition body.h:78
struct ParameterList parameter
Parameters of the content-type.
Definition body.h:63
unsigned int disposition
content-disposition, ContentDisposition
Definition body.h:42
char * subtype
content-type subtype
Definition body.h:61
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition body.h:41
int current
Current entry.
Definition lib.h:87
int num_tagged
Number of tagged entries.
Definition lib.h:101
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ OpCompose

const struct MenuFuncOp OpCompose[]
static

Functions for the Compose Menu.

Definition at line 79 of file functions.c.

79 { /* map: compose */
80 { "attach-file", OP_ATTACH_ATTACH_FILE },
81 { "attach-key", OP_ATTACH_ATTACH_KEY },
82 { "attach-message", OP_ATTACH_ATTACH_MESSAGE },
83 { "attach-news-message", OP_ATTACH_ATTACH_NEWS_MESSAGE },
84#ifdef USE_AUTOCRYPT
85 { "autocrypt-menu", OP_COMPOSE_AUTOCRYPT_MENU },
86#endif
87 { "copy-file", OP_ATTACH_SAVE },
88 { "detach-file", OP_ATTACH_DETACH },
89 { "display-toggle-weed", OP_DISPLAY_HEADERS },
90 { "edit-bcc", OP_ENVELOPE_EDIT_BCC },
91 { "edit-cc", OP_ENVELOPE_EDIT_CC },
92 { "edit-content-id", OP_ATTACH_EDIT_CONTENT_ID },
93 { "edit-description", OP_ATTACH_EDIT_DESCRIPTION },
94 { "edit-encoding", OP_ATTACH_EDIT_ENCODING },
95 { "edit-fcc", OP_ENVELOPE_EDIT_FCC },
96 { "edit-file", OP_COMPOSE_EDIT_FILE },
97 { "edit-followup-to", OP_ENVELOPE_EDIT_FOLLOWUP_TO },
98 { "edit-from", OP_ENVELOPE_EDIT_FROM },
99 { "edit-headers", OP_ENVELOPE_EDIT_HEADERS },
100 { "edit-language", OP_ATTACH_EDIT_LANGUAGE },
101 { "edit-message", OP_COMPOSE_EDIT_MESSAGE },
102 { "edit-mime", OP_ATTACH_EDIT_MIME },
103 { "edit-newsgroups", OP_ENVELOPE_EDIT_NEWSGROUPS },
104 { "edit-reply-to", OP_ENVELOPE_EDIT_REPLY_TO },
105 { "edit-subject", OP_ENVELOPE_EDIT_SUBJECT },
106 { "edit-to", OP_ENVELOPE_EDIT_TO },
107 { "edit-type", OP_ATTACH_EDIT_TYPE },
108 { "edit-x-comment-to", OP_ENVELOPE_EDIT_X_COMMENT_TO },
109 { "filter-entry", OP_ATTACH_FILTER },
110 { "get-attachment", OP_ATTACH_GET_ATTACHMENT },
111 { "group-alternatives", OP_ATTACH_GROUP_ALTS },
112 { "group-multilingual", OP_ATTACH_GROUP_LINGUAL },
113 { "group-related", OP_ATTACH_GROUP_RELATED },
114 { "ispell", OP_COMPOSE_CHECK_SPELLING },
115 { "move-down", OP_ATTACH_MOVE_DOWN },
116 { "move-up", OP_ATTACH_MOVE_UP },
117 { "new-mime", OP_ATTACH_NEW_MIME },
118 { "pgp-menu", OP_COMPOSE_PGP_MENU },
119 { "pipe-entry", OP_PIPE },
120 { "pipe-message", OP_PIPE },
121 { "postpone-message", OP_COMPOSE_POSTPONE_MESSAGE },
122 { "preview-scroll-half-down", OP_PREVIEW_SCROLL_HALF_DOWN },
123 { "preview-scroll-half-up", OP_PREVIEW_SCROLL_HALF_UP },
124 { "preview-scroll-line-down", OP_PREVIEW_SCROLL_LINE_DOWN },
125 { "preview-scroll-line-up", OP_PREVIEW_SCROLL_LINE_UP },
126 { "preview-scroll-page-down", OP_PREVIEW_SCROLL_PAGE_DOWN },
127 { "preview-scroll-page-up", OP_PREVIEW_SCROLL_PAGE_UP },
128 { "preview-select-first-entry", OP_PREVIEW_SELECT_FIRST_ENTRY },
129 { "preview-select-last-entry", OP_PREVIEW_SELECT_LAST_ENTRY },
130 { "print-entry", OP_ATTACH_PRINT },
131 { "rename-attachment", OP_ATTACH_RENAME_ATTACHMENT },
132 { "rename-file", OP_COMPOSE_RENAME_FILE },
133 { "send-message", OP_COMPOSE_SEND_MESSAGE },
134 { "smime-menu", OP_COMPOSE_SMIME_MENU },
135 { "toggle-disposition", OP_ATTACH_TOGGLE_DISPOSITION },
136 { "toggle-recode", OP_ATTACH_TOGGLE_RECODE },
137 { "toggle-unlink", OP_ATTACH_TOGGLE_UNLINK },
138 { "ungroup-attachment", OP_ATTACH_UNGROUP },
139 { "update-encoding", OP_ATTACH_UPDATE_ENCODING },
140 { "view-attach", OP_ATTACH_VIEW },
141 { "view-mailcap", OP_ATTACH_VIEW_MAILCAP },
142 { "view-pager", OP_ATTACH_VIEW_PAGER },
143 { "view-text", OP_ATTACH_VIEW_TEXT },
144 { "write-fcc", OP_COMPOSE_WRITE_MESSAGE },
145 { NULL, 0 },
146};

◆ ComposeDefaultBindings

const struct MenuOpSeq ComposeDefaultBindings[]
static

Key bindings for the Compose Menu.

Definition at line 151 of file functions.c.

151 { /* map: compose */
152 { OP_ATTACH_ATTACH_FILE, "a" },
153 { OP_ATTACH_ATTACH_KEY, "\033k" }, // <Alt-k>
154 { OP_ATTACH_ATTACH_MESSAGE, "A" },
155 { OP_ATTACH_DETACH, "D" },
156 { OP_ATTACH_EDIT_CONTENT_ID, "\033i" }, // <Alt-i>
157 { OP_ATTACH_EDIT_DESCRIPTION, "d" },
158 { OP_ATTACH_EDIT_ENCODING, "\005" }, // <Ctrl-E>
159 { OP_ATTACH_EDIT_LANGUAGE, "\014" }, // <Ctrl-L>
160 { OP_ATTACH_EDIT_MIME, "m" },
161 { OP_ATTACH_EDIT_TYPE, "\024" }, // <Ctrl-T>
162 { OP_ATTACH_FILTER, "F" },
163 { OP_ATTACH_GET_ATTACHMENT, "G" },
164 { OP_ATTACH_GROUP_ALTS, "&" },
165 { OP_ATTACH_GROUP_LINGUAL, "^" },
166 { OP_ATTACH_GROUP_RELATED, "%" },
167 { OP_ATTACH_MOVE_DOWN, "+" },
168 { OP_ATTACH_MOVE_UP, "-" },
169 { OP_ATTACH_NEW_MIME, "n" },
170 { OP_PIPE, "|" },
171 { OP_ATTACH_PRINT, "l" },
172 { OP_ATTACH_RENAME_ATTACHMENT, "\017" }, // <Ctrl-O>
173 { OP_ATTACH_SAVE, "C" },
174 { OP_ATTACH_TOGGLE_DISPOSITION, "\004" }, // <Ctrl-D>
175 { OP_ATTACH_TOGGLE_UNLINK, "u" },
176 { OP_ATTACH_UNGROUP, "#" },
177 { OP_ATTACH_UPDATE_ENCODING, "U" },
178 { OP_ATTACH_VIEW, "<keypadenter>" },
179 { OP_ATTACH_VIEW, "\n" }, // <Enter>
180 { OP_ATTACH_VIEW, "\r" }, // <Return>
181#ifdef USE_AUTOCRYPT
182 { OP_COMPOSE_AUTOCRYPT_MENU, "o" },
183#endif
184 { OP_COMPOSE_EDIT_FILE, "\033e" }, // <Alt-e>
185 { OP_COMPOSE_EDIT_MESSAGE, "e" },
186 { OP_COMPOSE_CHECK_SPELLING, "i" },
187 { OP_COMPOSE_PGP_MENU, "p" },
188 { OP_COMPOSE_POSTPONE_MESSAGE, "P" },
189 { OP_COMPOSE_RENAME_FILE, "R" },
190 { OP_COMPOSE_SEND_MESSAGE, "y" },
191 { OP_COMPOSE_SMIME_MENU, "S" },
192 { OP_COMPOSE_WRITE_MESSAGE, "w" },
193 { OP_DISPLAY_HEADERS, "h" },
194 { OP_ENVELOPE_EDIT_BCC, "b" },
195 { OP_ENVELOPE_EDIT_CC, "c" },
196 { OP_ENVELOPE_EDIT_FCC, "f" },
197 { OP_ENVELOPE_EDIT_FROM, "\033f" }, // <Alt-f>
198 { OP_ENVELOPE_EDIT_HEADERS, "E" },
199 { OP_ENVELOPE_EDIT_REPLY_TO, "r" },
200 { OP_ENVELOPE_EDIT_SUBJECT, "s" },
201 { OP_ENVELOPE_EDIT_TO, "t" },
202 { OP_PREVIEW_SCROLL_PAGE_DOWN, "<pagedown>" },
203 { OP_PREVIEW_SCROLL_PAGE_UP, "<pageup>" },
204 { OP_FORGET_PASSPHRASE, "\006" }, // <Ctrl-F>
205 { OP_TAG, "T" },
206 { 0, NULL },
207};

◆ ComposeFunctions

const struct ComposeFunction ComposeFunctions[]
static

All the NeoMutt functions that the Compose supports.

Definition at line 2764 of file functions.c.

2764 {
2765 // clang-format off
2766 { OP_ATTACH_ATTACH_FILE, op_attach_attach_file },
2767 { OP_ATTACH_ATTACH_KEY, op_attach_attach_key },
2768 { OP_ATTACH_ATTACH_MESSAGE, op_attach_attach_message },
2769 { OP_ATTACH_ATTACH_NEWS_MESSAGE, op_attach_attach_message },
2770 { OP_ATTACH_DETACH, op_attach_detach },
2771 { OP_ATTACH_EDIT_CONTENT_ID, op_attach_edit_content_id },
2772 { OP_ATTACH_EDIT_DESCRIPTION, op_attach_edit_description },
2773 { OP_ATTACH_EDIT_ENCODING, op_attach_edit_encoding },
2774 { OP_ATTACH_EDIT_LANGUAGE, op_attach_edit_language },
2775 { OP_ATTACH_EDIT_MIME, op_attach_edit_mime },
2776 { OP_ATTACH_EDIT_TYPE, op_attach_edit_type },
2777 { OP_ATTACH_FILTER, op_attach_filter },
2778 { OP_ATTACH_GET_ATTACHMENT, op_attach_get_attachment },
2779 { OP_ATTACH_GROUP_ALTS, op_attach_group_alts },
2780 { OP_ATTACH_GROUP_LINGUAL, op_attach_group_lingual },
2781 { OP_ATTACH_GROUP_RELATED, op_attach_group_related },
2782 { OP_ATTACH_MOVE_DOWN, op_attach_move_down },
2783 { OP_ATTACH_MOVE_UP, op_attach_move_up },
2784 { OP_ATTACH_NEW_MIME, op_attach_new_mime },
2785 { OP_ATTACH_PRINT, op_attach_print },
2786 { OP_ATTACH_RENAME_ATTACHMENT, op_attach_rename_attachment },
2787 { OP_ATTACH_SAVE, op_attach_save },
2788 { OP_ATTACH_TOGGLE_DISPOSITION, op_attach_toggle_disposition },
2789 { OP_ATTACH_TOGGLE_RECODE, op_attach_toggle_recode },
2790 { OP_ATTACH_TOGGLE_UNLINK, op_attach_toggle_unlink },
2791 { OP_ATTACH_UNGROUP, op_attach_ungroup },
2792 { OP_ATTACH_UPDATE_ENCODING, op_attach_update_encoding },
2793 { OP_ATTACH_VIEW, op_display_headers },
2794 { OP_ATTACH_VIEW_MAILCAP, op_display_headers },
2795 { OP_ATTACH_VIEW_PAGER, op_display_headers },
2796 { OP_ATTACH_VIEW_TEXT, op_display_headers },
2797 { OP_COMPOSE_EDIT_FILE, op_compose_edit_file },
2798 { OP_COMPOSE_EDIT_MESSAGE, op_compose_edit_message },
2799 { OP_COMPOSE_CHECK_SPELLING, op_compose_check_spelling },
2800 { OP_COMPOSE_POSTPONE_MESSAGE, op_compose_postpone_message },
2801 { OP_COMPOSE_RENAME_FILE, op_compose_rename_file },
2802 { OP_COMPOSE_SEND_MESSAGE, op_compose_send_message },
2803 { OP_COMPOSE_WRITE_MESSAGE, op_compose_write_message },
2804 { OP_DISPLAY_HEADERS, op_display_headers },
2805 { OP_ENVELOPE_EDIT_HEADERS, op_envelope_edit_headers },
2806 { OP_EXIT, op_quit },
2807 { OP_PIPE, op_attach_filter },
2808 { OP_QUIT, op_quit },
2809 { 0, NULL },
2810 // clang-format on
2811};
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_attach_edit_type(struct AttachFunctionData *fdata, const struct KeyEvent *event)
edit attachment content type - Implements attach_function_t -
Definition functions.c:391
static int op_attach_save(struct AttachFunctionData *fdata, const struct KeyEvent *event)
save message/attachment to a mailbox/file - Implements attach_function_t -
Definition functions.c:428
static int op_attach_print(struct AttachFunctionData *fdata, const struct KeyEvent *event)
print the current entry - Implements attach_function_t -
Definition functions.c:415
static int op_attach_edit_description(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit attachment description - Implements compose_function_t -.
Definition functions.c:1449
static int op_compose_postpone_message(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Save this message to send later - Implements compose_function_t -.
Definition functions.c:2533
static int op_attach_edit_content_id(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit the 'Content-ID' of the attachment - Implements compose_function_t -.
Definition functions.c:1361
static int op_attach_group_lingual(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Group selected attachments as 'multipart/multilingual' - Implements compose_function_t -.
Definition functions.c:1791
static int op_compose_write_message(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Write the message to a folder - Implements compose_function_t -.
Definition functions.c:2630
static int op_compose_edit_message(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit the message - Implements compose_function_t -.
Definition functions.c:2451
static int op_attach_ungroup(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Ungroup a 'multipart' attachment - Implements compose_function_t -.
Definition functions.c:2274
static int op_attach_update_encoding(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Update an attachment's encoding info - Implements compose_function_t -.
Definition functions.c:2337
static int op_attach_get_attachment(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Get a temporary copy of an attachment - Implements compose_function_t -.
Definition functions.c:1724
static int op_attach_group_related(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Group selected attachments as 'multipart/related' - Implements compose_function_t -.
Definition functions.c:1832
static int op_compose_check_spelling(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Check the spelling of the message - Implements compose_function_t -.
Definition functions.c:2494
static int op_compose_rename_file(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Rename/move an attached file - Implements compose_function_t -.
Definition functions.c:2550
static int op_attach_move_up(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Move an attachment up in the attachment list - Implements compose_function_t -.
Definition functions.c:1927
static int op_attach_filter(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Filter attachment through a shell command - Implements compose_function_t -.
Definition functions.c:1685
static int op_attach_edit_language(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit the 'Content-Language' of the attachment - Implements compose_function_t -.
Definition functions.c:1563
static int op_attach_toggle_disposition(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Toggle disposition between inline/attachment - Implements compose_function_t -.
Definition functions.c:2146
static int op_attach_rename_attachment(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Send attachment with a different name - Implements compose_function_t -.
Definition functions.c:2082
static int op_attach_move_down(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Move an attachment down in the attachment list - Implements compose_function_t -.
Definition functions.c:1867
static int op_attach_group_alts(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Group selected attachments as 'multipart/alternative' - Implements compose_function_t -.
Definition functions.c:1770
static int op_attach_attach_key(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Attach a PGP public key - Implements compose_function_t -.
Definition functions.c:1090
static int op_attach_toggle_recode(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Toggle recoding of this attachment - Implements compose_function_t -.
Definition functions.c:2183
static int op_envelope_edit_headers(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit the message with headers - Implements compose_function_t -.
Definition functions.c:2376
static int op_compose_send_message(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Send the message - Implements compose_function_t -.
Definition functions.c:2601
static int op_attach_edit_encoding(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit attachment transfer-encoding - Implements compose_function_t -.
Definition functions.c:1500
static int op_attach_toggle_unlink(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Toggle whether to delete file after sending it - Implements compose_function_t -.
Definition functions.c:2238
static int op_attach_detach(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Delete the current entry - Implements compose_function_t -.
Definition functions.c:1271
static int op_display_headers(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Display message and toggle header weeding - Implements compose_function_t -.
Definition functions.c:2674
static int op_attach_attach_message(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Attach messages to this message - Implements compose_function_t -.
Definition functions.c:1119
static int op_compose_edit_file(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit the file to be attached - Implements compose_function_t -.
Definition functions.c:2426
static int op_attach_edit_mime(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Edit attachment using mailcap entry - Implements compose_function_t -.
Definition functions.c:1619
static int op_attach_new_mime(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Compose new attachment using mailcap entry - Implements compose_function_t -.
Definition functions.c:1966
static int op_attach_attach_file(struct ComposeFunctionData *fdata, const struct KeyEvent *event)
Attach files to this message - Implements compose_function_t -.
Definition functions.c:1024