NeoMutt  2025-12-11-117-gc1a713
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Index Function API

Prototype for an Index Function. More...

+ Collaboration diagram for Index Function API:

Functions

static int op_alias_dialog (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open the aliases dialog - Implements index_function_t -.
 
static int op_attachment_edit_type (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Edit attachment content type - Implements index_function_t -.
 
static int op_bounce_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Remail a message to another user - Implements index_function_t -.
 
static int op_check_traditional (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Check for classic PGP - Implements index_function_t -.
 
static int op_compose_to_sender (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Compose new message to the current message sender - Implements index_function_t -.
 
static int op_create_alias (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Create an alias from a message sender - Implements index_function_t -.
 
static int op_delete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete the current entry - Implements index_function_t -.
 
static int op_delete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete all messages in thread - Implements index_function_t -.
 
static int op_display_address (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display full address of sender - Implements index_function_t -.
 
static int op_display_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display a message - Implements index_function_t -.
 
static int op_edit_label (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Add, change, or delete a message's label - Implements index_function_t -.
 
static int op_edit_raw_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Edit the raw message (edit and edit-raw-message are synonyms) - Implements index_function_t -.
 
static int op_end_cond (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 End of conditional execution (noop) - Implements index_function_t -.
 
static int op_exit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Exit this menu - Implements index_function_t -.
 
static int op_extract_keys (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Extract supported public keys - Implements index_function_t -.
 
static int op_flag_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'important' flag - Implements index_function_t -.
 
static int op_forget_passphrase (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Wipe passphrases from memory - Implements index_function_t -.
 
static int op_forward_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Forward a message with comments - Implements index_function_t -.
 
static int op_group_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to all recipients - Implements index_function_t -.
 
static int op_jump (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to an index number - Implements index_function_t -.
 
static int op_list_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to specified mailing list - Implements index_function_t -.
 
static int op_list_subscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Subscribe to a mailing list - Implements index_function_t -.
 
static int op_list_unsubscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Unsubscribe from mailing list - Implements index_function_t -.
 
static int op_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Compose a new mail message - Implements index_function_t -.
 
static int op_mailbox_list (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 List mailboxes with new mail - Implements index_function_t -.
 
static int op_mail_key (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mail a PGP public key - Implements index_function_t -.
 
static int op_main_break_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Break the thread in two - Implements index_function_t -.
 
static int op_main_change_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different folder - Implements index_function_t -.
 
static int op_main_collapse_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse all threads - Implements index_function_t -.
 
static int op_main_collapse_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse current thread - Implements index_function_t -.
 
static int op_main_delete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete messages matching a pattern - Implements index_function_t -.
 
static int op_main_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Limit view to a pattern/thread - Implements index_function_t -.
 
static int op_main_link_threads (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Link tagged message to the current one - Implements index_function_t -.
 
static int op_main_modify_tags (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Modify (notmuch/imap) tags - Implements index_function_t -.
 
static int op_main_next_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next new message - Implements index_function_t -.
 
static int op_main_next_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next thread - Implements index_function_t -.
 
static int op_main_next_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next undeleted message - Implements index_function_t -.
 
static int op_main_next_unread_mailbox (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open next mailbox with unread mail - Implements index_function_t -.
 
static int op_main_prev_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous undeleted message - Implements index_function_t -.
 
static int op_main_quasi_delete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete from NeoMutt, don't touch on disk - Implements index_function_t -.
 
static int op_main_read_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark the current thread as read - Implements index_function_t -.
 
static int op_main_root_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to root message in thread - Implements index_function_t -.
 
static int op_main_set_flag (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Set a status flag on a message - Implements index_function_t -.
 
static int op_main_show_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show currently active limit pattern - Implements index_function_t -.
 
static int op_main_sync_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox - Implements index_function_t -.
 
static int op_main_tag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag messages matching a pattern - Implements index_function_t -.
 
static int op_main_undelete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete messages matching a pattern - Implements index_function_t -.
 
static int op_main_untag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Untag messages matching a pattern - Implements index_function_t -.
 
static int op_mark_msg (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Create a hotkey macro for the current message - Implements index_function_t -.
 
static int op_next_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next entry - Implements index_function_t -.
 
static int op_pipe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Pipe message/attachment to a shell command - Implements index_function_t -.
 
static int op_prev_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous entry - Implements index_function_t -.
 
static int op_print (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Print the current entry - Implements index_function_t -.
 
static int op_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Query external program for addresses - Implements index_function_t -.
 
static int op_quit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox and quit - Implements index_function_t -.
 
static int op_recall_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Recall a postponed message - Implements index_function_t -.
 
static int op_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to a message - Implements index_function_t -.
 
static int op_resend (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Use the current message as a template for a new one - Implements index_function_t -.
 
static int op_save (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Make decrypted copy - Implements index_function_t -.
 
static int op_search (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Search for a regular expression - Implements index_function_t -.
 
static int op_sort (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Sort messages - Implements index_function_t -.
 
static int op_tag (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current entry - Implements index_function_t -.
 
static int op_tag_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current thread - Implements index_function_t -.
 
static int op_toggle_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'new' flag - Implements index_function_t -.
 
static int op_toggle_write (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle whether the mailbox will be rewritten - Implements index_function_t -.
 
static int op_undelete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete the current entry - Implements index_function_t -.
 
static int op_undelete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete all messages in thread - Implements index_function_t -.
 
static int op_view_attachments (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show MIME attachments - Implements index_function_t -.
 
static int op_autocrypt_acct_menu (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Manage autocrypt accounts - Implements index_function_t -.
 
static int op_main_imap_fetch (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Force retrieval of mail from IMAP server - Implements index_function_t -.
 
static int op_main_imap_logout_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Logout from all IMAP servers - Implements index_function_t -.
 
static int op_catchup (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark all articles in newsgroup as read - Implements index_function_t -.
 
static int op_get_children (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get all children of the current message - Implements index_function_t -.
 
static int op_get_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get parent of the current message - Implements index_function_t -.
 
static int op_main_change_group (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different newsgroup - Implements index_function_t -.
 
static int op_post (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Followup to newsgroup - Implements index_function_t -.
 
static int op_main_entire_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Read entire thread of the current message - Implements index_function_t -.
 
static int op_main_vfolder_from_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Generate virtual folder from query - Implements index_function_t -.
 
static int op_main_windowed_vfolder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Shifts virtual folder time window - Implements index_function_t -.
 
static int op_main_fetch_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Retrieve mail from POP server - Implements index_function_t -.
 

Detailed Description

Prototype for an Index Function.

Parameters
sharedShared Index data
privPrivate Index data
opOperation to perform, e.g. OP_MAIN_LIMIT
Return values
numFunctionRetval or opcode, e.g. OP_JUMP

Function Documentation

◆ op_alias_dialog()

static int op_alias_dialog ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Open the aliases dialog - Implements index_function_t -.

Definition at line 428 of file functions.c.

430{
431 alias_dialog(shared->mailbox, shared->sub);
432 return FR_SUCCESS;
433}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:39
void alias_dialog(struct Mailbox *m, struct ConfigSubset *sub)
Open the aliases dialog.
Definition dlg_alias.c:476
struct Mailbox * mailbox
Current Mailbox.
Definition shared_data.h:41
struct ConfigSubset * sub
Config set to use.
Definition shared_data.h:38
+ Here is the call graph for this function:

◆ op_attachment_edit_type()

static int op_attachment_edit_type ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Edit attachment content type - Implements index_function_t -.

Definition at line 438 of file functions.c.

440{
441 if (!shared->email)
442 return FR_NO_ACTION;
443 mutt_edit_content_type(shared->email, shared->email->body, NULL);
444
446 return FR_SUCCESS;
447}
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:37
bool mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp)
Edit the content type of an attachment.
Definition external.c:1073
void menu_queue_redraw(struct Menu *menu, MenuRedrawFlags redraw)
Queue a request for a redraw.
Definition menu.c:185
#define MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition lib.h:58
struct Body * body
List of MIME parts.
Definition email.h:69
struct Menu * menu
Menu controlling the index.
struct Email * email
Currently selected Email.
Definition shared_data.h:42
+ Here is the call graph for this function:

◆ op_bounce_message()

static int op_bounce_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Remail a message to another user - Implements index_function_t -.

Definition at line 452 of file functions.c.

454{
455 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
456 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
457 index_bounce_message(shared->mailbox, &ea);
458 ARRAY_FREE(&ea);
459
460 return FR_SUCCESS;
461}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:209
#define ARRAY_HEAD_INITIALIZER
Static initializer for arrays.
Definition array.h:58
void index_bounce_message(struct Mailbox *m, struct EmailArray *ea)
Bounce an email.
Definition external.c:90
int ea_add_tagged(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged)
Get an array of the tagged Emails.
Definition mview.c:377
bool tag_prefix
tag-prefix has been pressed
struct MailboxView * mailbox_view
Current Mailbox view.
Definition shared_data.h:40
+ Here is the call graph for this function:

◆ op_check_traditional()

static int op_check_traditional ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Check for classic PGP - Implements index_function_t -.

Definition at line 466 of file functions.c.

468{
470 return FR_NOT_IMPL;
471 if (!shared->email)
472 return FR_NO_ACTION;
473
474 if (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED))
475 {
476 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
477 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
478 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
480 ARRAY_FREE(&ea);
481 }
482
483 return FR_SUCCESS;
484}
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:36
bool mutt_check_traditional_pgp(struct Mailbox *m, struct EmailArray *ea)
Check if a message has inline PGP content.
Definition external.c:1214
#define MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:59
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition lib.h:100
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:98
#define WithCrypto
Definition lib.h:124
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition email.h:43
+ Here is the call graph for this function:

◆ op_compose_to_sender()

static int op_compose_to_sender ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Compose new message to the current message sender - Implements index_function_t -.

Definition at line 489 of file functions.c.

491{
492 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
493 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
494 int rc = mutt_send_message(SEND_TO_SENDER, NULL, NULL, shared->mailbox, &ea,
495 shared->sub);
496 ARRAY_FREE(&ea);
498
499 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
500}
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:38
int mutt_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Mailbox *m, struct EmailArray *ea, struct ConfigSubset *sub)
Send an email.
Definition send.c:2034
#define SEND_TO_SENDER
Compose new email to sender.
Definition send.h:53
+ Here is the call graph for this function:

◆ op_create_alias()

static int op_create_alias ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Create an alias from a message sender - Implements index_function_t -.

Definition at line 505 of file functions.c.

507{
508 struct AddressList *al = NULL;
509 if (shared->email && shared->email->env)
510 al = mutt_get_address(shared->email->env, NULL);
511 alias_create(al, shared->sub);
513
514 return FR_SUCCESS;
515}
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition alias.c:366
struct AddressList * mutt_get_address(struct Envelope *env, const char **prefix)
Get an Address from an Envelope.
Definition alias.c:326
struct Envelope * env
Envelope information.
Definition email.h:68
+ Here is the call graph for this function:

◆ op_delete()

static int op_delete ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Delete the current entry - Implements index_function_t -.

This function handles:

  • OP_DELETE
  • OP_PURGE_MESSAGE

Definition at line 524 of file functions.c.

525{
526 /* L10N: CHECK_ACL */
527 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete message")))
528 return FR_ERROR;
529
530 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
531 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
532
533 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, true);
534 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, (op == OP_PURGE_MESSAGE));
535 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
536 if (c_delete_untag)
537 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_TAG, false);
538 ARRAY_FREE(&ea);
539
540 if (priv->tag_prefix)
541 {
543 }
544 else
545 {
547 }
548
549 return FR_SUCCESS;
550}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
#define MUTT_ACL_DELETE
Delete a message.
Definition mailbox.h:63
bool check_acl(struct Mailbox *m, AclFlags acl, const char *msg)
Check the ACLs for a function.
Definition dlg_index.c:137
void mutt_emails_set_flag(struct Mailbox *m, struct EmailArray *ea, enum MessageType flag, bool bf)
Set flag on messages.
Definition flags.c:360
static bool resolve_email(struct IndexPrivateData *priv, struct IndexSharedData *shared, enum ResolveMethod rm)
Pick the next Email to advance the cursor to.
Definition functions.c:348
@ RESOLVE_NEXT_UNDELETED
Next undeleted email.
Definition functions.c:319
#define MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:56
#define _(a)
Definition message.h:28
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition mutt.h:77
@ MUTT_TAG
Tagged messages.
Definition mutt.h:80
@ MUTT_DELETE
Messages to be deleted.
Definition mutt.h:75
+ Here is the call graph for this function:

◆ op_delete_thread()

static int op_delete_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Delete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_DELETE_SUBTHREAD
  • OP_DELETE_THREAD
  • OP_PURGE_THREAD

Definition at line 560 of file functions.c.

562{
563 /* L10N: CHECK_ACL */
564 /* L10N: Due to the implementation details we do not know whether we
565 delete zero, 1, 12, ... messages. So in English we use
566 "messages". Your language might have other means to express this. */
567 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
568 return FR_ERROR;
569 if (!shared->email)
570 return FR_NO_ACTION;
571
572 int subthread = (op == OP_DELETE_SUBTHREAD);
573 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_DELETE, true, subthread);
574 if (rc == -1)
575 return FR_ERROR;
576 if (op == OP_PURGE_THREAD)
577 {
578 rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_PURGE, true, subthread);
579 if (rc == -1)
580 return FR_ERROR;
581 }
582
583 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
584 if (c_delete_untag)
585 mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_TAG, false, subthread);
586
589 return FR_SUCCESS;
590}
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.
Definition flags.c:384
+ Here is the call graph for this function:

◆ op_display_address()

static int op_display_address ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Display full address of sender - Implements index_function_t -.

Definition at line 595 of file functions.c.

597{
598 if (!shared->email)
599 return FR_NO_ACTION;
601
602 return FR_SUCCESS;
603}
void mutt_display_address(struct Envelope *env)
Display the address of a message.
Definition external.c:664
+ Here is the call graph for this function:

◆ op_display_message()

static int op_display_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Display a message - Implements index_function_t -.

This function handles:

  • OP_DISPLAY_HEADERS
  • OP_DISPLAY_MESSAGE

Definition at line 612 of file functions.c.

614{
615 if (!shared->email)
616 return FR_NO_ACTION;
617
619
620 /* toggle the weeding of headers so that a user can press the key
621 * again while reading the message. */
622 if (op == OP_DISPLAY_HEADERS)
623 {
624 bool_str_toggle(shared->sub, "weed", NULL);
625 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, shared);
626 if (!window_is_focused(priv->win_index))
627 return FR_SUCCESS;
628 }
629
630 OptNeedResort = false;
631
632 if (mutt_using_threads() && shared->email->collapsed)
633 {
635 mutt_set_vnum(shared->mailbox);
636 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
637 if (c_uncollapse_jump)
639 }
640
641 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
642 if (c_pgp_auto_decode &&
643 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
644 {
645 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
646 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
647 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
649 ARRAY_FREE(&ea);
650 }
651 const int index = menu_get_index(priv->menu);
653
654 const char *const c_pager = pager_get_pager(NeoMutt->sub);
655 if (c_pager)
656 {
657 op = external_pager(shared->mailbox_view, shared->email, c_pager);
658 }
659 else
660 {
661 op = mutt_display_message(priv->win_index, shared);
662 }
663
665 if (op < OP_NULL)
666 {
667 OptNeedResort = false;
668 return FR_ERROR;
669 }
670
671 if (shared->mailbox)
672 {
674 shared->mailbox->msg_count, shared);
675 }
676
677 return op;
678}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:229
@ CMD_MESSAGE_HOOK
:message-hook
Definition command.h:92
void update_index(struct Menu *menu, struct MailboxView *mv, enum MxStatus check, int oldcount, const struct IndexSharedData *shared)
Update the index.
Definition dlg_index.c:541
bool OptNeedResort
(pseudo) used to force a re-sort
Definition globals.c:63
#define NT_INDEX_EMAIL
Email has changed.
Definition lib.h:73
void index_shared_data_set_email(struct IndexSharedData *shared, struct Email *e)
Set the current Email for the Index and friends.
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition menu.c:161
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:175
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
off_t mutt_set_vnum(struct Mailbox *m)
Set the virtual index number of all the messages in a mailbox.
#define mutt_thread_next_unread(e)
#define mutt_using_threads()
#define mutt_uncollapse_thread(e)
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition mview.c:417
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition mxapi.h:63
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition notify_type.h:48
const char * pager_get_pager(struct ConfigSubset *sub)
Get the value of $pager.
Definition config.c:111
int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *shared)
Display a message in the pager.
Definition message.c:445
int external_pager(struct MailboxView *mv, struct Email *e, const char *command)
Display a message in an external program.
Definition message.c:298
void mutt_message_hook(struct Mailbox *m, struct Email *e, enum CommandId id)
Perform a message hook.
Definition run.c:132
bool collapsed
Is this message part of a collapsed thread?
Definition email.h:120
struct MuttWindow * win_index
Window for the Index.
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition shared_data.h:44
int msg_count
Total number of messages.
Definition mailbox.h:88
Container for Accounts, Notifications.
Definition neomutt.h:128
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:134
+ Here is the call graph for this function:

◆ op_edit_label()

static int op_edit_label ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Add, change, or delete a message's label - Implements index_function_t -.

Definition at line 683 of file functions.c.

684{
685 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
686 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
687 int num_changed = mutt_label_message(shared->mailbox_view, &ea);
688 ARRAY_FREE(&ea);
689
690 if (num_changed > 0)
691 {
692 shared->mailbox->changed = true;
694 /* L10N: This is displayed when the x-label on one or more
695 messages is edited. */
696 mutt_message(ngettext("%d label changed", "%d labels changed", num_changed), num_changed);
697
698 if (!priv->tag_prefix)
700 return FR_SUCCESS;
701 }
702
703 /* L10N: This is displayed when editing an x-label, but no messages
704 were updated. Possibly due to canceling at the prompt or if the new
705 label is the same as the old label. */
706 mutt_message(_("No labels changed"));
707 return FR_NO_ACTION;
708}
#define mutt_message(...)
Definition logging2.h:93
int mutt_label_message(struct MailboxView *mv, struct EmailArray *ea)
Let the user label a message.
bool changed
Mailbox has been modified.
Definition mailbox.h:110
+ Here is the call graph for this function:

◆ op_edit_raw_message()

static int op_edit_raw_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Edit the raw message (edit and edit-raw-message are synonyms) - Implements index_function_t -.

This function handles:

  • OP_EDIT_OR_VIEW_RAW_MESSAGE
  • OP_EDIT_RAW_MESSAGE
  • OP_VIEW_RAW_MESSAGE

Definition at line 718 of file functions.c.

720{
721 /* TODO split this into 3 cases? */
722 bool edit;
723 if (op == OP_EDIT_RAW_MESSAGE)
724 {
725 /* L10N: CHECK_ACL */
726 if (!check_acl(shared->mailbox, MUTT_ACL_INSERT, _("Can't edit message")))
727 return FR_ERROR;
728 edit = true;
729 }
730 else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
731 {
732 edit = !shared->mailbox->readonly && (shared->mailbox->rights & MUTT_ACL_INSERT);
733 }
734 else
735 {
736 edit = false;
737 }
738
739 if (!shared->email)
740 return FR_NO_ACTION;
741 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
742 if (c_pgp_auto_decode &&
743 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
744 {
745 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
746 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
747 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
749 ARRAY_FREE(&ea);
750 }
751 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
752 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
753 mutt_ev_message(shared->mailbox, &ea, edit ? EVM_EDIT : EVM_VIEW);
754 ARRAY_FREE(&ea);
756
757 return FR_SUCCESS;
758}
#define MUTT_ACL_INSERT
Add/copy into the mailbox (used when editing a message)
Definition mailbox.h:66
int mutt_ev_message(struct Mailbox *m, struct EmailArray *ea, enum EvMessage action)
Edit or view a message.
Definition editmsg.c:284
@ EVM_VIEW
View the message.
Definition protos.h:53
@ EVM_EDIT
Edit the message.
Definition protos.h:54
AclFlags rights
ACL bits, see AclFlags.
Definition mailbox.h:119
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:116
+ Here is the call graph for this function:

◆ op_end_cond()

static int op_end_cond ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

End of conditional execution (noop) - Implements index_function_t -.

Definition at line 763 of file functions.c.

764{
765 return FR_SUCCESS;
766}

◆ op_exit()

static int op_exit ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Exit this menu - Implements index_function_t -.

Definition at line 771 of file functions.c.

772{
773 if (shared->attach_msg)
774 return FR_DONE;
775
776 if (query_quadoption(_("Exit NeoMutt without saving?"), shared->sub, "quit") == MUTT_YES)
777 {
778 if (shared->mailbox_view)
779 {
780 mx_fastclose_mailbox(shared->mailbox, false);
781 mview_free(&shared->mailbox_view);
782 }
783 return FR_DONE;
784 }
785
786 return FR_NO_ACTION;
787}
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:35
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition mview.c:49
void mx_fastclose_mailbox(struct Mailbox *m, bool keep_account)
Free up memory associated with the Mailbox.
Definition mx.c:414
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition quad.h:39
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
Definition question.c:378
bool attach_msg
Are we in "attach message" mode?
Definition shared_data.h:46
+ Here is the call graph for this function:

◆ op_extract_keys()

static int op_extract_keys ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Extract supported public keys - Implements index_function_t -.

Definition at line 792 of file functions.c.

794{
795 if (!WithCrypto)
796 return FR_NOT_IMPL;
797 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
798 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
800 ARRAY_FREE(&ea);
802
803 return FR_SUCCESS;
804}
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailArray *ea)
Extract keys from a message.
Definition crypt.c:860
+ Here is the call graph for this function:

◆ op_flag_message()

static int op_flag_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Toggle a message's 'important' flag - Implements index_function_t -.

Definition at line 809 of file functions.c.

811{
812 /* L10N: CHECK_ACL */
813 if (!check_acl(shared->mailbox, MUTT_ACL_WRITE, _("Can't flag message")))
814 return FR_ERROR;
815
816 struct Mailbox *m = shared->mailbox;
817 if (priv->tag_prefix)
818 {
819 for (size_t i = 0; i < m->msg_count; i++)
820 {
821 struct Email *e = m->emails[i];
822 if (!e)
823 break;
824 if (message_is_tagged(e))
825 mutt_set_flag(m, e, MUTT_FLAG, !e->flagged, true);
826 }
827
829 }
830 else
831 {
832 if (!shared->email)
833 return FR_NO_ACTION;
834 mutt_set_flag(m, shared->email, MUTT_FLAG, !shared->email->flagged, true);
835
837 }
838
839 return FR_SUCCESS;
840}
#define MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition mailbox.h:71
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:56
@ MUTT_FLAG
Flagged messages.
Definition mutt.h:79
bool message_is_tagged(struct Email *e)
Is a message in the index tagged (and within limit)
Definition mview.c:363
The envelope/body of an email.
Definition email.h:39
bool flagged
Marked important?
Definition email.h:47
A mailbox.
Definition mailbox.h:79
struct Email ** emails
Array of Emails.
Definition mailbox.h:96
+ Here is the call graph for this function:

◆ op_forget_passphrase()

static int op_forget_passphrase ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Wipe passphrases from memory - Implements index_function_t -.

Definition at line 845 of file functions.c.

847{
849 return FR_SUCCESS;
850}
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition crypt.c:91
+ Here is the call graph for this function:

◆ op_forward_message()

static int op_forward_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Forward a message with comments - Implements index_function_t -.

Definition at line 855 of file functions.c.

857{
858 if (!shared->email)
859 return FR_NO_ACTION;
860 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
861 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
862 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
863 if (c_pgp_auto_decode &&
864 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
865 {
866 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
868 }
869 int rc = mutt_send_message(SEND_FORWARD, NULL, NULL, shared->mailbox, &ea,
870 shared->sub);
871 ARRAY_FREE(&ea);
873
874 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
875}
#define SEND_FORWARD
Forward email.
Definition send.h:45
+ Here is the call graph for this function:

◆ op_group_reply()

static int op_group_reply ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Reply to all recipients - Implements index_function_t -.

This function handles:

  • OP_GROUP_CHAT_REPLY
  • OP_GROUP_REPLY

Definition at line 884 of file functions.c.

886{
887 SendFlags replyflags = SEND_REPLY;
888 if (op == OP_GROUP_REPLY)
889 replyflags |= SEND_GROUP_REPLY;
890 else
891 replyflags |= SEND_GROUP_CHAT_REPLY;
892 if (!shared->email)
893 return FR_NO_ACTION;
894 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
895 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
896 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
897 if (c_pgp_auto_decode &&
898 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
899 {
900 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
902 }
903 int rc = mutt_send_message(replyflags, NULL, NULL, shared->mailbox, &ea,
904 shared->sub);
905 ARRAY_FREE(&ea);
907
908 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
909}
#define SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition send.h:54
uint32_t SendFlags
Flags for mutt_send_message(), e.g. SEND_REPLY.
Definition send.h:40
#define SEND_GROUP_REPLY
Reply to all.
Definition send.h:43
#define SEND_REPLY
Reply to sender.
Definition send.h:42
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Jump to an index number - Implements index_function_t -.

Definition at line 914 of file functions.c.

915{
916 int rc = FR_ERROR;
917 struct Buffer *buf = buf_pool_get();
918
919 const int digit = op - OP_JUMP;
920 if ((digit > 0) && (digit < 10))
921 {
922 mutt_unget_ch('0' + digit);
923 }
924
925 int msg_num = 0;
926 if ((mw_get_field(_("Jump to message: "), buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0) ||
927 buf_is_empty(buf))
928 {
929 mutt_message(_("Nothing to do"));
930 rc = FR_NO_ACTION;
931 }
932 else if (!mutt_str_atoi_full(buf_string(buf), &msg_num))
933 {
934 mutt_warning(_("Argument must be a message number"));
935 }
936 else if ((msg_num < 1) || (msg_num > shared->mailbox->msg_count))
937 {
938 mutt_warning(_("Invalid message number"));
939 }
940 else if (!shared->mailbox->emails[msg_num - 1]->visible)
941 {
942 mutt_warning(_("That message is not visible"));
943 }
944 else
945 {
946 struct Email *e = shared->mailbox->emails[msg_num - 1];
947
948 if (mutt_messages_in_thread(shared->mailbox, e, MIT_POSITION) > 1)
949 {
951 mutt_set_vnum(shared->mailbox);
952 }
953 menu_set_index(priv->menu, e->vnum);
954 rc = FR_SUCCESS;
955 }
956
957 buf_pool_release(&buf);
958 return rc;
959}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:291
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
int digit(const char *s)
void mutt_unget_ch(int ch)
Return a keystroke to the input buffer.
Definition get.c:121
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:272
#define mutt_warning(...)
Definition logging2.h:92
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition mutt.h:56
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, enum MessageInThread mit)
Count the messages in a thread.
@ MIT_POSITION
Our position in the thread.
Definition mutt_thread.h:89
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
String manipulation buffer.
Definition buffer.h:36
bool visible
Is this message part of the view?
Definition email.h:121
int vnum
Virtual message number.
Definition email.h:114
+ Here is the call graph for this function:

◆ op_list_reply()

static int op_list_reply ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Reply to specified mailing list - Implements index_function_t -.

Definition at line 964 of file functions.c.

965{
966 if (!shared->email)
967 return FR_NO_ACTION;
968 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
969 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
970 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
971 if (c_pgp_auto_decode &&
972 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
973 {
974 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
976 }
977 int rc = mutt_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL,
978 shared->mailbox, &ea, shared->sub);
979 ARRAY_FREE(&ea);
981
982 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
983}
#define SEND_LIST_REPLY
Reply to mailing list.
Definition send.h:44
+ Here is the call graph for this function:

◆ op_list_subscribe()

static int op_list_subscribe ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Subscribe to a mailing list - Implements index_function_t -.

Definition at line 988 of file functions.c.

990{
991 return mutt_send_list_subscribe(shared->mailbox, shared->email) ? FR_SUCCESS : FR_NO_ACTION;
992}
bool mutt_send_list_subscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list subscription email.
Definition send.c:2952
+ Here is the call graph for this function:

◆ op_list_unsubscribe()

static int op_list_unsubscribe ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Unsubscribe from mailing list - Implements index_function_t -.

Definition at line 997 of file functions.c.

999{
1000 return mutt_send_list_unsubscribe(shared->mailbox, shared->email) ? FR_SUCCESS : FR_NO_ACTION;
1001}
bool mutt_send_list_unsubscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list unsubscription email.
Definition send.c:2981
+ Here is the call graph for this function:

◆ op_mail()

static int op_mail ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Compose a new mail message - Implements index_function_t -.

Definition at line 1006 of file functions.c.

1007{
1008 int rc = mutt_send_message(SEND_NO_FLAGS, NULL, NULL, shared->mailbox, NULL,
1009 shared->sub);
1011 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1012}
#define SEND_NO_FLAGS
No flags are set.
Definition send.h:41
+ Here is the call graph for this function:

◆ op_mailbox_list()

static int op_mailbox_list ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

List mailboxes with new mail - Implements index_function_t -.

Definition at line 1017 of file functions.c.

1019{
1021 return FR_SUCCESS;
1022}
bool mutt_mailbox_list(void)
Show a message with the list of mailboxes with new mail.
+ Here is the call graph for this function:

◆ op_mail_key()

static int op_mail_key ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Mail a PGP public key - Implements index_function_t -.

Definition at line 1027 of file functions.c.

1028{
1029 if (!(WithCrypto & APPLICATION_PGP))
1030 return FR_NOT_IMPL;
1031 int rc = mutt_send_message(SEND_KEY, NULL, NULL, NULL, NULL, shared->sub);
1033
1034 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1035}
#define SEND_KEY
Mail a PGP public key.
Definition send.h:48
+ Here is the call graph for this function:

◆ op_main_break_thread()

static int op_main_break_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Break the thread in two - Implements index_function_t -.

Definition at line 1040 of file functions.c.

1042{
1043 struct Mailbox *m = shared->mailbox;
1044 /* L10N: CHECK_ACL */
1045 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't break thread")))
1046 return FR_ERROR;
1047
1048 struct Email *e = shared->email;
1049 if (!e)
1050 return FR_NO_ACTION;
1051
1052 if (!mutt_using_threads())
1053 {
1054 mutt_warning(_("Threading is not enabled"));
1055 return FR_NO_ACTION;
1056 }
1057
1058 struct MailboxView *mv = shared->mailbox_view;
1060 {
1061 {
1063 mutt_sort_headers(mv, true);
1064 menu_set_index(priv->menu, e->vnum);
1065 }
1066
1067 m->changed = true;
1068 mutt_message(_("Thread broken"));
1069
1071 }
1072 else
1073 {
1074 mutt_error(_("Thread can't be broken, message is not part of a thread"));
1075 }
1076
1077 return FR_SUCCESS;
1078}
void mutt_sort_headers(struct MailboxView *mv, bool init)
Sort emails by their headers.
Definition sort.c:355
#define mutt_error(...)
Definition logging2.h:94
#define STAILQ_EMPTY(head)
Definition queue.h:382
struct ListHead references
message references (in reverse order)
Definition envelope.h:83
struct ListHead in_reply_to
in-reply-to header content
Definition envelope.h:84
View of a Mailbox.
Definition mview.h:40
void mutt_break_thread(struct Email *e)
Break the email Thread.
Definition thread.c:229
+ Here is the call graph for this function:

◆ op_main_change_folder()

static int op_main_change_folder ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Open a different folder - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_FOLDER
  • OP_MAIN_CHANGE_FOLDER_READONLY
  • OP_MAIN_CHANGE_VFOLDER

Definition at line 1088 of file functions.c.

1090{
1091 struct Buffer *folderbuf = buf_pool_get();
1092 buf_alloc(folderbuf, PATH_MAX);
1093
1094 char *cp = NULL;
1095 bool read_only;
1096 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
1097 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_FOLDER_READONLY))
1098 {
1099 cp = _("Open mailbox in read-only mode");
1100 read_only = true;
1101 }
1102 else
1103 {
1104 cp = _("Open mailbox");
1105 read_only = false;
1106 }
1107
1108 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
1109 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
1110 {
1111 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
1112 buf_pretty_mailbox(folderbuf);
1113 }
1114 /* By default, fill buf with the next mailbox that contains unread mail */
1115 mutt_mailbox_next(shared->mailbox_view ? shared->mailbox : NULL, folderbuf);
1116
1117 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
1118 MUTT_SEL_NO_FLAGS) == -1)
1119 {
1120 goto changefoldercleanup;
1121 }
1122
1123 /* Selected directory is okay, let's save it. */
1125
1126 if (buf_is_empty(folderbuf))
1127 {
1128 msgwin_clear_text(NULL);
1129 goto changefoldercleanup;
1130 }
1131
1132 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
1133 if (m)
1134 {
1135 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
1136 }
1137 else
1138 {
1139 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
1140 }
1141
1142changefoldercleanup:
1143 buf_pool_release(&folderbuf);
1145
1146 return FR_SUCCESS;
1147}
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition lib.h:59
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:337
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:214
void mutt_browser_select_dir(const char *f)
Remember the last directory selected.
void change_folder_mailbox(struct Menu *menu, struct Mailbox *m, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Mailbox by pointer.
Definition dlg_index.c:610
void change_folder_string(struct Menu *menu, struct Buffer *buf, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Mailbox by string.
Definition dlg_index.c:756
int mw_enter_fname(const char *prompt, struct Buffer *fname, bool mailbox, struct Mailbox *m, bool multiple, char ***files, int *numfiles, SelectFileFlags flags)
Ask the user to select a file -.
Definition curs_lib.c:237
void msgwin_clear_text(struct MuttWindow *win)
Clear the text in the Message Window.
Definition msgwin.c:518
#define PATH_MAX
Definition mutt.h:42
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:519
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
Definition mx.c:1618
int oldcount
Old count of mails in the mailbox.
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:80
+ Here is the call graph for this function:

◆ op_main_collapse_all()

static int op_main_collapse_all ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Collapse/uncollapse all threads - Implements index_function_t -.

Definition at line 1152 of file functions.c.

1154{
1155 if (!mutt_using_threads())
1156 {
1157 mutt_error(_("Threading is not enabled"));
1158 return FR_ERROR;
1159 }
1160 collapse_all(shared->mailbox_view, priv->menu, 1);
1161 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1162
1163 return FR_SUCCESS;
1164}
void collapse_all(struct MailboxView *mv, struct Menu *menu, int toggle)
Collapse/uncollapse all threads.
Definition dlg_index.c:164
+ Here is the call graph for this function:

◆ op_main_collapse_thread()

static int op_main_collapse_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Collapse/uncollapse current thread - Implements index_function_t -.

Definition at line 1169 of file functions.c.

1171{
1172 if (!mutt_using_threads())
1173 {
1174 mutt_error(_("Threading is not enabled"));
1175 return FR_ERROR;
1176 }
1177
1178 if (!shared->email)
1179 return FR_NO_ACTION;
1180
1181 if (shared->email->collapsed)
1182 {
1183 int index = mutt_uncollapse_thread(shared->email);
1184 mutt_set_vnum(shared->mailbox);
1185 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
1186 if (c_uncollapse_jump)
1187 index = mutt_thread_next_unread(shared->email);
1188 menu_set_index(priv->menu, index);
1189 }
1190 else if (mutt_thread_can_collapse(shared->email))
1191 {
1193 mutt_set_vnum(shared->mailbox);
1194 }
1195 else
1196 {
1197 mutt_error(_("Thread contains unread or flagged messages"));
1198 return FR_ERROR;
1199 }
1200
1202 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1203
1204 return FR_SUCCESS;
1205}
bool mutt_thread_can_collapse(struct Email *e)
Check whether a thread can be collapsed.
#define mutt_collapse_thread(e)
+ Here is the call graph for this function:

◆ op_main_delete_pattern()

static int op_main_delete_pattern ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Delete messages matching a pattern - Implements index_function_t -.

Definition at line 1210 of file functions.c.

1212{
1213 /* L10N: CHECK_ACL */
1214 /* L10N: Due to the implementation details we do not know whether we
1215 delete zero, 1, 12, ... messages. So in English we use
1216 "messages". Your language might have other means to express this. */
1217 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
1218 return FR_ERROR;
1219
1220 mutt_pattern_func(shared->mailbox_view, MUTT_DELETE, _("Delete messages matching: "));
1222
1223 return FR_SUCCESS;
1224}
int mutt_pattern_func(struct MailboxView *mv, int op, char *prompt)
Perform some Pattern matching.
Definition pattern.c:308
+ Here is the call graph for this function:

◆ op_main_limit()

static int op_main_limit ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Limit view to a pattern/thread - Implements index_function_t -.

This function handles:

  • OP_LIMIT_CURRENT_THREAD
  • OP_MAIN_LIMIT
  • OP_TOGGLE_READ

Definition at line 1234 of file functions.c.

1235{
1236 const bool lmt = mview_has_limit(shared->mailbox_view);
1237 int old_index = shared->email ? shared->email->index : -1;
1238 if (op == OP_TOGGLE_READ)
1239 {
1240 char buf2[1024] = { 0 };
1241
1242 if (!lmt || !mutt_strn_equal(shared->mailbox_view->pattern, "!~R!~D~s", 8))
1243 {
1244 snprintf(buf2, sizeof(buf2), "!~R!~D~s%s", lmt ? shared->mailbox_view->pattern : ".*");
1245 }
1246 else
1247 {
1248 mutt_str_copy(buf2, shared->mailbox_view->pattern + 8, sizeof(buf2));
1249 if ((*buf2 == '\0') || mutt_strn_equal(buf2, ".*", 2))
1250 snprintf(buf2, sizeof(buf2), "~A");
1251 }
1252 mutt_str_replace(&shared->mailbox_view->pattern, buf2);
1254 }
1255
1256 if (((op == OP_LIMIT_CURRENT_THREAD) &&
1257 mutt_limit_current_thread(shared->mailbox_view, shared->email)) ||
1258 (op == OP_TOGGLE_READ) ||
1259 ((op == OP_MAIN_LIMIT) && (mutt_pattern_func(shared->mailbox_view, MUTT_LIMIT,
1260 _("Limit to messages matching: ")) == 0)))
1261 {
1262 priv->menu->max = shared->mailbox->vcount;
1263 menu_set_index(priv->menu, 0);
1264 if (old_index >= 0)
1265 {
1266 /* try to find what used to be the current message */
1267 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1268 {
1269 struct Email *e = mutt_get_virt_email(shared->mailbox, i);
1270 if (!e)
1271 continue;
1272 if (e->index == old_index)
1273 {
1274 menu_set_index(priv->menu, i);
1275 break;
1276 }
1277 }
1278 }
1279
1280 if ((shared->mailbox->msg_count != 0) && mutt_using_threads())
1281 {
1282 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
1283 if (c_collapse_all)
1284 collapse_all(shared->mailbox_view, priv->menu, 0);
1286 }
1287 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1289 }
1290 if (lmt)
1291 mutt_message(_("To view all messages, limit to \"all\""));
1292
1293 return FR_SUCCESS;
1294}
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
Definition string.c:429
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition string.c:583
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
@ MUTT_LIMIT
Messages in limited view.
Definition mutt.h:82
void mutt_draw_tree(struct ThreadsContext *tctx)
Draw a tree of threaded emails.
bool mutt_limit_current_thread(struct MailboxView *mv, struct Email *e)
Limit the email view to the current thread.
Definition mview.c:480
bool mview_has_limit(const struct MailboxView *mv)
Is a limit active?
Definition mview.c:438
int index
The absolute (unsorted) message number.
Definition email.h:110
struct ThreadsContext * threads
Threads context.
Definition mview.h:44
char * pattern
Limit pattern string.
Definition mview.h:42
int vcount
The number of virtual messages.
Definition mailbox.h:99
int max
Number of entries in the menu.
Definition lib.h:81
+ Here is the call graph for this function:

◆ op_main_link_threads()

static int op_main_link_threads ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Link tagged message to the current one - Implements index_function_t -.

Definition at line 1299 of file functions.c.

1301{
1302 struct Mailbox *m = shared->mailbox;
1303 /* L10N: CHECK_ACL */
1304 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't link threads")))
1305 return FR_ERROR;
1306
1307 struct Email *e = shared->email;
1308 if (!e)
1309 return FR_NO_ACTION;
1310
1311 enum FunctionRetval rc = FR_ERROR;
1312
1313 if (!mutt_using_threads())
1314 {
1315 mutt_error(_("Threading is not enabled"));
1316 }
1317 else if (!e->env->message_id)
1318 {
1319 mutt_error(_("No Message-ID: header available to link thread"));
1320 }
1321 else
1322 {
1323 struct MailboxView *mv = shared->mailbox_view;
1324 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1325 ea_add_tagged(&ea, mv, NULL, true);
1326
1327 if (mutt_link_threads(e, &ea, m))
1328 {
1329 mutt_sort_headers(mv, true);
1330 menu_set_index(priv->menu, e->vnum);
1331
1332 m->changed = true;
1333 mutt_message(_("Threads linked"));
1334 rc = FR_SUCCESS;
1335 }
1336 else
1337 {
1338 mutt_error(_("No thread linked"));
1339 rc = FR_NO_ACTION;
1340 }
1341
1342 ARRAY_FREE(&ea);
1343 }
1344
1346 return rc;
1347}
FunctionRetval
Possible return values for NeoMutt functions.
Definition dispatcher.h:32
bool mutt_link_threads(struct Email *parent, struct EmailArray *children, struct Mailbox *m)
Forcibly link threads together.
char * message_id
Message ID.
Definition envelope.h:73
+ Here is the call graph for this function:

◆ op_main_modify_tags()

static int op_main_modify_tags ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Modify (notmuch/imap) tags - Implements index_function_t -.

This function handles:

  • OP_MAIN_MODIFY_TAGS
  • OP_MAIN_MODIFY_TAGS_THEN_HIDE

Definition at line 1356 of file functions.c.

1358{
1359 int rc = FR_ERROR;
1360 struct Buffer *buf = NULL;
1361
1362 if (!shared->mailbox)
1363 goto done;
1364 struct Mailbox *m = shared->mailbox;
1365 if (!mx_tags_is_supported(m))
1366 {
1367 mutt_message(_("Folder doesn't support tagging, aborting"));
1368 goto done;
1369 }
1370 if (!shared->email)
1371 {
1372 rc = FR_NO_ACTION;
1373 goto done;
1374 }
1375
1376 struct Buffer *tags = buf_pool_get();
1377 if (!priv->tag_prefix)
1378 driver_tags_get_with_hidden(&shared->email->tags, tags);
1379 buf = buf_pool_get();
1380 int rc2 = mx_tags_edit(m, buf_string(tags), buf);
1381 buf_pool_release(&tags);
1382 if (rc2 < 0)
1383 {
1384 goto done;
1385 }
1386 else if (rc2 == 0)
1387 {
1388 mutt_message(_("No tag specified, aborting"));
1389 goto done;
1390 }
1391
1392 if (priv->tag_prefix)
1393 {
1394 struct Progress *progress = NULL;
1395
1396 if (m->verbose)
1397 {
1399 progress_set_message(progress, _("Update tags..."));
1400 }
1401
1402#ifdef USE_NOTMUCH
1403 if (m->type == MUTT_NOTMUCH)
1404 nm_db_longrun_init(m, true);
1405#endif
1406 for (int px = 0, i = 0; i < m->msg_count; i++)
1407 {
1408 struct Email *e = m->emails[i];
1409 if (!e)
1410 break;
1411 if (!message_is_tagged(e))
1412 continue;
1413
1414 progress_update(progress, ++px, -1);
1415 mx_tags_commit(m, e, buf_string(buf));
1416 e->attr_color = NULL;
1417 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1418 {
1419 bool still_queried = false;
1420#ifdef USE_NOTMUCH
1421 if (m->type == MUTT_NOTMUCH)
1422 still_queried = nm_message_is_still_queried(m, e);
1423#endif
1424 e->quasi_deleted = !still_queried;
1425 m->changed = true;
1426 }
1427 }
1428 progress_free(&progress);
1429#ifdef USE_NOTMUCH
1430 if (m->type == MUTT_NOTMUCH)
1432#endif
1434 }
1435 else
1436 {
1437 if (mx_tags_commit(m, shared->email, buf_string(buf)))
1438 {
1439 mutt_message(_("Failed to modify tags, aborting"));
1440 goto done;
1441 }
1442 shared->email->attr_color = NULL;
1443 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1444 {
1445 bool still_queried = false;
1446#ifdef USE_NOTMUCH
1447 if (m->type == MUTT_NOTMUCH)
1448 still_queried = nm_message_is_still_queried(m, shared->email);
1449#endif
1450 shared->email->quasi_deleted = !still_queried;
1451 m->changed = true;
1452 }
1453
1455 }
1456 rc = FR_SUCCESS;
1457
1458done:
1459 buf_pool_release(&buf);
1460 return rc;
1461}
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:51
void driver_tags_get_with_hidden(struct TagList *tl, struct Buffer *tags)
Get all tags, also hidden ones, separated by space.
Definition tags.c:174
int mx_tags_edit(struct Mailbox *m, const char *tags, struct Buffer *buf)
Start the tag editor of the mailbox.
Definition mx.c:1279
bool mx_tags_is_supported(struct Mailbox *m)
Return true if mailbox support tagging.
Definition mx.c:1316
int mx_tags_commit(struct Mailbox *m, struct Email *e, const char *tags)
Save tags to the Mailbox - Wrapper for MxOps::tags_commit()
Definition mx.c:1299
void nm_db_longrun_done(struct Mailbox *m)
Finish a long transaction.
Definition db.c:379
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition db.c:364
bool nm_message_is_still_queried(struct Mailbox *m, struct Email *e)
Is a message still visible in the query?
Definition notmuch.c:1713
@ MUTT_PROGRESS_WRITE
Progress tracks elements, according to $write_inc
Definition lib.h:85
struct Progress * progress_new(enum ProgressType type, size_t size)
Create a new Progress Bar.
Definition progress.c:139
void progress_free(struct Progress **ptr)
Free a Progress Bar.
Definition progress.c:110
void progress_set_message(struct Progress *progress, const char *fmt,...) __attribute__((__format__(__printf__
bool progress_update(struct Progress *progress, size_t pos, int percent)
Update the state of the progress bar.
Definition progress.c:80
const struct AttrColor * attr_color
Color-pair to use when displaying in the index.
Definition email.h:112
struct TagList tags
For drivers that support server tagging.
Definition email.h:72
bool quasi_deleted
Deleted from neomutt, but not modified on disk.
Definition email.h:103
enum MailboxType type
Mailbox type.
Definition mailbox.h:102
int msg_tagged
How many messages are tagged?
Definition mailbox.h:94
bool verbose
Display status messages?
Definition mailbox.h:117
+ Here is the call graph for this function:

◆ op_main_next_new()

static int op_main_next_new ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Jump to the next new message - Implements index_function_t -.

This function handles:

  • OP_MAIN_NEXT_NEW
  • OP_MAIN_NEXT_NEW_THEN_UNREAD
  • OP_MAIN_NEXT_UNREAD
  • OP_MAIN_PREV_NEW
  • OP_MAIN_PREV_NEW_THEN_UNREAD
  • OP_MAIN_PREV_UNREAD

Definition at line 1474 of file functions.c.

1476{
1477 int first_unread = -1;
1478 int first_new = -1;
1479
1480 const int saved_current = menu_get_index(priv->menu);
1481 int mcur = saved_current;
1482 int index = -1;
1483 const bool threaded = mutt_using_threads();
1484 for (size_t i = 0; i != shared->mailbox->vcount; i++)
1485 {
1486 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_NEXT_UNREAD) ||
1487 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD))
1488 {
1489 mcur++;
1490 if (mcur > (shared->mailbox->vcount - 1))
1491 {
1492 mcur = 0;
1493 }
1494 }
1495 else
1496 {
1497 mcur--;
1498 if (mcur < 0)
1499 {
1500 mcur = shared->mailbox->vcount - 1;
1501 }
1502 }
1503
1504 struct Email *e = mutt_get_virt_email(shared->mailbox, mcur);
1505 if (!e)
1506 break;
1507 if (e->collapsed && threaded)
1508 {
1509 int unread = mutt_thread_contains_unread(e);
1510 if ((unread != 0) && (first_unread == -1))
1511 first_unread = mcur;
1512 if ((unread == 1) && (first_new == -1))
1513 first_new = mcur;
1514 }
1515 else if (!e->deleted && !e->read)
1516 {
1517 if (first_unread == -1)
1518 first_unread = mcur;
1519 if (!e->old && (first_new == -1))
1520 first_new = mcur;
1521 }
1522
1523 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD)) && (first_unread != -1))
1524 {
1525 break;
1526 }
1527 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
1528 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1529 (first_new != -1))
1530 {
1531 break;
1532 }
1533 }
1534 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
1535 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1536 (first_new != -1))
1537 {
1538 index = first_new;
1539 }
1540 else if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD) ||
1541 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
1542 (first_unread != -1))
1543 {
1544 index = first_unread;
1545 }
1546
1547 if (index == -1)
1548 {
1549 menu_set_index(priv->menu, saved_current);
1550 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW))
1551 {
1552 if (mview_has_limit(shared->mailbox_view))
1553 mutt_error(_("No new messages in this limited view"));
1554 else
1555 mutt_error(_("No new messages"));
1556 }
1557 else
1558 {
1559 if (mview_has_limit(shared->mailbox_view))
1560 mutt_error(_("No unread messages in this limited view"));
1561 else
1562 mutt_error(_("No unread messages"));
1563 }
1564 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1565 return FR_ERROR;
1566 }
1567 else
1568 {
1569 menu_set_index(priv->menu, index);
1570 }
1571
1572 index = menu_get_index(priv->menu);
1573 if ((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_NEXT_UNREAD) ||
1574 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD))
1575 {
1576 if (saved_current > index)
1577 {
1578 mutt_message(_("Search wrapped to top"));
1579 }
1580 }
1581 else if (saved_current < index)
1582 {
1583 mutt_message(_("Search wrapped to bottom"));
1584 }
1585
1586 return FR_SUCCESS;
1587}
#define mutt_thread_contains_unread(e)
bool read
Email is read.
Definition email.h:50
bool old
Email is seen, but unread.
Definition email.h:49
bool threaded
Used for threading.
Definition email.h:108
bool deleted
Email is deleted.
Definition email.h:78
+ Here is the call graph for this function:

◆ op_main_next_thread()

static int op_main_next_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Jump to the next thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_NEXT_SUBTHREAD
  • OP_MAIN_NEXT_THREAD
  • OP_MAIN_PREV_SUBTHREAD
  • OP_MAIN_PREV_THREAD

Definition at line 1598 of file functions.c.

1600{
1601 int index = -1;
1602 switch (op)
1603 {
1604 case OP_MAIN_NEXT_THREAD:
1605 index = mutt_next_thread(shared->email);
1606 break;
1607
1608 case OP_MAIN_NEXT_SUBTHREAD:
1609 index = mutt_next_subthread(shared->email);
1610 break;
1611
1612 case OP_MAIN_PREV_THREAD:
1613 index = mutt_previous_thread(shared->email);
1614 break;
1615
1616 case OP_MAIN_PREV_SUBTHREAD:
1617 index = mutt_previous_subthread(shared->email);
1618 break;
1619 }
1620
1621 if (index != -1)
1622 menu_set_index(priv->menu, index);
1623
1624 if (index < 0)
1625 {
1626 if ((op == OP_MAIN_NEXT_THREAD) || (op == OP_MAIN_NEXT_SUBTHREAD))
1627 mutt_error(_("No more threads"));
1628 else
1629 mutt_error(_("You are on the first thread"));
1630
1631 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1632 }
1633
1634 return FR_SUCCESS;
1635}
#define mutt_previous_thread(e)
#define mutt_next_subthread(e)
#define mutt_previous_subthread(e)
#define mutt_next_thread(e)
+ Here is the call graph for this function:

◆ op_main_next_undeleted()

static int op_main_next_undeleted ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Move to the next undeleted message - Implements index_function_t -.

Definition at line 1640 of file functions.c.

1642{
1643 int index = menu_get_index(priv->menu);
1644 if (index >= (shared->mailbox->vcount - 1))
1645 {
1646 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1647 mutt_message(_("You are on the last message"));
1648 return FR_ERROR;
1649 }
1650
1651 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
1652
1653 index = find_next_undeleted(shared->mailbox_view, index, uncollapse);
1654 if (index != -1)
1655 {
1656 menu_set_index(priv->menu, index);
1657 if (uncollapse)
1659 }
1660
1661 if (index == -1)
1662 {
1663 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1664 mutt_error(_("No undeleted messages"));
1665 }
1666
1667 return FR_SUCCESS;
1668}
int find_next_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the next undeleted email.
Definition dlg_index.c:240
+ Here is the call graph for this function:

◆ op_main_next_unread_mailbox()

static int op_main_next_unread_mailbox ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Open next mailbox with unread mail - Implements index_function_t -.

Definition at line 1673 of file functions.c.

1675{
1676 struct Mailbox *m = shared->mailbox;
1677
1678 struct Buffer *folderbuf = buf_pool_get();
1679 buf_strcpy(folderbuf, mailbox_path(m));
1680 m = mutt_mailbox_next_unread(m, folderbuf);
1681 buf_pool_release(&folderbuf);
1682
1683 if (!m)
1684 {
1685 mutt_error(_("No mailboxes have new mail"));
1686 return FR_ERROR;
1687 }
1688
1689 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
1690 return FR_SUCCESS;
1691}
struct Mailbox * mutt_mailbox_next_unread(struct Mailbox *m_cur, struct Buffer *s)
Find next mailbox with unread mail.
+ Here is the call graph for this function:

◆ op_main_prev_undeleted()

static int op_main_prev_undeleted ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Move to the previous undeleted message - Implements index_function_t -.

Definition at line 1696 of file functions.c.

1698{
1699 int index = menu_get_index(priv->menu);
1700 if (index < 1)
1701 {
1702 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1703 mutt_message(_("You are on the first message"));
1704 return FR_ERROR;
1705 }
1706
1707 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
1708
1709 index = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
1710 if (index != -1)
1711 {
1712 menu_set_index(priv->menu, index);
1713 if (uncollapse)
1715 }
1716
1717 if (index == -1)
1718 {
1719 mutt_error(_("No undeleted messages"));
1720 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1721 }
1722
1723 return FR_SUCCESS;
1724}
int find_previous_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the previous undeleted email.
Definition dlg_index.c:274
+ Here is the call graph for this function:

◆ op_main_quasi_delete()

static int op_main_quasi_delete ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Delete from NeoMutt, don't touch on disk - Implements index_function_t -.

Definition at line 1729 of file functions.c.

1731{
1732 if (priv->tag_prefix)
1733 {
1734 struct Mailbox *m = shared->mailbox;
1735 for (size_t i = 0; i < m->msg_count; i++)
1736 {
1737 struct Email *e = m->emails[i];
1738 if (!e)
1739 break;
1740 if (message_is_tagged(e))
1741 {
1742 e->quasi_deleted = true;
1743 m->changed = true;
1744 }
1745 }
1746 }
1747 else
1748 {
1749 if (!shared->email)
1750 return FR_NO_ACTION;
1751 shared->email->quasi_deleted = true;
1752 shared->mailbox->changed = true;
1753 }
1754
1755 return FR_SUCCESS;
1756}
+ Here is the call graph for this function:

◆ op_main_read_thread()

static int op_main_read_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Mark the current thread as read - Implements index_function_t -.

This function handles:

  • OP_MAIN_READ_SUBTHREAD
  • OP_MAIN_READ_THREAD

Definition at line 1765 of file functions.c.

1767{
1768 /* L10N: CHECK_ACL */
1769 /* L10N: Due to the implementation details we do not know whether we
1770 mark zero, 1, 12, ... messages as read. So in English we use
1771 "messages". Your language might have other means to express this. */
1772 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't mark messages as read")))
1773 return FR_ERROR;
1774
1775 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_READ, true,
1776 (op != OP_MAIN_READ_THREAD));
1777 if (rc != -1)
1778 {
1779 const enum ResolveMethod rm = (op == OP_MAIN_READ_THREAD) ? RESOLVE_NEXT_THREAD :
1781 resolve_email(priv, shared, rm);
1783 }
1784
1785 return FR_SUCCESS;
1786}
#define MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition mailbox.h:70
ResolveMethod
How to advance the cursor.
Definition functions.c:317
@ RESOLVE_NEXT_SUBTHREAD
Next sibling sub-thread.
Definition functions.c:321
@ RESOLVE_NEXT_THREAD
Next top-level thread.
Definition functions.c:320
@ MUTT_READ
Messages that have been read.
Definition mutt.h:73
+ Here is the call graph for this function:

◆ op_main_root_message()

static int op_main_root_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Jump to root message in thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_PARENT_MESSAGE
  • OP_MAIN_ROOT_MESSAGE

Definition at line 1795 of file functions.c.

1797{
1798 int index = mutt_parent_message(shared->email, op == OP_MAIN_ROOT_MESSAGE);
1799 if (index != -1)
1800 menu_set_index(priv->menu, index);
1801
1802 return FR_SUCCESS;
1803}
int mutt_parent_message(struct Email *e, bool find_root)
Find the parent of a message.
+ Here is the call graph for this function:

◆ op_main_set_flag()

static int op_main_set_flag ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Set a status flag on a message - Implements index_function_t -.

This function handles:

  • OP_MAIN_CLEAR_FLAG
  • OP_MAIN_SET_FLAG

Definition at line 1812 of file functions.c.

1814{
1815 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1816 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1817
1818 if (mw_change_flag(shared->mailbox, &ea, (op == OP_MAIN_SET_FLAG)) == 0)
1819 {
1820 if (priv->tag_prefix)
1821 {
1823 }
1824 else
1825 {
1827 }
1828 }
1829 ARRAY_FREE(&ea);
1830
1831 return FR_SUCCESS;
1832}
int mw_change_flag(struct Mailbox *m, struct EmailArray *ea, bool bf)
Change the flag on a Message -.
Definition flags.c:453
+ Here is the call graph for this function:

◆ op_main_show_limit()

static int op_main_show_limit ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Show currently active limit pattern - Implements index_function_t -.

Definition at line 1837 of file functions.c.

1839{
1840 if (mview_has_limit(shared->mailbox_view))
1841 {
1842 char buf2[256] = { 0 };
1843 /* L10N: ask for a limit to apply */
1844 snprintf(buf2, sizeof(buf2), _("Limit: %s"), shared->mailbox_view->pattern);
1845 mutt_message("%s", buf2);
1846 }
1847 else
1848 {
1849 mutt_message(_("No limit pattern is in effect"));
1850 }
1851
1852 return FR_SUCCESS;
1853}
+ Here is the call graph for this function:

◆ op_main_sync_folder()

static int op_main_sync_folder ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Save changes to mailbox - Implements index_function_t -.

Definition at line 1858 of file functions.c.

1860{
1861 if (!shared->mailbox || (shared->mailbox->msg_count == 0) || shared->mailbox->readonly)
1862 return FR_NO_ACTION;
1863
1864 int ovc = shared->mailbox->vcount;
1865 int oc = shared->mailbox->msg_count;
1866 struct Email *e = NULL;
1867
1868 /* don't attempt to move the cursor if there are no visible messages in the current limit */
1869 int index = menu_get_index(priv->menu);
1870 if (index < shared->mailbox->vcount)
1871 {
1872 /* threads may be reordered, so figure out what header the cursor
1873 * should be on. */
1874 int newidx = index;
1875 if (!shared->email)
1876 return FR_NO_ACTION;
1877 if (shared->email->deleted)
1878 newidx = find_next_undeleted(shared->mailbox_view, index, false);
1879 if (newidx < 0)
1880 newidx = find_previous_undeleted(shared->mailbox_view, index, false);
1881 if (newidx >= 0)
1882 e = mutt_get_virt_email(shared->mailbox, newidx);
1883 }
1884
1885 enum MxStatus check = mx_mbox_sync(shared->mailbox);
1886 if (check == MX_STATUS_OK)
1887 {
1888 if (e && (shared->mailbox->vcount != ovc))
1889 {
1890 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1891 {
1892 struct Email *e2 = mutt_get_virt_email(shared->mailbox, i);
1893 if (e2 == e)
1894 {
1895 menu_set_index(priv->menu, i);
1896 break;
1897 }
1898 }
1899 }
1901 }
1902 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
1903 {
1904 update_index(priv->menu, shared->mailbox_view, check, oc, shared);
1905 }
1906
1907 /* do a sanity check even if mx_mbox_sync failed. */
1908
1909 index = menu_get_index(priv->menu);
1910 if ((index < 0) || (shared->mailbox && (index >= shared->mailbox->vcount)))
1911 {
1913 }
1914
1915 /* check for a fatal error, or all messages deleted */
1916 if (shared->mailbox && buf_is_empty(&shared->mailbox->pathbuf))
1917 {
1918 mview_free(&shared->mailbox_view);
1919 }
1920
1921 priv->menu->max = shared->mailbox->vcount;
1923
1924 struct EventMailbox ev_m = { shared->mailbox };
1926
1927 return FR_SUCCESS;
1928}
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:775
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:176
int find_first_message(struct MailboxView *mv)
Get index of first new message.
Definition dlg_index.c:308
enum MxStatus mx_mbox_sync(struct Mailbox *m)
Save changes to mailbox.
Definition mx.c:906
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
Definition mxapi.h:60
@ MX_STATUS_OK
No changes.
Definition mxapi.h:62
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition mxapi.h:65
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:49
An Event that happened to a Mailbox.
Definition mailbox.h:190
struct SearchState * search_state
State of the current search.
Definition shared_data.h:45
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:145
struct PatternList * pattern
compiled search pattern
+ Here is the call graph for this function:

◆ op_main_tag_pattern()

static int op_main_tag_pattern ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Tag messages matching a pattern - Implements index_function_t -.

Definition at line 1933 of file functions.c.

1935{
1936 mutt_pattern_func(shared->mailbox_view, MUTT_TAG, _("Tag messages matching: "));
1938
1939 return FR_SUCCESS;
1940}
+ Here is the call graph for this function:

◆ op_main_undelete_pattern()

static int op_main_undelete_pattern ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Undelete messages matching a pattern - Implements index_function_t -.

Definition at line 1945 of file functions.c.

1947{
1948 /* L10N: CHECK_ACL */
1949 /* L10N: Due to the implementation details we do not know whether we
1950 undelete zero, 1, 12, ... messages. So in English we use
1951 "messages". Your language might have other means to express this. */
1952 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
1953 return FR_ERROR;
1954
1956 _("Undelete messages matching: ")) == 0)
1957 {
1959 }
1960
1961 return FR_SUCCESS;
1962}
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition mutt.h:76
+ Here is the call graph for this function:

◆ op_main_untag_pattern()

static int op_main_untag_pattern ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Untag messages matching a pattern - Implements index_function_t -.

Definition at line 1967 of file functions.c.

1969{
1970 if (mutt_pattern_func(shared->mailbox_view, MUTT_UNTAG, _("Untag messages matching: ")) == 0)
1972
1973 return FR_SUCCESS;
1974}
@ MUTT_UNTAG
Messages to be un-tagged.
Definition mutt.h:81
+ Here is the call graph for this function:

◆ op_mark_msg()

static int op_mark_msg ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Create a hotkey macro for the current message - Implements index_function_t -.

Definition at line 1979 of file functions.c.

1980{
1981 if (!shared->email)
1982 return FR_NO_ACTION;
1983
1984 int rc = FR_SUCCESS;
1985
1986 if (shared->email->env->message_id)
1987 {
1988 struct Buffer *buf = buf_pool_get();
1989
1990 /* L10N: This is the prompt for <mark-message>. Whatever they
1991 enter will be prefixed by $mark_macro_prefix and will become
1992 a macro hotkey to jump to the currently selected message. */
1993 if ((mw_get_field(_("Enter macro stroke: "), buf, MUTT_COMP_NO_FLAGS,
1994 HC_OTHER, NULL, NULL) == 0) &&
1995 !buf_is_empty(buf))
1996 {
1997 const char *const c_mark_macro_prefix = cs_subset_string(shared->sub, "mark_macro_prefix");
1998 char str[256] = { 0 };
1999 snprintf(str, sizeof(str), "%s%s", c_mark_macro_prefix, buf_string(buf));
2000
2001 struct Buffer *msg_id = buf_pool_get();
2002 mutt_file_sanitize_regex(msg_id, shared->email->env->message_id);
2003 char macro[256] = { 0 };
2004 snprintf(macro, sizeof(macro), "<search>~i '%s'\n", buf_string(msg_id));
2005 buf_pool_release(&msg_id);
2006
2007 struct MenuDefinition *md = menu_find(MENU_INDEX);
2008 /* L10N: "message hotkey" is the key bindings menu description of a
2009 macro created by <mark-message>. */
2010 km_bind(md, str, OP_MACRO, macro, _("message hotkey"), NULL);
2011
2012 /* L10N: This is echoed after <mark-message> creates a new hotkey
2013 macro. %s is the hotkey string ($mark_macro_prefix followed
2014 by whatever they typed at the prompt.) */
2015 buf_printf(buf, _("Message bound to %s"), str);
2016 mutt_message("%s", buf_string(buf));
2017 mutt_debug(LL_DEBUG1, "Mark: %s => %s\n", str, macro);
2018 buf_pool_release(&buf);
2019 }
2020 }
2021 else
2022 {
2023 /* L10N: This error is printed if <mark-message> can't find a
2024 Message-ID for the currently selected message in the index. */
2025 mutt_error(_("No message ID to macro"));
2026 rc = FR_ERROR;
2027 }
2028
2029 return rc;
2030}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Definition helpers.c:291
int mutt_file_sanitize_regex(struct Buffer *dest, const char *src)
Escape any regex-magic characters in a string.
Definition file.c:632
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
enum CommandResult km_bind(struct MenuDefinition *md, const char *key_str, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
Definition menu.c:51
struct MenuDefinition * menu_find(int menu)
Find a Menu Definition by Menu type.
Definition menu.c:287
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
Functions for a Dialog or Window.
Definition menu.h:81
@ MENU_INDEX
Index panel (list of emails)
Definition type.h:44
+ Here is the call graph for this function:

◆ op_next_entry()

static int op_next_entry ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Move to the next entry - Implements index_function_t -.

Definition at line 2035 of file functions.c.

2036{
2037 const int index = menu_get_index(priv->menu) + 1;
2038 if (index >= shared->mailbox->vcount)
2039 {
2040 mutt_message(_("You are on the last message"));
2041 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2042 return FR_ERROR;
2043 }
2044 menu_set_index(priv->menu, index);
2045 return FR_SUCCESS;
2046}
+ Here is the call graph for this function:

◆ op_pipe()

static int op_pipe ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Pipe message/attachment to a shell command - Implements index_function_t -.

Definition at line 2051 of file functions.c.

2052{
2053 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2054 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2055 mutt_pipe_message(shared->mailbox, &ea);
2056 ARRAY_FREE(&ea);
2057
2058 /* in an IMAP folder index with imap_peek=no, piping could change
2059 * new or old messages status to read. Redraw what's needed. */
2060 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2061 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2062 {
2064 }
2065
2066 return FR_SUCCESS;
2067}
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:50
void mutt_pipe_message(struct Mailbox *m, struct EmailArray *ea)
Pipe a message.
Definition external.c:407
+ Here is the call graph for this function:

◆ op_prev_entry()

static int op_prev_entry ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Move to the previous entry - Implements index_function_t -.

Definition at line 2072 of file functions.c.

2073{
2074 int index = menu_get_index(priv->menu);
2075 if (index < 1)
2076 {
2077 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2078 mutt_message(_("You are on the first message"));
2079 return FR_ERROR;
2080 }
2081 menu_set_index(priv->menu, index - 1);
2082 return FR_SUCCESS;
2083}
+ Here is the call graph for this function:

◆ op_print()

static int op_print ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Print the current entry - Implements index_function_t -.

Definition at line 2088 of file functions.c.

2089{
2090 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2091 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2092 mutt_print_message(shared->mailbox, &ea);
2093 ARRAY_FREE(&ea);
2094
2095 /* in an IMAP folder index with imap_peek=no, printing could change
2096 * new or old messages status to read. Redraw what's needed. */
2097 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2098 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2099 {
2101 }
2102
2103 return FR_SUCCESS;
2104}
void mutt_print_message(struct Mailbox *m, struct EmailArray *ea)
Print a message.
Definition external.c:438
+ Here is the call graph for this function:

◆ op_query()

static int op_query ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Query external program for addresses - Implements index_function_t -.

Definition at line 2109 of file functions.c.

2110{
2111 query_index(shared->mailbox, shared->sub);
2112 return FR_SUCCESS;
2113}
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition dlg_query.c:481
+ Here is the call graph for this function:

◆ op_quit()

static int op_quit ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Save changes to mailbox and quit - Implements index_function_t -.

Definition at line 2118 of file functions.c.

2119{
2120 if (shared->attach_msg)
2121 return FR_DONE;
2122
2123 if (query_quadoption(_("Quit NeoMutt?"), shared->sub, "quit") == MUTT_YES)
2124 {
2125 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
2126
2128 mutt_debug(LL_NOTIFY, "NT_GLOBAL_SHUTDOWN\n");
2130
2131 enum MxStatus check = MX_STATUS_OK;
2132 if (!shared->mailbox_view || ((check = mx_mbox_close(shared->mailbox)) == MX_STATUS_OK))
2133 {
2134 mview_free(&shared->mailbox_view);
2135 mailbox_free(&shared->mailbox);
2136 return FR_DONE;
2137 }
2138
2139 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2140 {
2141 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2142 }
2143
2144 menu_queue_redraw(priv->menu, MENU_REDRAW_FULL); /* new mail arrived? */
2146 }
2147
2148 return FR_NO_ACTION;
2149}
@ CMD_SHUTDOWN_HOOK
:shutdown-hook
Definition command.h:108
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:90
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:50
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition mx.c:598
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition neomutt.h:156
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition notify_type.h:46
void mutt_startup_shutdown_hook(enum CommandId id)
Execute any startup/shutdown hooks.
Definition run.c:397
struct Notify * notify
Notifications handler.
Definition neomutt.h:130
+ Here is the call graph for this function:

◆ op_recall_message()

static int op_recall_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Recall a postponed message - Implements index_function_t -.

Definition at line 2154 of file functions.c.

2156{
2157 int rc = mutt_send_message(SEND_POSTPONED, NULL, NULL, shared->mailbox, NULL,
2158 shared->sub);
2160 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2161}
#define SEND_POSTPONED
Recall a postponed email.
Definition send.h:46
+ Here is the call graph for this function:

◆ op_reply()

static int op_reply ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Reply to a message - Implements index_function_t -.

Definition at line 2166 of file functions.c.

2167{
2168 if (!shared->email)
2169 return FR_NO_ACTION;
2170 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2171 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2172 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
2173 if (c_pgp_auto_decode &&
2174 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
2175 {
2176 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
2178 }
2179 int rc = mutt_send_message(SEND_REPLY, NULL, NULL, shared->mailbox, &ea,
2180 shared->sub);
2181 ARRAY_FREE(&ea);
2183
2184 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2185}
+ Here is the call graph for this function:

◆ op_resend()

static int op_resend ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Use the current message as a template for a new one - Implements index_function_t -.

Definition at line 2190 of file functions.c.

2191{
2192 int rc = -1;
2193 if (priv->tag_prefix)
2194 {
2195 struct Mailbox *m = shared->mailbox;
2196 for (size_t i = 0; i < m->msg_count; i++)
2197 {
2198 struct Email *e = m->emails[i];
2199 if (!e)
2200 break;
2201 if (message_is_tagged(e))
2202 rc = mutt_resend_message(NULL, shared->mailbox, e, shared->sub);
2203 }
2204 }
2205 else
2206 {
2207 rc = mutt_resend_message(NULL, shared->mailbox, shared->email, shared->sub);
2208 }
2209
2211 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2212}
int mutt_resend_message(FILE *fp, struct Mailbox *m, struct Email *e_cur, struct ConfigSubset *sub)
Resend an email.
Definition send.c:1549
+ Here is the call graph for this function:

◆ op_save()

static int op_save ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Make decrypted copy - Implements index_function_t -.

This function handles:

  • OP_COPY_MESSAGE
  • OP_DECODE_COPY
  • OP_DECODE_SAVE
  • OP_DECRYPT_COPY
  • OP_DECRYPT_SAVE
  • OP_SAVE

Definition at line 2225 of file functions.c.

2226{
2227 if (((op == OP_DECRYPT_COPY) || (op == OP_DECRYPT_SAVE)) && !WithCrypto)
2228 return FR_NOT_IMPL;
2229
2230 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2231 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2232
2233 const enum MessageSaveOpt save_opt = ((op == OP_SAVE) || (op == OP_DECODE_SAVE) ||
2234 (op == OP_DECRYPT_SAVE)) ?
2235 SAVE_MOVE :
2236 SAVE_COPY;
2237
2238 enum MessageTransformOpt transform_opt =
2239 ((op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY)) ? TRANSFORM_DECODE :
2240 ((op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY)) ? TRANSFORM_DECRYPT :
2242
2243 const int rc = mutt_save_message(shared->mailbox, &ea, save_opt, transform_opt);
2244 if ((rc == 0) && (save_opt == SAVE_MOVE) && !priv->tag_prefix)
2245 {
2247 }
2248 ARRAY_FREE(&ea);
2249
2250 if (priv->tag_prefix)
2252
2253 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2254}
int mutt_save_message(struct Mailbox *m, struct EmailArray *ea, enum MessageSaveOpt save_opt, enum MessageTransformOpt transform_opt)
Save an email.
Definition external.c:781
MessageTransformOpt
Message transformation option.
Definition external.h:42
@ TRANSFORM_NONE
No transformation.
Definition external.h:43
@ TRANSFORM_DECODE
Decode message.
Definition external.h:45
@ TRANSFORM_DECRYPT
Decrypt message.
Definition external.h:44
MessageSaveOpt
Message save option.
Definition external.h:52
@ SAVE_MOVE
Move message to another mailbox, removing the original.
Definition external.h:54
@ SAVE_COPY
Copy message, making a duplicate in another mailbox.
Definition external.h:53
+ Here is the call graph for this function:

◆ op_search()

static int op_search ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Search for a regular expression - Implements index_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE
  • OP_SEARCH_REVERSE

Definition at line 2265 of file functions.c.

2266{
2268 switch (op)
2269 {
2270 case OP_SEARCH:
2271 flags |= SEARCH_PROMPT;
2272 shared->search_state->reverse = false;
2273 break;
2274 case OP_SEARCH_REVERSE:
2275 flags |= SEARCH_PROMPT;
2276 shared->search_state->reverse = true;
2277 break;
2278 case OP_SEARCH_NEXT:
2279 break;
2280 case OP_SEARCH_OPPOSITE:
2281 flags |= SEARCH_OPPOSITE;
2282 break;
2283 }
2284
2285 // Initiating a search can happen on an empty mailbox, but
2286 // searching for next/previous/... needs to be on a message and
2287 // thus a non-empty mailbox
2288 int index = menu_get_index(priv->menu);
2289 index = mutt_search_command(shared->mailbox_view, priv->menu, index,
2290 shared->search_state, flags);
2291 if (index != -1)
2292 menu_set_index(priv->menu, index);
2293
2294 return FR_SUCCESS;
2295}
int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition pattern.c:475
#define SEARCH_OPPOSITE
Search in the opposite direction.
uint8_t SearchFlags
Flags for a specific search, e.g. SEARCH_PROMPT.
#define SEARCH_NO_FLAGS
No flags are set.
#define SEARCH_PROMPT
Ask for search input.
bool reverse
search backwards
+ Here is the call graph for this function:

◆ op_sort()

static int op_sort ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Sort messages - Implements index_function_t -.

This function handles:

  • OP_SORT
  • OP_SORT_REVERSE

Definition at line 2304 of file functions.c.

2305{
2306 if (!mutt_select_sort(op == OP_SORT_REVERSE))
2307 return FR_ERROR;
2308
2309 if (shared->mailbox && (shared->mailbox->msg_count != 0))
2310 {
2311 resort_index(shared->mailbox_view, priv->menu);
2313 }
2314
2315 return FR_SUCCESS;
2316}
void resort_index(struct MailboxView *mv, struct Menu *menu)
Resort the index.
Definition dlg_index.c:368
bool mutt_select_sort(bool reverse)
Ask the user for a sort method.
Definition external.c:476
+ Here is the call graph for this function:

◆ op_tag()

static int op_tag ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Tag the current entry - Implements index_function_t -.

Definition at line 2321 of file functions.c.

2322{
2323 const bool c_auto_tag = cs_subset_bool(shared->sub, "auto_tag");
2324 if (priv->tag_prefix && !c_auto_tag)
2325 {
2326 struct Mailbox *m = shared->mailbox;
2327 for (size_t i = 0; i < m->msg_count; i++)
2328 {
2329 struct Email *e = m->emails[i];
2330 if (!e)
2331 break;
2332 if (e->visible)
2333 mutt_set_flag(m, e, MUTT_TAG, false, true);
2334 }
2336 return FR_SUCCESS;
2337 }
2338
2339 if (!shared->email)
2340 return FR_NO_ACTION;
2341
2342 mutt_set_flag(shared->mailbox, shared->email, MUTT_TAG, !shared->email->tagged, true);
2343
2344 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL);
2345 return FR_SUCCESS;
2346}
@ RESOLVE_NEXT_EMAIL
Next email, whatever its state.
Definition functions.c:318
bool tagged
Email is tagged.
Definition email.h:107
+ Here is the call graph for this function:

◆ op_tag_thread()

static int op_tag_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Tag the current thread - Implements index_function_t -.

This function handles:

  • OP_TAG_SUBTHREAD
  • OP_TAG_THREAD

Definition at line 2355 of file functions.c.

2356{
2357 if (!shared->email)
2358 return FR_NO_ACTION;
2359
2360 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_TAG,
2361 !shared->email->tagged, (op != OP_TAG_THREAD));
2362 if (rc != -1)
2363 {
2364 const enum ResolveMethod rm = (op == OP_TAG_THREAD) ? RESOLVE_NEXT_THREAD :
2366 resolve_email(priv, shared, rm);
2368 }
2369
2370 return FR_SUCCESS;
2371}
+ Here is the call graph for this function:

◆ op_toggle_new()

static int op_toggle_new ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Toggle a message's 'new' flag - Implements index_function_t -.

Definition at line 2376 of file functions.c.

2377{
2378 /* L10N: CHECK_ACL */
2379 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't toggle new")))
2380 return FR_ERROR;
2381
2382 struct Mailbox *m = shared->mailbox;
2383 if (priv->tag_prefix)
2384 {
2385 for (size_t i = 0; i < m->msg_count; i++)
2386 {
2387 struct Email *e = m->emails[i];
2388 if (!e)
2389 break;
2390 if (!message_is_tagged(e))
2391 continue;
2392
2393 if (e->read || e->old)
2394 mutt_set_flag(m, e, MUTT_NEW, true, true);
2395 else
2396 mutt_set_flag(m, e, MUTT_READ, true, true);
2397 }
2399 }
2400 else
2401 {
2402 if (!shared->email)
2403 return FR_NO_ACTION;
2404 if (shared->email->read || shared->email->old)
2405 mutt_set_flag(m, shared->email, MUTT_NEW, true, true);
2406 else
2407 mutt_set_flag(m, shared->email, MUTT_READ, true, true);
2408
2410 }
2411
2412 return FR_SUCCESS;
2413}
@ MUTT_NEW
New messages.
Definition mutt.h:70
+ Here is the call graph for this function:

◆ op_toggle_write()

static int op_toggle_write ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Toggle whether the mailbox will be rewritten - Implements index_function_t -.

Definition at line 2418 of file functions.c.

2420{
2421 mx_toggle_write(shared->mailbox);
2422 return FR_SUCCESS;
2423}
int mx_toggle_write(struct Mailbox *m)
Toggle the mailbox's readonly flag.
Definition mx.c:1824
+ Here is the call graph for this function:

◆ op_undelete()

static int op_undelete ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Undelete the current entry - Implements index_function_t -.

Definition at line 2428 of file functions.c.

2429{
2430 /* L10N: CHECK_ACL */
2431 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete message")))
2432 return FR_ERROR;
2433
2434 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2435 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2436
2437 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, false);
2438 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, false);
2439 ARRAY_FREE(&ea);
2440
2441 if (priv->tag_prefix)
2442 {
2444 }
2445 else
2446 {
2447 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL);
2448 }
2449
2450 return FR_SUCCESS;
2451}
+ Here is the call graph for this function:

◆ op_undelete_thread()

static int op_undelete_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Undelete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_UNDELETE_SUBTHREAD
  • OP_UNDELETE_THREAD

Definition at line 2460 of file functions.c.

2462{
2463 /* L10N: CHECK_ACL */
2464 /* L10N: Due to the implementation details we do not know whether we
2465 undelete zero, 1, 12, ... messages. So in English we use
2466 "messages". Your language might have other means to express this. */
2467 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
2468 return FR_ERROR;
2469
2470 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_DELETE,
2471 false, (op != OP_UNDELETE_THREAD));
2472 if (rc != -1)
2473 {
2474 rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_PURGE, false,
2475 (op != OP_UNDELETE_THREAD));
2476 }
2477 if (rc != -1)
2478 {
2479 const enum ResolveMethod rm = (op == OP_UNDELETE_THREAD) ? RESOLVE_NEXT_THREAD :
2481 resolve_email(priv, shared, rm);
2483 }
2484
2485 return FR_SUCCESS;
2486}
+ Here is the call graph for this function:

◆ op_view_attachments()

static int op_view_attachments ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Show MIME attachments - Implements index_function_t -.

Definition at line 2491 of file functions.c.

2493{
2494 if (!shared->email)
2495 return FR_NO_ACTION;
2496
2497 enum FunctionRetval rc = FR_ERROR;
2498 struct Message *msg = mx_msg_open(shared->mailbox, shared->email);
2499 if (msg)
2500 {
2501 dlg_attachment(NeoMutt->sub, shared->mailbox_view, shared->email, msg->fp,
2502 shared->attach_msg);
2503 if (shared->email->attach_del)
2504 {
2505 shared->mailbox->changed = true;
2506 }
2507 mx_msg_close(shared->mailbox, &msg);
2508 rc = FR_SUCCESS;
2509 }
2511 return rc;
2512}
void dlg_attachment(struct ConfigSubset *sub, struct MailboxView *mv, struct Email *e, FILE *fp, bool attach_msg)
Show the attachments in a Menu -.
Definition dlg_attach.c:208
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
Definition mx.c:1185
struct Message * mx_msg_open(struct Mailbox *m, struct Email *e)
Return a stream pointer for a message.
Definition mx.c:1139
bool attach_del
Has an attachment marked for deletion.
Definition email.h:99
A local copy of an email.
Definition message.h:34
FILE * fp
pointer to the message data
Definition message.h:35
+ Here is the call graph for this function:

◆ op_autocrypt_acct_menu()

static int op_autocrypt_acct_menu ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Manage autocrypt accounts - Implements index_function_t -.

Definition at line 2520 of file functions.c.

2522{
2523 dlg_autocrypt();
2524 return FR_SUCCESS;
2525}
void dlg_autocrypt(void)
Display the Autocrypt account Menu -.
+ Here is the call graph for this function:

◆ op_main_imap_fetch()

static int op_main_imap_fetch ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Force retrieval of mail from IMAP server - Implements index_function_t -.

Definition at line 2531 of file functions.c.

2533{
2534 if (!shared->mailbox || (shared->mailbox->type != MUTT_IMAP))
2535 return FR_NO_ACTION;
2536
2537 imap_check_mailbox(shared->mailbox, true);
2538 return FR_SUCCESS;
2539}
enum MxStatus imap_check_mailbox(struct Mailbox *m, bool force)
Use the NOOP or IDLE command to poll for new mail.
Definition imap.c:1139
+ Here is the call graph for this function:

◆ op_main_imap_logout_all()

static int op_main_imap_logout_all ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Logout from all IMAP servers - Implements index_function_t -.

Definition at line 2544 of file functions.c.

2546{
2547 if (shared->mailbox && (shared->mailbox->type == MUTT_IMAP))
2548 {
2549 const enum MxStatus check = mx_mbox_close(shared->mailbox);
2550 if (check == MX_STATUS_OK)
2551 {
2552 mview_free(&shared->mailbox_view);
2553 }
2554 else
2555 {
2556 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2557 {
2558 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2559 }
2562 return FR_ERROR;
2563 }
2564 }
2566 mutt_message(_("Logged out of IMAP servers"));
2569
2570 return FR_SUCCESS;
2571}
void imap_logout_all(void)
Close all open connections.
Definition imap.c:660
+ Here is the call graph for this function:

◆ op_catchup()

static int op_catchup ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Mark all articles in newsgroup as read - Implements index_function_t -.

Definition at line 2576 of file functions.c.

2577{
2578 struct Mailbox *m = shared->mailbox;
2579 if (!m || (m->type != MUTT_NNTP))
2580 return FR_NO_ACTION;
2581
2582 struct NntpMboxData *mdata = m->mdata;
2583 if (mutt_newsgroup_catchup(m, mdata->adata, mdata->group))
2585
2586 return FR_SUCCESS;
2587}
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:49
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition newsrc.c:1226
void * mdata
Driver specific data.
Definition mailbox.h:132
NNTP-specific Mailbox data -.
Definition mdata.h:34
+ Here is the call graph for this function:

◆ op_get_children()

static int op_get_children ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Get all children of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_CHILDREN
  • OP_RECONSTRUCT_THREAD

Definition at line 2596 of file functions.c.

2598{
2599 struct Mailbox *m = shared->mailbox;
2600 if (m->type != MUTT_NNTP)
2601 return FR_ERROR;
2602
2603 struct Email *e = shared->email;
2604 if (!e)
2605 return FR_NO_ACTION;
2606
2607 char buf[PATH_MAX] = { 0 };
2608 int oldmsgcount = m->msg_count;
2609 int oldindex = e->index;
2610 int rc = 0;
2611
2612 if (!e->env->message_id)
2613 {
2614 mutt_error(_("No Message-Id. Unable to perform operation."));
2615 return FR_ERROR;
2616 }
2617
2618 mutt_message(_("Fetching message headers..."));
2619 if (!m->id_hash)
2620 m->id_hash = mutt_make_id_hash(m);
2621 mutt_str_copy(buf, e->env->message_id, sizeof(buf));
2622
2623 /* trying to find msgid of the root message */
2624 if (op == OP_RECONSTRUCT_THREAD)
2625 {
2626 struct ListNode *ref = NULL;
2627 STAILQ_FOREACH(ref, &e->env->references, entries)
2628 {
2629 if (!mutt_hash_find(m->id_hash, ref->data))
2630 {
2631 rc = nntp_check_msgid(m, ref->data);
2632 if (rc < 0)
2633 return FR_ERROR;
2634 }
2635
2636 /* the last msgid in References is the root message */
2637 if (!STAILQ_NEXT(ref, entries))
2638 mutt_str_copy(buf, ref->data, sizeof(buf));
2639 }
2640 }
2641
2642 /* fetching all child messages */
2643 rc = nntp_check_children(m, buf);
2644
2645 /* at least one message has been loaded */
2646 if (m->msg_count > oldmsgcount)
2647 {
2648 bool verbose = m->verbose;
2649
2650 if (rc < 0)
2651 m->verbose = false;
2652
2653 struct MailboxView *mv = shared->mailbox_view;
2654 mutt_sort_headers(mv, (op == OP_RECONSTRUCT_THREAD));
2655 m->verbose = verbose;
2656
2657 /* if the root message was retrieved, move to it */
2658 struct Email *e2 = mutt_hash_find(m->id_hash, buf);
2659 if (e2)
2660 {
2661 menu_set_index(priv->menu, e2->vnum);
2662 }
2663 else
2664 {
2665 /* try to restore old position */
2666 for (int i = 0; i < m->msg_count; i++)
2667 {
2668 e2 = m->emails[i];
2669 if (!e2)
2670 break;
2671 if (e2->index == oldindex)
2672 {
2673 menu_set_index(priv->menu, e2->vnum);
2674 /* as an added courtesy, recenter the menu
2675 * with the current entry at the middle of the screen */
2677 }
2678 }
2679 }
2681 }
2682 else if (rc >= 0)
2683 {
2684 mutt_error(_("No deleted messages found in the thread"));
2685 }
2686
2687 return FR_SUCCESS;
2688}
void * mutt_hash_find(const struct HashTable *table, const char *strkey)
Find the HashElem data in a Hash Table element using a key.
Definition hash.c:363
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition move.c:464
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
int nntp_check_msgid(struct Mailbox *m, const char *msgid)
Fetch article by Message-ID.
Definition nntp.c:2215
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition nntp.c:2286
#define STAILQ_FOREACH(var, head, field)
Definition queue.h:390
#define STAILQ_NEXT(elm, field)
Definition queue.h:439
A List node for strings.
Definition list.h:37
char * data
String.
Definition list.h:38
struct HashTable * id_hash
Hash Table: "message-id" -> Email.
Definition mailbox.h:123
+ Here is the call graph for this function:

◆ op_get_message()

static int op_get_message ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Get parent of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_MESSAGE
  • OP_GET_PARENT

Definition at line 2697 of file functions.c.

2699{
2700 struct Mailbox *m = shared->mailbox;
2701 if (m->type != MUTT_NNTP)
2702 return FR_SUCCESS;
2703
2704 int rc = FR_ERROR;
2705 struct Buffer *buf = buf_pool_get();
2706
2707 if (op == OP_GET_MESSAGE)
2708 {
2709 if ((mw_get_field(_("Enter Message-Id: "), buf, MUTT_COMP_NO_FLAGS,
2710 HC_OTHER, NULL, NULL) != 0) ||
2711 buf_is_empty(buf))
2712 {
2713 goto done;
2714 }
2715 }
2716 else
2717 {
2718 struct Email *e = shared->email;
2719 if (!e || STAILQ_EMPTY(&e->env->references))
2720 {
2721 mutt_error(_("Article has no parent reference"));
2722 goto done;
2723 }
2724 buf_strcpy(buf, STAILQ_FIRST(&e->env->references)->data);
2725 }
2726
2727 if (!m->id_hash)
2728 m->id_hash = mutt_make_id_hash(m);
2729 struct Email *e = mutt_hash_find(m->id_hash, buf_string(buf));
2730 if (e)
2731 {
2732 if (e->vnum != -1)
2733 {
2734 menu_set_index(priv->menu, e->vnum);
2735 }
2736 else if (e->collapsed)
2737 {
2739 mutt_set_vnum(m);
2740 menu_set_index(priv->menu, e->vnum);
2741 }
2742 else
2743 {
2744 mutt_error(_("Message is not visible in limited view"));
2745 }
2746 }
2747 else
2748 {
2749 mutt_message(_("Fetching %s from server..."), buf_string(buf));
2750 int rc2 = nntp_check_msgid(m, buf_string(buf));
2751 if (rc2 == 0)
2752 {
2753 e = m->emails[m->msg_count - 1];
2754 struct MailboxView *mv = shared->mailbox_view;
2755 mutt_sort_headers(mv, false);
2756 menu_set_index(priv->menu, e->vnum);
2758 rc = FR_SUCCESS;
2759 }
2760 else if (rc2 > 0)
2761 {
2762 mutt_error(_("Article %s not found on the server"), buf_string(buf));
2763 }
2764 }
2765
2766done:
2767 buf_pool_release(&buf);
2768 return rc;
2769}
#define STAILQ_FIRST(head)
Definition queue.h:388
+ Here is the call graph for this function:

◆ op_main_change_group()

static int op_main_change_group ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Open a different newsgroup - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_GROUP
  • OP_MAIN_CHANGE_GROUP_READONLY

Definition at line 2778 of file functions.c.

2780{
2781 struct Buffer *folderbuf = buf_pool_get();
2782 buf_alloc(folderbuf, PATH_MAX);
2783
2784 OptNews = false;
2785 bool read_only;
2786 char *cp = NULL;
2787 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
2788 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_GROUP_READONLY))
2789 {
2790 cp = _("Open newsgroup in read-only mode");
2791 read_only = true;
2792 }
2793 else
2794 {
2795 cp = _("Open newsgroup");
2796 read_only = false;
2797 }
2798
2799 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
2800 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
2801 {
2802 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
2803 buf_pretty_mailbox(folderbuf);
2804 }
2805
2806 OptNews = true;
2807 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
2808 if (!CurrentNewsSrv)
2809 CurrentNewsSrv = nntp_select_server(shared->mailbox, c_news_server, false);
2810 if (!CurrentNewsSrv)
2811 goto changefoldercleanup2;
2812
2813 nntp_mailbox(shared->mailbox, folderbuf->data, folderbuf->dsize);
2814
2815 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
2816 MUTT_SEL_NO_FLAGS) == -1)
2817 {
2818 goto changefoldercleanup2;
2819 }
2820
2821 /* Selected directory is okay, let's save it. */
2823
2824 if (buf_is_empty(folderbuf))
2825 {
2826 msgwin_clear_text(NULL);
2827 goto changefoldercleanup2;
2828 }
2829
2830 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
2831 if (m)
2832 {
2833 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
2834 }
2835 else
2836 {
2837 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
2838 }
2839 struct MuttWindow *dlg = dialog_find(priv->win_index);
2840 dlg->help_data = IndexNewsHelp;
2841
2842changefoldercleanup2:
2843 buf_pool_release(&folderbuf);
2844 return FR_SUCCESS;
2845}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition dialog.c:89
const struct Mapping IndexNewsHelp[]
Help Bar for the News Index dialog.
Definition dlg_index.c:116
bool OptNews
(pseudo) used to change reader mode
Definition globals.c:64
void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen)
Get first newsgroup with new messages.
Definition newsrc.c:1308
struct NntpAccountData * CurrentNewsSrv
Current NNTP news server.
Definition nntp.c:77
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition newsrc.c:945
size_t dsize
Length of data.
Definition buffer.h:39
char * data
Pointer to data.
Definition buffer.h:37
const struct Mapping * help_data
Data for the Help Bar.
+ Here is the call graph for this function:

◆ op_post()

static int op_post ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Followup to newsgroup - Implements index_function_t -.

This function handles:

  • OP_FOLLOWUP
  • OP_POST

Definition at line 2854 of file functions.c.

2855{
2856 if (!shared->email)
2857 return FR_NO_ACTION;
2858
2859 if ((op != OP_FOLLOWUP) || !shared->email->env->followup_to ||
2860 !mutt_istr_equal(shared->email->env->followup_to, "poster") ||
2861 (query_quadoption(_("Reply by mail as poster prefers?"), shared->sub,
2862 "followup_to_poster") != MUTT_YES))
2863 {
2864 if (shared->mailbox && (shared->mailbox->type == MUTT_NNTP) &&
2865 !((struct NntpMboxData *) shared->mailbox->mdata)->allowed &&
2866 (query_quadoption(_("Posting to this group not allowed, may be moderated. Continue?"),
2867 shared->sub, "post_moderated") != MUTT_YES))
2868 {
2869 return FR_ERROR;
2870 }
2871 if (op == OP_POST)
2872 {
2873 mutt_send_message(SEND_NEWS, NULL, NULL, shared->mailbox, NULL, shared->sub);
2874 }
2875 else
2876 {
2877 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2878 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2879 mutt_send_message(((op == OP_FOLLOWUP) ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS,
2880 NULL, NULL, shared->mailbox, &ea, shared->sub);
2881 ARRAY_FREE(&ea);
2882 }
2884 return FR_SUCCESS;
2885 }
2886
2887 return op_reply(shared, priv, OP_REPLY);
2888}
static int op_reply(struct AttachPrivateData *priv, int op)
reply to a message - Implements attach_function_t -
Definition functions.c:611
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:674
#define SEND_NEWS
Reply to a news article.
Definition send.h:55
char * followup_to
List of 'followup-to' fields.
Definition envelope.h:80
+ Here is the call graph for this function:

◆ op_main_entire_thread()

static int op_main_entire_thread ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Read entire thread of the current message - Implements index_function_t -.

Definition at line 2894 of file functions.c.

2896{
2897 if (shared->mailbox->type != MUTT_NOTMUCH)
2898 {
2899 if (((shared->mailbox->type != MUTT_MH) && (shared->mailbox->type != MUTT_MAILDIR)) ||
2900 (!shared->email || !shared->email->env || !shared->email->env->message_id))
2901 {
2902 mutt_message(_("No virtual folder and no Message-Id, aborting"));
2903 return FR_ERROR;
2904 } // no virtual folder, but we have message-id, reconstruct thread on-the-fly
2905
2906 struct Buffer *buf = buf_pool_get();
2907 buf_alloc(buf, PATH_MAX);
2908 buf_addstr(buf, "id:");
2909
2910 int msg_id_offset = 0;
2911 if ((shared->email->env->message_id)[0] == '<')
2912 msg_id_offset = 1;
2913
2914 buf_addstr(buf, shared->email->env->message_id + msg_id_offset);
2915
2916 size_t len = buf_len(buf);
2917 ASSERT(len > 0);
2918 if (buf->data[len - 1] == '>')
2919 buf->data[len - 1] = '\0';
2920
2921 change_folder_notmuch(priv->menu, buf->data, buf->dsize, &priv->oldcount, shared, false);
2922 buf_pool_release(&buf);
2923
2924 // If notmuch doesn't contain the message, we're left in an empty
2925 // vfolder. No messages are found, but nm_read_entire_thread assumes
2926 // a valid message-id and will throw a segfault.
2927 //
2928 // To prevent that, stay in the empty vfolder and print an error.
2929 if (shared->mailbox->msg_count == 0)
2930 {
2931 mutt_error(_("failed to find message in notmuch database. try running 'notmuch new'."));
2932 return FR_ERROR;
2933 }
2934 }
2935 priv->oldcount = shared->mailbox->msg_count;
2936 int index = menu_get_index(priv->menu);
2937 struct Email *e_oldcur = mutt_get_virt_email(shared->mailbox, index);
2938 if (!e_oldcur)
2939 return FR_ERROR;
2940
2941 if (nm_read_entire_thread(shared->mailbox, e_oldcur) < 0)
2942 {
2943 mutt_message(_("Failed to read thread, aborting"));
2944 return FR_ERROR;
2945 }
2946
2947 // nm_read_entire_thread() may modify msg_count and menu won't be updated.
2948 priv->menu->max = shared->mailbox->msg_count;
2949
2950 if (priv->oldcount < shared->mailbox->msg_count)
2951 {
2952 /* nm_read_entire_thread() triggers mutt_sort_headers() if necessary */
2953 index = e_oldcur->vnum;
2954 if (e_oldcur->collapsed || shared->mailbox_view->collapsed)
2955 {
2956 index = mutt_uncollapse_thread(e_oldcur);
2957 mutt_set_vnum(shared->mailbox);
2958 }
2959 menu_set_index(priv->menu, index);
2961 }
2962
2963 return FR_SUCCESS;
2964}
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition buffer.c:491
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition buffer.c:226
@ MUTT_MH
'MH' Mailbox type
Definition mailbox.h:47
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition mailbox.h:48
struct Mailbox * change_folder_notmuch(struct Menu *menu, char *buf, int buflen, int *oldcount, struct IndexSharedData *shared, bool read_only)
Change to a different Notmuch Mailbox by string.
Definition dlg_index.c:731
int nm_read_entire_thread(struct Mailbox *m, struct Email *e)
Get the entire thread of an email.
Definition notmuch.c:1529
#define ASSERT(COND)
Definition signal2.h:60
bool collapsed
Are all threads collapsed?
Definition mview.h:49
+ Here is the call graph for this function:

◆ op_main_vfolder_from_query()

static int op_main_vfolder_from_query ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Generate virtual folder from query - Implements index_function_t -.

This function handles:

  • OP_MAIN_VFOLDER_FROM_QUERY
  • OP_MAIN_VFOLDER_FROM_QUERY_READONLY op_main_vfolder_from_query

Definition at line 2973 of file functions.c.

2975{
2976 int rc = FR_SUCCESS;
2977 struct Buffer *buf = buf_pool_get();
2978
2979 if ((mw_get_field("Query: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2980 &CompleteNmQueryOps, NULL) != 0) ||
2981 buf_is_empty(buf))
2982 {
2983 mutt_message(_("No query, aborting"));
2984 rc = FR_NO_ACTION;
2985 goto done;
2986 }
2987
2988 // Keep copy of user's query to name the mailbox
2989 char *query_unencoded = buf_strdup(buf);
2990
2991 buf_alloc(buf, PATH_MAX);
2992 struct Mailbox *m_query = change_folder_notmuch(priv->menu, buf->data, buf->dsize,
2993 &priv->oldcount, shared,
2994 (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY));
2995 if (m_query)
2996 {
2997 FREE(&m_query->name);
2998 m_query->name = query_unencoded;
2999 query_unencoded = NULL;
3000 rc = FR_SUCCESS;
3001 }
3002 else
3003 {
3004 FREE(&query_unencoded);
3005 }
3006
3007done:
3008 buf_pool_release(&buf);
3009 return rc;
3010}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:571
#define FREE(x)
Definition memory.h:63
const struct CompleteOps CompleteNmQueryOps
Auto-Completion of NmQuerys.
Definition complete.c:247
char * name
A short name for the Mailbox.
Definition mailbox.h:82
+ Here is the call graph for this function:

◆ op_main_windowed_vfolder()

static int op_main_windowed_vfolder ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Shifts virtual folder time window - Implements index_function_t -.

This function handles:

  • OP_MAIN_WINDOWED_VFOLDER_BACKWARD
  • OP_MAIN_WINDOWED_VFOLDER_FORWARD
  • OP_MAIN_WINDOWED_VFOLDER_RESET

Definition at line 3020 of file functions.c.

3022{
3023 // Common guard clauses.
3025 {
3026 mutt_message(_("Windowed queries disabled"));
3027 return FR_ERROR;
3028 }
3029 const char *const c_nm_query_window_current_search = cs_subset_string(shared->sub, "nm_query_window_current_search");
3030 if (!c_nm_query_window_current_search)
3031 {
3032 mutt_message(_("No notmuch vfolder currently loaded"));
3033 return FR_ERROR;
3034 }
3035
3036 // Call the specific operation.
3037 switch (op)
3038 {
3039 case OP_MAIN_WINDOWED_VFOLDER_BACKWARD:
3041 break;
3042 case OP_MAIN_WINDOWED_VFOLDER_FORWARD:
3044 break;
3045 case OP_MAIN_WINDOWED_VFOLDER_RESET:
3047 break;
3048 }
3049
3050 // Common query window folder change.
3051 char buf[PATH_MAX] = { 0 };
3052 mutt_str_copy(buf, c_nm_query_window_current_search, sizeof(buf));
3053 change_folder_notmuch(priv->menu, buf, sizeof(buf), &priv->oldcount, shared, false);
3054
3055 return FR_SUCCESS;
3056}
void nm_query_window_reset(void)
Resets the vfolder window position to the present.
Definition notmuch.c:1701
void nm_query_window_backward(void)
Function to move the current search window backward in time.
Definition notmuch.c:1690
bool nm_query_window_available(void)
Are windowed queries enabled for use?
Definition notmuch.c:1653
void nm_query_window_forward(void)
Function to move the current search window forward in time.
Definition notmuch.c:1670
+ Here is the call graph for this function:

◆ op_main_fetch_mail()

static int op_main_fetch_mail ( struct IndexSharedData * shared,
struct IndexPrivateData * priv,
int op )
static

Retrieve mail from POP server - Implements index_function_t -.

Definition at line 3062 of file functions.c.

3064{
3067 return FR_SUCCESS;
3068}
void pop_fetch_mail(void)
Fetch messages and save them in $spool_file.
Definition pop.c:512
+ Here is the call graph for this function: