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

Detailed Description

Prototype for an Index Function.

Parameters
fdataIndex Function context data
eventEvent to process
Return values
numFunctionRetval or opcode, e.g. OP_NEXT_ENTRY
Precondition
fdata is not NULL
event is not NULL

Function Documentation

◆ op_alias_dialog()

static int op_alias_dialog ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open the aliases dialog - Implements index_function_t -.

Definition at line 615 of file functions.c.

616{
617 struct IndexSharedData *shared = fdata->shared;
618 alias_dialog(shared->mailbox, shared->sub);
619 return FR_SUCCESS;
620}
@ FR_SUCCESS
Valid function - successfully performed.
Definition dispatcher.h:40
void alias_dialog(struct Mailbox *m, struct ConfigSubset *sub)
Open the aliases dialog.
Definition dlg_alias.c:500
struct IndexSharedData * shared
Shared Index data.
Definition functions.h:38
Data shared between Index, Pager and Sidebar.
Definition shared_data.h:37
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_attach_edit_type()

static int op_attach_edit_type ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Edit attachment content type - Implements index_function_t -.

Definition at line 625 of file functions.c.

626{
627 struct IndexSharedData *shared = fdata->shared;
628 struct IndexPrivateData *priv = fdata->priv;
629 if (!shared->email)
630 return FR_NO_ACTION;
632
634 return FR_SUCCESS;
635}
@ FR_NO_ACTION
Valid function - no action performed.
Definition dispatcher.h:38
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:177
@ MENU_REDRAW_CURRENT
Redraw the current line of the menu.
Definition lib.h:63
struct Body * body
List of MIME parts.
Definition email.h:69
struct IndexPrivateData * priv
Private Index data.
Definition functions.h:39
Private state data for the Index.
struct IndexSharedData * shared
Shared Index data.
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Remail a message to another user - Implements index_function_t -.

Definition at line 640 of file functions.c.

641{
642 struct IndexSharedData *shared = fdata->shared;
643 struct IndexPrivateData *priv = fdata->priv;
644 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
645 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
646 index_bounce_message(shared->mailbox, &ea);
647 ARRAY_FREE(&ea);
648
649 return FR_SUCCESS;
650}
#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:87
int ea_add_tagged(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged)
Get an array of the tagged Emails.
Definition selection.c:128
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Check for classic PGP - Implements index_function_t -.

Definition at line 655 of file functions.c.

656{
657 struct IndexSharedData *shared = fdata->shared;
658 struct IndexPrivateData *priv = fdata->priv;
660 return FR_NOT_IMPL;
661 if (!shared->email)
662 return FR_NO_ACTION;
663
665 {
666 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
667 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
668 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
670 ARRAY_FREE(&ea);
671 }
672
673 return FR_SUCCESS;
674}
@ FR_NOT_IMPL
Invalid function - feature not enabled.
Definition dispatcher.h:37
bool mutt_check_traditional_pgp(struct Mailbox *m, struct EmailArray *ea)
Check if a message has inline PGP content.
Definition external.c:1214
@ MENU_REDRAW_FULL
Redraw everything.
Definition lib.h:64
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition lib.h:108
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition lib.h:106
#define WithCrypto
Definition lib.h:132
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 679 of file functions.c.

680{
681 struct IndexSharedData *shared = fdata->shared;
682 struct IndexPrivateData *priv = fdata->priv;
683 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
684 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
685 int rc = mutt_send_message(SEND_TO_SENDER, NULL, NULL, shared->mailbox, &ea,
686 shared->sub);
687 ARRAY_FREE(&ea);
689
690 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
691}
@ FR_ERROR
Valid function - error occurred.
Definition dispatcher.h:39
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:2031
@ SEND_TO_SENDER
Compose new email to sender.
Definition send.h:57
+ Here is the call graph for this function:

◆ op_create_alias()

static int op_create_alias ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 696 of file functions.c.

697{
698 struct IndexSharedData *shared = fdata->shared;
699 struct IndexPrivateData *priv = fdata->priv;
700 struct AddressList *al = NULL;
701 if (shared->email && shared->email->env)
702 al = mutt_get_address(shared->email->env, NULL);
703 alias_create(al, shared->sub);
705
706 return FR_SUCCESS;
707}
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition alias.c:369
struct AddressList * mutt_get_address(struct Envelope *env, const char **prefix)
Get an Address from an Envelope.
Definition alias.c:329
struct Envelope * env
Envelope information.
Definition email.h:68
+ Here is the call graph for this function:

◆ op_delete()

static int op_delete ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Delete the current entry - Implements index_function_t -.

This function handles:

  • OP_DELETE
  • OP_PURGE_MESSAGE

Definition at line 716 of file functions.c.

717{
718 struct IndexSharedData *shared = fdata->shared;
719 struct IndexPrivateData *priv = fdata->priv;
720 /* L10N: CHECK_ACL */
721 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete message")))
722 return FR_ERROR;
723
724 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
725 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
726 event->count);
727 if (ARRAY_EMPTY(&ea))
728 {
729 ARRAY_FREE(&ea);
730 return FR_NO_ACTION;
731 }
732
733 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, true);
734 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, (event->op == OP_PURGE_MESSAGE));
735 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
736 if (c_delete_untag)
737 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_TAG, false);
738 ARRAY_FREE(&ea);
739
740 if (priv->tag_prefix)
741 {
743 }
744 else
745 {
746 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
747 }
748
749 return FR_SUCCESS;
750}
#define ARRAY_EMPTY(head)
Check if an array is empty.
Definition array.h:74
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
@ 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:358
static int ea_add_selection(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged, int count)
Build a working set of Emails for an action.
Definition functions.c:475
static bool resolve_email(struct IndexPrivateData *priv, struct IndexSharedData *shared, enum ResolveMethod rm, int count)
Pick the next Email to advance the cursor to.
Definition functions.c:366
@ RESOLVE_NEXT_UNDELETED
Next undeleted email.
Definition functions.c:319
@ MENU_REDRAW_INDEX
Redraw the index.
Definition lib.h:61
#define _(a)
Definition message.h:28
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition mutt.h:96
@ MUTT_TAG
Tagged messages.
Definition mutt.h:99
@ MUTT_DELETE
Messages to be deleted.
Definition mutt.h:94
int count
Optional count prefix, e.g. 3 for 3j
Definition get.h:78
int op
Function opcode, e.g. OP_HELP.
Definition get.h:77
+ Here is the call graph for this function:

◆ op_delete_thread()

static int op_delete_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 868 of file functions.c.

869{
870 struct IndexSharedData *shared = fdata->shared;
871 struct IndexPrivateData *priv = fdata->priv;
872 /* L10N: CHECK_ACL */
873 /* L10N: Due to the implementation details we do not know whether we
874 delete zero, 1, 12, ... messages. So in English we use
875 "messages". Your language might have other means to express this. */
876 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
877 return FR_ERROR;
878 if (!shared->email)
879 return FR_NO_ACTION;
880
881 const int op = event->op;
882 const bool subthread = (op == OP_DELETE_SUBTHREAD);
883 int rc = 0;
884 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
885 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
886 priv->tag_prefix, subthread, event->count);
887
888 struct Email **ep = NULL;
889 ARRAY_FOREACH(ep, &ea)
890 {
891 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_DELETE, true, subthread);
892 if (rc == -1)
893 break;
894
895 if (op == OP_PURGE_THREAD)
896 {
897 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_PURGE, true, subthread);
898 if (rc == -1)
899 break;
900 }
901
902 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
903 if (c_delete_untag)
904 mutt_thread_set_flag(shared->mailbox, *ep, MUTT_TAG, false, subthread);
905 }
906 ARRAY_FREE(&ea);
907
908 if (rc == -1)
909 return FR_ERROR;
910
911 if (priv->tag_prefix)
912 {
914 return FR_SUCCESS;
915 }
916
917 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
919 return FR_SUCCESS;
920}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition array.h:223
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:382
static int ea_add_selection_threads(struct EmailArray *ea, struct MailboxView *mv, struct Email *e, bool use_tagged, bool subthread, int count)
Build a working set of threads/subthreads.
Definition functions.c:563
The envelope/body of an email.
Definition email.h:39
+ Here is the call graph for this function:

◆ op_display_address()

static int op_display_address ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Display full address of sender - Implements index_function_t -.

Definition at line 925 of file functions.c.

926{
927 struct IndexSharedData *shared = fdata->shared;
928 if (!shared->email)
929 return FR_NO_ACTION;
931
932 return FR_SUCCESS;
933}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Display a message - Implements index_function_t -.

This function handles:

  • OP_DISPLAY_HEADERS
  • OP_DISPLAY_MESSAGE
  • OP_GENERIC_SELECT_ENTRY

Definition at line 943 of file functions.c.

944{
945 struct IndexSharedData *shared = fdata->shared;
946 struct IndexPrivateData *priv = fdata->priv;
947 if (!shared->email)
948 return FR_NO_ACTION;
949
950 if (event->count > 0)
951 return op_jump(fdata, event);
952
953 int op = event->op;
954
955 if (op == OP_DISPLAY_MESSAGE)
956 {
957 if (!window_is_focused(priv->win_index))
958 return FR_SUCCESS;
959 }
960
962
963 /* toggle the weeding of headers so that a user can press the key
964 * again while reading the message. */
965 if (op == OP_DISPLAY_HEADERS)
966 {
967 bool_str_toggle(shared->sub, "weed", NULL);
969 if (!window_is_focused(priv->win_index))
970 return FR_SUCCESS;
971 }
972
973 OptNeedResort = false;
974
976 {
979 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
980 if (c_uncollapse_jump)
982 }
983
984 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
985 if (c_pgp_auto_decode &&
987 {
988 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
989 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
990 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
992 ARRAY_FREE(&ea);
993 }
994 const int index = menu_get_index(priv->menu);
996
997 const char *const c_pager = pager_get_pager(fdata->n->sub);
998 if (c_pager)
999 {
1000 op = external_pager(shared->mailbox_view, shared->email, c_pager);
1001 }
1002 else
1003 {
1004 op = mutt_display_message(priv->win_index, shared);
1005 }
1006
1008 if (op < OP_NULL)
1009 {
1010 OptNeedResort = false;
1011 return FR_ERROR;
1012 }
1013
1014 if (shared->mailbox)
1015 {
1017 shared->mailbox->msg_count, shared);
1018 }
1019
1020 return op;
1021}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:231
@ CMD_MESSAGE_HOOK
:message-hook
Definition command.h:97
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:562
bool OptNeedResort
(pseudo) used to force a re-sort
Definition globals.c:52
static int op_jump(struct AliasFunctionData *fdata, const struct KeyEvent *event)
Jump to an index number - Implements alias_function_t -.
Definition functions.c:316
off_t mutt_set_vnum(struct Mailbox *m)
Set the virtual index number of all the messages in a mailbox.
Definition thread.c:1515
#define mutt_thread_next_unread(e)
Definition thread.h:116
#define mutt_using_threads()
Definition thread.h:119
#define mutt_uncollapse_thread(e)
Definition thread.h:113
void exec_message_hook(struct Mailbox *m, struct Email *e, enum CommandId id)
Perform a message hook.
Definition exec.c:137
@ NT_INDEX_EMAIL
Email has changed.
Definition lib.h:80
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:153
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:167
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
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:378
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition mxapi.h:73
@ 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:447
int external_pager(struct MailboxView *mv, struct Email *e, const char *command)
Display a message in an external program.
Definition message.c:296
bool collapsed
Is this message part of a collapsed thread?
Definition email.h:120
struct NeoMutt * n
NeoMutt application data.
Definition functions.h:36
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:90
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ Here is the call graph for this function:

◆ op_edit_label()

static int op_edit_label ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 1026 of file functions.c.

1027{
1028 struct IndexSharedData *shared = fdata->shared;
1029 struct IndexPrivateData *priv = fdata->priv;
1030 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1031 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1032 event->count);
1033 if (ARRAY_EMPTY(&ea))
1034 {
1035 ARRAY_FREE(&ea);
1036 return FR_NO_ACTION;
1037 }
1038 const int num = ARRAY_SIZE(&ea);
1039 int num_changed = mutt_label_message(shared->mailbox_view, &ea);
1040 ARRAY_FREE(&ea);
1041
1042 if (num_changed > 0)
1043 {
1044 shared->mailbox->changed = true;
1046 /* L10N: This is displayed when the x-label on one or more
1047 messages is edited. */
1048 mutt_message(ngettext("%d label changed", "%d labels changed", num_changed), num_changed);
1049
1050 if (!priv->tag_prefix)
1051 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
1052 return FR_SUCCESS;
1053 }
1054
1055 /* L10N: This is displayed when editing an x-label, but no messages
1056 were updated. Possibly due to canceling at the prompt or if the new
1057 label is the same as the old label. */
1058 mutt_message(_("No labels changed"));
1059 return FR_NO_ACTION;
1060}
#define ARRAY_SIZE(head)
The number of elements stored.
Definition array.h:87
int mutt_label_message(struct MailboxView *mv, struct EmailArray *ea)
Let the user label a message.
Definition header.c:130
#define mutt_message(...)
Definition logging2.h:93
bool changed
Mailbox has been modified.
Definition mailbox.h:112
+ Here is the call graph for this function:

◆ op_edit_raw_message()

static int op_edit_raw_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 1070 of file functions.c.

1071{
1072 struct IndexSharedData *shared = fdata->shared;
1073 struct IndexPrivateData *priv = fdata->priv;
1074 /* TODO split this into 3 cases? */
1075 bool edit;
1076 const int op = event->op;
1077 if (op == OP_EDIT_RAW_MESSAGE)
1078 {
1079 /* L10N: CHECK_ACL */
1080 if (!check_acl(shared->mailbox, MUTT_ACL_INSERT, _("Can't edit message")))
1081 return FR_ERROR;
1082 edit = true;
1083 }
1084 else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
1085 {
1087 }
1088 else
1089 {
1090 edit = false;
1091 }
1092
1093 if (!shared->email)
1094 return FR_NO_ACTION;
1095 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1096 if (c_pgp_auto_decode &&
1098 {
1099 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1100 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1101 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1103 ARRAY_FREE(&ea);
1104 }
1105 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1106 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1107 mutt_ev_message(shared->mailbox, &ea, edit ? EVM_EDIT : EVM_VIEW);
1108 ARRAY_FREE(&ea);
1110
1111 return FR_SUCCESS;
1112}
@ 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:282
@ EVM_VIEW
View the message.
Definition mutt.h:76
@ EVM_EDIT
Edit the message.
Definition mutt.h:77
AclFlags rights
ACL bits, see AclFlags.
Definition mailbox.h:121
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:118
+ Here is the call graph for this function:

◆ op_end_cond()

static int op_end_cond ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 1117 of file functions.c.

1118{
1119 return FR_SUCCESS;
1120}

◆ op_exit()

static int op_exit ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Exit this menu - Implements index_function_t -.

Definition at line 1125 of file functions.c.

1126{
1127 struct IndexSharedData *shared = fdata->shared;
1128 if (shared->attach_msg)
1129 return FR_DONE;
1130
1131 if (query_quadoption(_("Exit NeoMutt without saving?"), shared->sub, "quit") == MUTT_YES)
1132 {
1133 if (shared->mailbox_view)
1134 {
1135 mx_fastclose_mailbox(shared->mailbox, false);
1136 mview_free(&shared->mailbox_view);
1137 }
1138 return FR_DONE;
1139 }
1140
1141 return FR_NO_ACTION;
1142}
@ FR_DONE
Exit the Dialog.
Definition dispatcher.h:36
void mview_free(struct MailboxView **ptr)
Free a MailboxView.
Definition mview.c:47
void mx_fastclose_mailbox(struct Mailbox *m, bool keep_account)
Free up memory associated with the Mailbox.
Definition mx.c:411
@ 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:384
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Extract supported public keys - Implements index_function_t -.

Definition at line 1147 of file functions.c.

1148{
1149 struct IndexSharedData *shared = fdata->shared;
1150 struct IndexPrivateData *priv = fdata->priv;
1151 if (!WithCrypto)
1152 return FR_NOT_IMPL;
1153 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1154 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1156 ARRAY_FREE(&ea);
1158
1159 return FR_SUCCESS;
1160}
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailArray *ea)
Extract keys from a message.
Definition crypt.c:864
+ Here is the call graph for this function:

◆ op_flag_message()

static int op_flag_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 1165 of file functions.c.

1166{
1167 struct IndexSharedData *shared = fdata->shared;
1168 struct IndexPrivateData *priv = fdata->priv;
1169 /* L10N: CHECK_ACL */
1170 if (!check_acl(shared->mailbox, MUTT_ACL_WRITE, _("Can't flag message")))
1171 return FR_ERROR;
1172
1173 struct Mailbox *m = shared->mailbox;
1174 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1175 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1176 event->count);
1177 if (ARRAY_EMPTY(&ea))
1178 {
1179 ARRAY_FREE(&ea);
1180 return FR_NO_ACTION;
1181 }
1182 const int num = ARRAY_SIZE(&ea);
1183
1184 struct Email **ep = NULL;
1185 ARRAY_FOREACH(ep, &ea)
1186 mutt_set_flag(m, *ep, MUTT_FLAG, !(*ep)->flagged, true);
1187 ARRAY_FREE(&ea);
1188
1189 if (priv->tag_prefix)
1190 {
1192 }
1193 else
1194 {
1195 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
1196 if (num > 1)
1198 }
1199
1200 return FR_SUCCESS;
1201}
@ 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:54
@ MUTT_FLAG
Flagged messages.
Definition mutt.h:98
A mailbox.
Definition mailbox.h:81
+ Here is the call graph for this function:

◆ op_forward_message()

static int op_forward_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Forward a message with comments - Implements index_function_t -.

Definition at line 1206 of file functions.c.

1207{
1208 struct IndexSharedData *shared = fdata->shared;
1209 struct IndexPrivateData *priv = fdata->priv;
1210 if (!shared->email)
1211 return FR_NO_ACTION;
1212 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1213 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1214 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1215 if (c_pgp_auto_decode &&
1216 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
1217 {
1218 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1220 }
1221 int rc = mutt_send_message(SEND_FORWARD, NULL, NULL, shared->mailbox, &ea,
1222 shared->sub);
1223 ARRAY_FREE(&ea);
1225
1226 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1227}
@ SEND_FORWARD
Forward email.
Definition send.h:49
+ Here is the call graph for this function:

◆ op_group_reply()

static int op_group_reply ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Reply to all recipients - Implements index_function_t -.

This function handles:

  • OP_GROUP_CHAT_REPLY
  • OP_GROUP_REPLY

Definition at line 1236 of file functions.c.

1237{
1238 struct IndexSharedData *shared = fdata->shared;
1239 struct IndexPrivateData *priv = fdata->priv;
1240 SendFlags replyflags = SEND_REPLY;
1241 if (event->op == OP_GROUP_REPLY)
1242 replyflags |= SEND_GROUP_REPLY;
1243 else
1244 replyflags |= SEND_GROUP_CHAT_REPLY;
1245 if (!shared->email)
1246 return FR_NO_ACTION;
1247 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1248 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1249 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1250 if (c_pgp_auto_decode &&
1251 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
1252 {
1253 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1255 }
1256 int rc = mutt_send_message(replyflags, NULL, NULL, shared->mailbox, &ea,
1257 shared->sub);
1258 ARRAY_FREE(&ea);
1260
1261 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1262}
uint32_t SendFlags
Definition send.h:64
@ SEND_GROUP_CHAT_REPLY
Reply to all recipients preserving To/Cc.
Definition send.h:58
@ SEND_REPLY
Reply to sender.
Definition send.h:46
@ SEND_GROUP_REPLY
Reply to all.
Definition send.h:47
+ Here is the call graph for this function:

◆ op_jump()

static int op_jump ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to an index number - Implements index_function_t -.

Definition at line 1267 of file functions.c.

1268{
1269 struct IndexSharedData *shared = fdata->shared;
1270 struct IndexPrivateData *priv = fdata->priv;
1271 int rc = FR_ERROR;
1272 struct Buffer *buf = buf_pool_get();
1273
1274 int num = event->count;
1275 if (num == 0)
1276 {
1277 if ((mw_get_field(_("Jump to message: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
1278 buf_is_empty(buf))
1279 {
1280 mutt_message(_("Nothing to do"));
1281 rc = FR_NO_ACTION;
1282 goto done;
1283 }
1284
1285 if (!mutt_str_atoi_full(buf_string(buf), &num))
1286 {
1287 mutt_warning(_("Argument must be a message number"));
1288 goto done;
1289 }
1290 }
1291
1292 if ((num < 1) || (num > shared->mailbox->msg_count))
1293 {
1294 mutt_warning(_("Invalid message number"));
1295 }
1296 else if (!shared->mailbox->emails[num - 1] ||
1297 !shared->mailbox->emails[num - 1]->visible)
1298 {
1299 mutt_warning(_("That message is not visible"));
1300 }
1301 else
1302 {
1303 struct Email *e = shared->mailbox->emails[num - 1];
1304
1305 if (mutt_messages_in_thread(shared->mailbox, e, MIT_POSITION) > 1)
1306 {
1308 mutt_set_vnum(shared->mailbox);
1309 }
1310 menu_set_index(priv->menu, e->vnum);
1311 rc = FR_SUCCESS;
1312 }
1313
1314done:
1315 buf_pool_release(&buf);
1316 return rc;
1317}
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition buffer.c:298
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ MUTT_COMP_NONE
No flags are set.
Definition wdata.h:46
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:502
#define mutt_warning(...)
Definition logging2.h:92
int mutt_messages_in_thread(struct Mailbox *m, struct Email *e, enum MessageInThread mit)
Count the messages in a thread.
Definition thread.c:1774
@ MIT_POSITION
Our position in the thread.
Definition thread.h:95
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:61
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
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
struct Email ** emails
Array of Emails.
Definition mailbox.h:98
+ Here is the call graph for this function:

◆ op_list_action()

static int op_list_action ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Show mailing-list actions - Implements index_function_t -.

Definition at line 1322 of file functions.c.

1323{
1324 struct IndexSharedData *shared = fdata->shared;
1325 struct IndexPrivateData *priv = fdata->priv;
1326
1329 return FR_SUCCESS;
1330}
void dlg_mlist(struct Mailbox *m, struct Email *e)
Display mailing-list actions for an email -.
Definition dlg_mlist.c:118
+ Here is the call graph for this function:

◆ op_list_reply()

static int op_list_reply ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Reply to specified mailing list - Implements index_function_t -.

Definition at line 1335 of file functions.c.

1336{
1337 struct IndexSharedData *shared = fdata->shared;
1338 struct IndexPrivateData *priv = fdata->priv;
1339 if (!shared->email)
1340 return FR_NO_ACTION;
1341 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1342 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1343 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1344 if (c_pgp_auto_decode &&
1345 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
1346 {
1347 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1349 }
1350 int rc = mutt_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL,
1351 shared->mailbox, &ea, shared->sub);
1352 ARRAY_FREE(&ea);
1354
1355 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1356}
@ SEND_LIST_REPLY
Reply to mailing list.
Definition send.h:48
+ Here is the call graph for this function:

◆ op_list_subscribe()

static int op_list_subscribe ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Subscribe to a mailing list - Implements index_function_t -.

Definition at line 1361 of file functions.c.

1362{
1363 struct IndexSharedData *shared = fdata->shared;
1364 return mutt_send_list_subscribe(shared->mailbox, shared->email) ? FR_SUCCESS : FR_ERROR;
1365}
bool mutt_send_list_subscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list subscription email.
Definition send.c:2957
+ Here is the call graph for this function:

◆ op_list_unsubscribe()

static int op_list_unsubscribe ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Unsubscribe from mailing list - Implements index_function_t -.

Definition at line 1370 of file functions.c.

1371{
1372 struct IndexSharedData *shared = fdata->shared;
1373 return mutt_send_list_unsubscribe(shared->mailbox, shared->email) ? FR_SUCCESS : FR_ERROR;
1374}
bool mutt_send_list_unsubscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list unsubscription email.
Definition send.c:2986
+ Here is the call graph for this function:

◆ op_mail()

static int op_mail ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Compose a new mail message - Implements index_function_t -.

Definition at line 1379 of file functions.c.

1380{
1381 struct IndexSharedData *shared = fdata->shared;
1382 struct IndexPrivateData *priv = fdata->priv;
1383 int rc = mutt_send_message(SEND_NONE, NULL, NULL, shared->mailbox, NULL,
1384 shared->sub);
1386 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1387}
@ SEND_NONE
No flags are set.
Definition send.h:45
+ Here is the call graph for this function:

◆ op_mailbox_list()

static int op_mailbox_list ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

List mailboxes with new mail - Implements index_function_t -.

Definition at line 1392 of file functions.c.

1393{
1395 return FR_SUCCESS;
1396}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Mail a PGP public key - Implements index_function_t -.

Definition at line 1401 of file functions.c.

1402{
1403 struct IndexSharedData *shared = fdata->shared;
1404 struct IndexPrivateData *priv = fdata->priv;
1405 if (!(WithCrypto & APPLICATION_PGP))
1406 return FR_NOT_IMPL;
1407 int rc = mutt_send_message(SEND_KEY, NULL, NULL, NULL, NULL, shared->sub);
1409
1410 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1411}
@ SEND_KEY
Mail a PGP public key.
Definition send.h:52
+ Here is the call graph for this function:

◆ op_main_break_thread()

static int op_main_break_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Break the thread in two - Implements index_function_t -.

Definition at line 1416 of file functions.c.

1417{
1418 struct IndexSharedData *shared = fdata->shared;
1419 struct IndexPrivateData *priv = fdata->priv;
1420 struct Mailbox *m = shared->mailbox;
1421 /* L10N: CHECK_ACL */
1422 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't break thread")))
1423 return FR_ERROR;
1424
1425 struct Email *e = shared->email;
1426 if (!e)
1427 return FR_NO_ACTION;
1428
1429 const bool has_repeat_count = (event->count > 0);
1430
1431 if (!mutt_using_threads())
1432 {
1433 mutt_warning(_("Threading is not enabled"));
1434 return FR_ERROR;
1435 }
1436
1437 struct MailboxView *mv = shared->mailbox_view;
1438 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1439 if (ea_add_selection(&ea, mv, e, false, event->count) <= 0)
1440 {
1441 ARRAY_FREE(&ea);
1442 return FR_NO_ACTION;
1443 }
1444
1445 bool changed = false;
1446 struct Email **ep = NULL;
1447 ARRAY_FOREACH(ep, &ea)
1448 {
1449 e = *ep;
1450 if (!e || (STAILQ_EMPTY(&e->env->in_reply_to) && STAILQ_EMPTY(&e->env->references)))
1451 continue;
1452
1453 {
1455 changed = true;
1456 }
1457 }
1458 ARRAY_FREE(&ea);
1459
1460 if (changed)
1461 {
1462 mutt_sort_headers(mv, true);
1463 menu_set_index(priv->menu, shared->email->vnum);
1464 m->changed = true;
1465 mutt_message(_("Thread broken"));
1466
1468 }
1469 else if (!has_repeat_count)
1470 {
1471 mutt_error(_("Thread can't be broken, message is not part of a thread"));
1472 return FR_ERROR;
1473 }
1474
1475 return FR_SUCCESS;
1476}
void mutt_sort_headers(struct MailboxView *mv, bool init)
Sort emails by their headers.
Definition sort.c:358
void mutt_break_thread(struct Email *e)
Break the email Thread.
Definition thread.c:229
#define mutt_error(...)
Definition logging2.h:94
#define STAILQ_EMPTY(head)
Definition queue.h:382
bool changed
Email has been edited.
Definition email.h:77
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
+ Here is the call graph for this function:

◆ op_main_change_folder()

static int op_main_change_folder ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 1486 of file functions.c.

1487{
1488 struct IndexSharedData *shared = fdata->shared;
1489 struct IndexPrivateData *priv = fdata->priv;
1490 struct Buffer *folderbuf = buf_pool_get();
1491 buf_alloc(folderbuf, PATH_MAX);
1492
1493 char *cp = NULL;
1494 bool read_only;
1495 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
1496 const int op = event->op;
1497 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_FOLDER_READONLY))
1498 {
1499 cp = _("Open mailbox in read-only mode");
1500 read_only = true;
1501 }
1502 else
1503 {
1504 cp = _("Open mailbox");
1505 read_only = false;
1506 }
1507
1508 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
1509 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
1510 {
1511 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
1512 pretty_mailbox(folderbuf);
1513 }
1514 /* By default, fill buf with the next mailbox that contains unread mail */
1515 mutt_mailbox_next(shared->mailbox_view ? shared->mailbox : NULL, folderbuf);
1516
1517 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
1518 MUTT_SEL_NONE) == -1)
1519 {
1520 goto changefoldercleanup;
1521 }
1522
1523 /* Selected directory is okay, let's save it. */
1525
1526 if (buf_is_empty(folderbuf))
1527 {
1528 msgwin_clear_text(NULL);
1529 goto changefoldercleanup;
1530 }
1531
1532 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
1533 if (m)
1534 {
1535 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
1536 }
1537 else
1538 {
1539 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
1540 }
1541
1542changefoldercleanup:
1543 buf_pool_release(&folderbuf);
1545
1546 return FR_SUCCESS;
1547}
@ MUTT_SEL_NONE
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:401
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:342
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
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:631
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:777
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:556
#define PATH_MAX
Definition mutt.h:49
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
void pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:428
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:82
+ Here is the call graph for this function:

◆ op_main_collapse_all()

static int op_main_collapse_all ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Collapse/uncollapse all threads - Implements index_function_t -.

Definition at line 1552 of file functions.c.

1553{
1554 struct IndexSharedData *shared = fdata->shared;
1555 struct IndexPrivateData *priv = fdata->priv;
1556 if (!mutt_using_threads())
1557 {
1558 mutt_warning(_("Threading is not enabled"));
1559 return FR_ERROR;
1560 }
1563
1564 return FR_SUCCESS;
1565}
void collapse_all(struct MailboxView *mv, struct Menu *menu, enum CollapseMode mode)
Collapse/uncollapse all threads.
Definition dlg_index.c:161
@ COLLAPSE_MODE_TOGGLE
Toggle collapsed state.
Definition lib.h:103
+ Here is the call graph for this function:

◆ op_main_close_all_threads()

static int op_main_close_all_threads ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Collapse all threads - Implements index_function_t -.

Definition at line 1570 of file functions.c.

1572{
1573 struct IndexSharedData *shared = fdata->shared;
1574 struct IndexPrivateData *priv = fdata->priv;
1575 if (!mutt_using_threads())
1576 {
1577 mutt_warning(_("Threading is not enabled"));
1578 return FR_ERROR;
1579 }
1580
1582 return FR_NO_ACTION;
1583
1586
1587 return FR_SUCCESS;
1588}
@ COLLAPSE_MODE_CLOSE
Collapse all threads.
Definition lib.h:104
bool collapsed
Are all threads collapsed?
Definition mview.h:49
+ Here is the call graph for this function:

◆ op_main_close_thread()

static int op_main_close_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Collapse current thread - Implements index_function_t -.

Definition at line 1593 of file functions.c.

1594{
1595 struct IndexSharedData *shared = fdata->shared;
1596 struct IndexPrivateData *priv = fdata->priv;
1597 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1598 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1599 priv->tag_prefix, false, event->count);
1600 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_CLOSE);
1601 ARRAY_FREE(&ea);
1602 return rc;
1603}
static int op_main_change_thread(struct IndexFunctionData *fdata, struct EmailArray *ea, enum CollapseMode mode)
Open/close/collapse a working set of threads.
Definition functions.c:782
+ Here is the call graph for this function:

◆ op_main_collapse_thread()

static int op_main_collapse_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Collapse/uncollapse current thread - Implements index_function_t -.

Definition at line 1608 of file functions.c.

1609{
1610 struct IndexSharedData *shared = fdata->shared;
1611 struct IndexPrivateData *priv = fdata->priv;
1612 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1613 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1614 priv->tag_prefix, false, event->count);
1615 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_TOGGLE);
1616 ARRAY_FREE(&ea);
1617 return rc;
1618}
+ Here is the call graph for this function:

◆ op_main_open_all_threads()

static int op_main_open_all_threads ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open all threads - Implements index_function_t -.

Definition at line 1623 of file functions.c.

1625{
1626 struct IndexSharedData *shared = fdata->shared;
1627 struct IndexPrivateData *priv = fdata->priv;
1628 if (!mutt_using_threads())
1629 {
1630 mutt_warning(_("Threading is not enabled"));
1631 return FR_ERROR;
1632 }
1633
1635 return FR_NO_ACTION;
1636
1639
1640 return FR_SUCCESS;
1641}
@ COLLAPSE_MODE_OPEN
Open all threads.
Definition lib.h:105
+ Here is the call graph for this function:

◆ op_main_open_thread()

static int op_main_open_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open current thread - Implements index_function_t -.

Definition at line 1646 of file functions.c.

1647{
1648 struct IndexSharedData *shared = fdata->shared;
1649 struct IndexPrivateData *priv = fdata->priv;
1650 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1651 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1652 priv->tag_prefix, false, event->count);
1653 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_OPEN);
1654 ARRAY_FREE(&ea);
1655 return rc;
1656}
+ Here is the call graph for this function:

◆ op_main_delete_pattern()

static int op_main_delete_pattern ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Delete messages matching a pattern - Implements index_function_t -.

Definition at line 1661 of file functions.c.

1662{
1663 struct IndexSharedData *shared = fdata->shared;
1664 struct IndexPrivateData *priv = fdata->priv;
1665 /* L10N: CHECK_ACL */
1666 /* L10N: Due to the implementation details we do not know whether we
1667 delete zero, 1, 12, ... messages. So in English we use
1668 "messages". Your language might have other means to express this. */
1669 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
1670 return FR_ERROR;
1671
1672 mutt_pattern_func(shared->mailbox_view, MUTT_DELETE, _("Delete messages matching: "));
1674
1675 return FR_SUCCESS;
1676}
int mutt_pattern_func(struct MailboxView *mv, int op, char *prompt)
Perform some Pattern matching.
Definition pattern.c:295
+ Here is the call graph for this function:

◆ op_main_limit()

static int op_main_limit ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 1686 of file functions.c.

1687{
1688 struct IndexSharedData *shared = fdata->shared;
1689 struct IndexPrivateData *priv = fdata->priv;
1690 const bool lmt = mview_has_limit(shared->mailbox_view);
1691 int old_index = shared->email ? shared->email->index : -1;
1692 const int op = event->op;
1693 if (op == OP_TOGGLE_READ)
1694 {
1695 struct Buffer *buf2 = buf_pool_get();
1696
1697 if (!lmt || !mutt_strn_equal(shared->mailbox_view->pattern, "!~R!~D~s", 8))
1698 {
1699 buf_printf(buf2, "!~R!~D~s%s", lmt ? shared->mailbox_view->pattern : ".*");
1700 }
1701 else
1702 {
1703 const char *pat = shared->mailbox_view->pattern + 8;
1704 if ((*pat == '\0') || mutt_strn_equal(pat, ".*", 2))
1705 buf_strcpy(buf2, "~A");
1706 else
1707 buf_strcpy(buf2, pat);
1708 }
1710 buf_pool_release(&buf2);
1712 }
1713
1714 if (((op == OP_LIMIT_CURRENT_THREAD) &&
1715 mutt_limit_current_thread(shared->mailbox_view, shared->email)) ||
1716 (op == OP_TOGGLE_READ) ||
1717 ((op == OP_MAIN_LIMIT) && (mutt_pattern_func(shared->mailbox_view, MUTT_LIMIT,
1718 _("Limit to messages matching: ")) == 0)))
1719 {
1720 priv->menu->max = shared->mailbox->vcount;
1721 menu_set_index(priv->menu, 0);
1722 if (old_index >= 0)
1723 {
1724 /* try to find what used to be the current message */
1725 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1726 {
1727 struct Email *e = mutt_get_virt_email(shared->mailbox, i);
1728 if (!e)
1729 continue;
1730 if (e->index == old_index)
1731 {
1732 menu_set_index(priv->menu, i);
1733 break;
1734 }
1735 }
1736 }
1737
1738 if ((shared->mailbox->msg_count != 0) && mutt_using_threads())
1739 {
1740 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
1741 if (c_collapse_all)
1744 }
1745 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1747 }
1748 if (lmt)
1749 mutt_message(_("To view all messages, limit to \"all\""));
1750
1751 return FR_SUCCESS;
1752}
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:168
void mutt_draw_tree(struct ThreadsContext *tctx)
Draw a tree of threaded emails.
Definition thread.c:465
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
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:101
bool mutt_limit_current_thread(struct MailboxView *mv, struct Email *e)
Limit the email view to the current thread.
Definition mview.c:441
bool mview_has_limit(const struct MailboxView *mv)
Is a limit active?
Definition mview.c:399
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:101
int max
Number of entries in the menu.
Definition lib.h:88
+ Here is the call graph for this function:

◆ op_main_link_threads()

static int op_main_link_threads ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

<link-threads> is only meaningful with tagged emails. Let the user run the function with or without <tag-prefix>.

Definition at line 1760 of file functions.c.

1761{
1762 struct IndexSharedData *shared = fdata->shared;
1763 struct IndexPrivateData *priv = fdata->priv;
1764 struct Mailbox *m = shared->mailbox;
1765 /* L10N: CHECK_ACL */
1766 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't link threads")))
1767 return FR_ERROR;
1768
1769 struct Email *e = shared->email;
1770 if (!e)
1771 return FR_NO_ACTION;
1772
1773 enum FunctionRetval rc = FR_ERROR;
1774
1775 if (!mutt_using_threads())
1776 {
1777 mutt_warning(_("Threading is not enabled"));
1778 rc = FR_ERROR;
1779 }
1780 else if (!e->env->message_id)
1781 {
1782 mutt_error(_("No Message-ID: header available to link thread"));
1783 }
1784 else
1785 {
1786 struct MailboxView *mv = shared->mailbox_view;
1787 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1788
1789 // If there's a repeat-count, use it.
1790 // If not, behave as if <tag-prefix> has been pressed.
1791 const bool tag_prefix = (event->count < 1);
1792 ea_add_selection(&ea, mv, e, tag_prefix, event->count);
1793
1794 if (!tag_prefix)
1795 {
1796 struct Email **ep = ARRAY_GET(&ea, 0);
1797 if (ep && (*ep == e))
1798 ARRAY_REMOVE(&ea, ep);
1799 }
1800
1801 if (mutt_link_threads(e, &ea, m))
1802 {
1803 mutt_sort_headers(mv, true);
1804 menu_set_index(priv->menu, e->vnum);
1805
1806 m->changed = true;
1807 mutt_message(_("Threads linked"));
1808 rc = FR_SUCCESS;
1809 }
1810 else
1811 {
1812 mutt_error(_("No thread linked"));
1813 rc = FR_ERROR;
1814 }
1815
1816 ARRAY_FREE(&ea);
1817 }
1818
1820 return rc;
1821}
#define ARRAY_REMOVE(head, elem)
Remove an entry from the array, shifting down the subsequent entries.
Definition array.h:355
#define ARRAY_GET(head, idx)
Return the element at index.
Definition array.h:109
FunctionRetval
Possible return values for NeoMutt functions.
Definition dispatcher.h:33
bool mutt_link_threads(struct Email *parent, struct EmailArray *children, struct Mailbox *m)
Forcibly link threads together.
Definition thread.c:1870
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
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 1830 of file functions.c.

1831{
1832 struct IndexSharedData *shared = fdata->shared;
1833 struct IndexPrivateData *priv = fdata->priv;
1834 int rc = FR_ERROR;
1835 struct Buffer *buf = NULL;
1836 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1837
1838 if (!shared->mailbox)
1839 goto done;
1840 struct Mailbox *m = shared->mailbox;
1841 if (!mx_tags_is_supported(m))
1842 {
1843 mutt_message(_("Folder doesn't support tagging, aborting"));
1844 goto done;
1845 }
1846 if (!shared->email)
1847 {
1848 rc = FR_NO_ACTION;
1849 goto done;
1850 }
1851
1852 const int op = event->op;
1853 struct Buffer *tags = buf_pool_get();
1854 if (!priv->tag_prefix)
1855 driver_tags_get_with_hidden(&shared->email->tags, tags);
1856 /* Prompt the user to edit the tag string */
1857 buf = buf_pool_get();
1858 int rc2 = mx_tags_edit(m, buf_string(tags), buf);
1859 buf_pool_release(&tags);
1860 if (rc2 < 0)
1861 {
1862 goto done;
1863 }
1864 else if (rc2 == 0)
1865 {
1866 mutt_message(_("No tag specified, aborting"));
1867 goto done;
1868 }
1869
1870 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1871 event->count);
1872 const int num = ARRAY_SIZE(&ea);
1873
1874 if (priv->tag_prefix || (num > 1))
1875 {
1876 struct Progress *progress = NULL;
1877
1878 if (m->verbose)
1879 {
1880 progress = progress_new(MUTT_PROGRESS_WRITE, num);
1881 progress_set_message(progress, _("Update tags..."));
1882 }
1883
1884#ifdef USE_NOTMUCH
1885 if (m->type == MUTT_NOTMUCH)
1886 nm_db_longrun_init(m, true);
1887#endif
1888 struct Email **ep = NULL;
1889 int px = 0;
1890 ARRAY_FOREACH(ep, &ea)
1891 {
1892 struct Email *e = *ep;
1893
1894 progress_update(progress, ++px, -1);
1895 mx_tags_commit(m, e, buf_string(buf));
1896 e->attr_color = NULL;
1897 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1898 {
1899 bool still_queried = false;
1900#ifdef USE_NOTMUCH
1901 if (m->type == MUTT_NOTMUCH)
1902 still_queried = nm_message_is_still_queried(m, e);
1903#endif
1904 e->quasi_deleted = !still_queried;
1905 m->changed = true;
1906 }
1907 }
1908 progress_free(&progress);
1909#ifdef USE_NOTMUCH
1910 if (m->type == MUTT_NOTMUCH)
1912#endif
1914 if (!priv->tag_prefix)
1916 (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE) ? 1 : num);
1917 }
1918 else
1919 {
1920 if (mx_tags_commit(m, shared->email, buf_string(buf)))
1921 {
1922 mutt_message(_("Failed to modify tags, aborting"));
1923 goto done;
1924 }
1925 shared->email->attr_color = NULL;
1926 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1927 {
1928 bool still_queried = false;
1929#ifdef USE_NOTMUCH
1930 if (m->type == MUTT_NOTMUCH)
1931 still_queried = nm_message_is_still_queried(m, shared->email);
1932#endif
1933 shared->email->quasi_deleted = !still_queried;
1934 m->changed = true;
1935 }
1936
1938 (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE) ? 1 : num);
1939 }
1940 rc = FR_SUCCESS;
1941
1942done:
1943 ARRAY_FREE(&ea);
1944 buf_pool_release(&buf);
1945 return rc;
1946}
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
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:393
void nm_db_longrun_init(struct Mailbox *m, bool writable)
Start a long transaction.
Definition db.c:378
bool nm_message_is_still_queried(struct Mailbox *m, struct Email *e)
Is a message still visible in the query?
Definition notmuch.c:1737
@ 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:104
bool verbose
Display status messages?
Definition mailbox.h:119
void driver_tags_get_with_hidden(struct TagList *tl, struct Buffer *tags)
Get all tags, also hidden ones, separated by space.
Definition tags.c:175
+ Here is the call graph for this function:

◆ find_next_new_email()

static int find_next_new_email ( struct Mailbox * m,
int start,
bool forwards,
int op )
static

Jump to 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 Find the next new/unread message with wrapping
    Parameters
    mMailbox
    startIndex to start searching from
    forwardsDirection: true for next, false for previous
    opOperation to determine match type
    Return values
    >=0Index of matching message
    -1No match found

Definition at line 1968 of file functions.c.

1969{
1970 int first_unread = -1;
1971 int first_new = -1;
1972 int mcur = start;
1973 const bool threaded = mutt_using_threads();
1974
1975 for (int i = 0; i < m->vcount; i++)
1976 {
1977 if (forwards)
1978 {
1979 mcur++;
1980 if (mcur > (m->vcount - 1))
1981 mcur = 0;
1982 }
1983 else
1984 {
1985 mcur--;
1986 if (mcur < 0)
1987 mcur = m->vcount - 1;
1988 }
1989
1990 struct Email *e = mutt_get_virt_email(m, mcur);
1991 if (!e)
1992 break;
1993 if (e->collapsed && threaded)
1994 {
1995 int unread = mutt_thread_contains_unread(e);
1996 if ((unread != 0) && (first_unread == -1))
1997 first_unread = mcur;
1998 if ((unread == 1) && (first_new == -1))
1999 first_new = mcur;
2000 }
2001 else if (!e->deleted && !e->read)
2002 {
2003 if (first_unread == -1)
2004 first_unread = mcur;
2005 if (!e->old && (first_new == -1))
2006 first_new = mcur;
2007 }
2008
2009 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD)) && (first_unread != -1))
2010 break;
2011 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
2012 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2013 (first_new != -1))
2014 {
2015 break;
2016 }
2017 }
2018
2019 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
2020 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2021 (first_new != -1))
2022 {
2023 return first_new;
2024 }
2025 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD) ||
2026 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2027 (first_unread != -1))
2028 {
2029 return first_unread;
2030 }
2031
2032 return -1;
2033}
#define mutt_thread_contains_unread(e)
Definition thread.h:114
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:
+ Here is the caller graph for this function:

◆ op_main_next_thread()

static int op_main_next_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 2113 of file functions.c.

2114{
2115 struct IndexSharedData *shared = fdata->shared;
2116 struct IndexPrivateData *priv = fdata->priv;
2117 const int op = event->op;
2118 const int count = event->count;
2119 const bool forwards = (op == OP_MAIN_NEXT_THREAD) || (op == OP_MAIN_NEXT_SUBTHREAD);
2120 const bool subthreads = (op == OP_MAIN_NEXT_SUBTHREAD) || (op == OP_MAIN_PREV_SUBTHREAD);
2121
2122 if (count > 0)
2123 {
2124 for (int i = 0; i < count; i++)
2125 {
2126 int index = mutt_aside_thread(shared->email, forwards, subthreads);
2127 if (index == -1)
2128 break;
2129 menu_set_index(priv->menu, index);
2130 }
2131 return FR_SUCCESS;
2132 }
2133
2134 int index = mutt_aside_thread(shared->email, forwards, subthreads);
2135
2136 if (index != -1)
2137 menu_set_index(priv->menu, index);
2138
2139 if (index < 0)
2140 {
2141 if (forwards)
2142 mutt_error(_("No more threads"));
2143 else
2144 mutt_error(_("You are on the first thread"));
2145
2147 return FR_ERROR;
2148 }
2149
2150 return FR_SUCCESS;
2151}
int mutt_aside_thread(struct Email *e, bool forwards, bool subthreads)
Find the next/previous (sub)thread.
Definition thread.c:1389
+ Here is the call graph for this function:

◆ op_main_next_undeleted()

static int op_main_next_undeleted ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the next undeleted message - Implements index_function_t -.

Definition at line 2156 of file functions.c.

2157{
2158 struct IndexSharedData *shared = fdata->shared;
2159 struct IndexPrivateData *priv = fdata->priv;
2160 const int count = event->count;
2161 int index = menu_get_index(priv->menu);
2162
2163 if (count > 0)
2164 {
2165 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2166 int last_good = index;
2167 for (int i = 0; i < count; i++)
2168 {
2169 int next = find_next_undeleted(shared->mailbox_view, index, uncollapse);
2170 if (next == -1)
2171 break;
2172 last_good = next;
2173 index = next;
2174 }
2175 if (last_good != menu_get_index(priv->menu))
2176 {
2177 menu_set_index(priv->menu, last_good);
2178 if (uncollapse)
2180 }
2181 return FR_SUCCESS;
2182 }
2183
2184 if (index >= (shared->mailbox->vcount - 1))
2185 {
2187 mutt_message(_("You are on the last message"));
2188 return FR_ERROR;
2189 }
2190
2191 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2192
2193 index = find_next_undeleted(shared->mailbox_view, index, uncollapse);
2194 if (index != -1)
2195 {
2196 menu_set_index(priv->menu, index);
2197 if (uncollapse)
2199 }
2200
2201 if (index == -1)
2202 {
2204 mutt_error(_("No undeleted messages"));
2205 return FR_ERROR;
2206 }
2207
2208 return FR_SUCCESS;
2209}
int find_next_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the next undeleted email.
Definition dlg_index.c:259
+ Here is the call graph for this function:

◆ op_main_next_unread_mailbox()

static int op_main_next_unread_mailbox ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open next mailbox with unread mail - Implements index_function_t -.

Definition at line 2214 of file functions.c.

2216{
2217 struct IndexSharedData *shared = fdata->shared;
2218 struct IndexPrivateData *priv = fdata->priv;
2219 struct Mailbox *m = shared->mailbox;
2220
2221 struct Buffer *folderbuf = buf_pool_get();
2222 buf_strcpy(folderbuf, mailbox_path(m));
2223 m = mutt_mailbox_next_unread(m, folderbuf);
2224 buf_pool_release(&folderbuf);
2225
2226 if (!m)
2227 {
2228 mutt_error(_("No mailboxes have new mail"));
2229 return FR_ERROR;
2230 }
2231
2232 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
2233 return FR_SUCCESS;
2234}
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_unread_mailbox()

static int op_main_prev_unread_mailbox ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open previous mailbox with unread mail - Implements index_function_t -.

Definition at line 2239 of file functions.c.

2241{
2242 struct IndexSharedData *shared = fdata->shared;
2243 struct IndexPrivateData *priv = fdata->priv;
2244 struct Mailbox *m = shared->mailbox;
2245
2246 struct Buffer *folderbuf = buf_pool_get();
2247 buf_strcpy(folderbuf, mailbox_path(m));
2248 m = mutt_mailbox_prev_unread(m, folderbuf);
2249 buf_pool_release(&folderbuf);
2250
2251 if (!m)
2252 {
2253 mutt_error(_("No mailboxes have new mail"));
2254 return FR_ERROR;
2255 }
2256
2257 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
2258 return FR_SUCCESS;
2259}
struct Mailbox * mutt_mailbox_prev_unread(struct Mailbox *m_cur, struct Buffer *s)
Find previous mailbox with unread mail.
+ Here is the call graph for this function:

◆ op_main_prev_undeleted()

static int op_main_prev_undeleted ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the previous undeleted message - Implements index_function_t -.

Definition at line 2264 of file functions.c.

2265{
2266 struct IndexSharedData *shared = fdata->shared;
2267 struct IndexPrivateData *priv = fdata->priv;
2268 const int count = event->count;
2269 int index = menu_get_index(priv->menu);
2270
2271 if (count > 0)
2272 {
2273 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2274 int last_good = index;
2275 for (int i = 0; i < count; i++)
2276 {
2277 int prev = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
2278 if (prev == -1)
2279 break;
2280 last_good = prev;
2281 index = prev;
2282 }
2283 if (last_good != menu_get_index(priv->menu))
2284 {
2285 menu_set_index(priv->menu, last_good);
2286 if (uncollapse)
2288 }
2289 return FR_SUCCESS;
2290 }
2291
2292 if (index < 1)
2293 {
2295 mutt_message(_("You are on the first message"));
2296 return FR_ERROR;
2297 }
2298
2299 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2300
2301 index = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
2302 if (index != -1)
2303 {
2304 menu_set_index(priv->menu, index);
2305 if (uncollapse)
2307 }
2308
2309 if (index == -1)
2310 {
2311 mutt_error(_("No undeleted messages"));
2313 return FR_ERROR;
2314 }
2315
2316 return FR_SUCCESS;
2317}
int find_previous_undeleted(struct MailboxView *mv, int msgno, bool uncollapse)
Find the previous undeleted email.
Definition dlg_index.c:293
+ Here is the call graph for this function:

◆ op_main_quasi_delete()

static int op_main_quasi_delete ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 2322 of file functions.c.

2323{
2324 struct IndexSharedData *shared = fdata->shared;
2325 struct IndexPrivateData *priv = fdata->priv;
2326 struct Mailbox *m = shared->mailbox;
2327 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2328 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2329 event->count);
2330 if (ARRAY_EMPTY(&ea))
2331 {
2332 ARRAY_FREE(&ea);
2333 return FR_NO_ACTION;
2334 }
2335 const int num = ARRAY_SIZE(&ea);
2336
2337 struct Email **ep = NULL;
2338 ARRAY_FOREACH(ep, &ea)
2339 {
2340 (*ep)->quasi_deleted = true;
2341 m->changed = true;
2342 }
2343 ARRAY_FREE(&ea);
2344
2345 if (priv->tag_prefix || (num > 1))
2347
2348 return FR_SUCCESS;
2349}
+ Here is the call graph for this function:

◆ op_main_read_thread()

static int op_main_read_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 2358 of file functions.c.

2359{
2360 struct IndexSharedData *shared = fdata->shared;
2361 struct IndexPrivateData *priv = fdata->priv;
2362 /* L10N: CHECK_ACL */
2363 /* L10N: Due to the implementation details we do not know whether we
2364 mark zero, 1, 12, ... messages as read. So in English we use
2365 "messages". Your language might have other means to express this. */
2366 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't mark messages as read")))
2367 return FR_ERROR;
2368
2369 const int op = event->op;
2370 const bool subthread = (op != OP_MAIN_READ_THREAD);
2371 int rc = 0;
2372 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2373 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
2374 priv->tag_prefix, subthread, event->count);
2375 const int num = ARRAY_SIZE(&ea);
2376
2377 struct Email **ep = NULL;
2378 ARRAY_FOREACH(ep, &ea)
2379 {
2380 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_READ, true, subthread);
2381 if (rc == -1)
2382 break;
2383 }
2384 ARRAY_FREE(&ea);
2385
2386 if (rc == -1)
2387 return FR_ERROR;
2388
2389 if (priv->tag_prefix)
2390 {
2392 return FR_SUCCESS;
2393 }
2394
2395 const enum ResolveMethod rm = (op == OP_MAIN_READ_THREAD) ? RESOLVE_NEXT_THREAD :
2397 resolve_email(priv, shared, rm, num);
2399 return FR_SUCCESS;
2400}
@ 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:92
+ Here is the call graph for this function:

◆ op_main_root_message()

static int op_main_root_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Jump to root message in thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_PARENT_MESSAGE
  • OP_MAIN_ROOT_MESSAGE

When called with a count prefix, will jump N ancestors up the thread (for parent-message, not for root-message which always goes to root).

Definition at line 2412 of file functions.c.

2413{
2414 struct IndexSharedData *shared = fdata->shared;
2415 struct IndexPrivateData *priv = fdata->priv;
2416 int count = event->op == OP_MAIN_ROOT_MESSAGE ? 0 : MAX(event->count, 1);
2417 int index = mutt_parent_message(shared->email, event->op == OP_MAIN_ROOT_MESSAGE, count);
2418 if (index != -1)
2419 menu_set_index(priv->menu, index);
2420
2421 return FR_SUCCESS;
2422}
int mutt_parent_message(struct Email *e, bool find_root, int count)
Find the parent of a message.
Definition thread.c:1457
#define MAX(a, b)
Return the maximum of two values.
Definition memory.h:38
+ Here is the call graph for this function:

◆ op_main_set_flag()

static int op_main_set_flag ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 2431 of file functions.c.

2432{
2433 struct IndexSharedData *shared = fdata->shared;
2434 struct IndexPrivateData *priv = fdata->priv;
2435 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2436 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2437 event->count);
2438 if (ARRAY_EMPTY(&ea))
2439 {
2440 ARRAY_FREE(&ea);
2441 return FR_NO_ACTION;
2442 }
2443 const int num = ARRAY_SIZE(&ea);
2444
2445 if (mw_change_flag(shared->mailbox, &ea, (event->op == OP_MAIN_SET_FLAG)) == 0)
2446 {
2447 if (priv->tag_prefix)
2448 {
2450 }
2451 else
2452 {
2453 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
2454 if (num > 1)
2456 }
2457 }
2458 ARRAY_FREE(&ea);
2459
2460 return FR_SUCCESS;
2461}
int mw_change_flag(struct Mailbox *m, struct EmailArray *ea, bool bf)
Change the flag on a Message -.
Definition flags.c:456
+ Here is the call graph for this function:

◆ op_main_show_limit()

static int op_main_show_limit ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Show currently active limit pattern - Implements index_function_t -.

Definition at line 2466 of file functions.c.

2467{
2468 struct IndexSharedData *shared = fdata->shared;
2469 if (mview_has_limit(shared->mailbox_view))
2470 {
2471 struct Buffer *buf = buf_pool_get();
2472 /* L10N: ask for a limit to apply */
2473 buf_printf(buf, _("Limit: %s"), shared->mailbox_view->pattern);
2474 mutt_message("%s", buf_string(buf));
2475 buf_pool_release(&buf);
2476 }
2477 else
2478 {
2479 mutt_message(_("No limit pattern is in effect"));
2480 }
2481
2482 return FR_SUCCESS;
2483}
+ Here is the call graph for this function:

◆ op_main_sync_folder()

static int op_main_sync_folder ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Save changes to mailbox - Implements index_function_t -.

Definition at line 2488 of file functions.c.

2489{
2490 struct IndexSharedData *shared = fdata->shared;
2491 struct IndexPrivateData *priv = fdata->priv;
2493 return FR_NO_ACTION;
2494
2495 int ovc = shared->mailbox->vcount;
2496 int oc = shared->mailbox->msg_count;
2497 struct Email *e = NULL;
2498
2499 /* don't attempt to move the cursor if there are no visible messages in the current limit */
2500 int index = menu_get_index(priv->menu);
2501 if (index < shared->mailbox->vcount)
2502 {
2503 /* threads may be reordered, so figure out what header the cursor
2504 * should be on. */
2505 int newidx = index;
2506 if (!shared->email)
2507 return FR_NO_ACTION;
2508 if (shared->email->deleted)
2509 newidx = find_next_undeleted(shared->mailbox_view, index, false);
2510 if (newidx < 0)
2511 newidx = find_previous_undeleted(shared->mailbox_view, index, false);
2512 if (newidx >= 0)
2513 e = mutt_get_virt_email(shared->mailbox, newidx);
2514 }
2515
2516 enum MxStatus check = mx_mbox_sync(shared->mailbox);
2517 if (check == MX_STATUS_OK)
2518 {
2519 if (e && (shared->mailbox->vcount != ovc))
2520 {
2521 for (size_t i = 0; i < shared->mailbox->vcount; i++)
2522 {
2523 struct Email *e2 = mutt_get_virt_email(shared->mailbox, i);
2524 if (e2 == e)
2525 {
2526 menu_set_index(priv->menu, i);
2527 break;
2528 }
2529 }
2530 }
2532 }
2533 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2534 {
2535 update_index(priv->menu, shared->mailbox_view, check, oc, shared);
2536 }
2537
2538 /* do a sanity check even if mx_mbox_sync failed. */
2539
2540 index = menu_get_index(priv->menu);
2541 if ((index < 0) || (shared->mailbox && (index >= shared->mailbox->vcount)))
2542 {
2544 }
2545
2546 /* check for a fatal error, or all messages deleted */
2547 if (shared->mailbox && buf_is_empty(&shared->mailbox->pathbuf))
2548 {
2549 mview_free(&shared->mailbox_view);
2550 }
2551
2552 if (shared->mailbox)
2553 {
2554 priv->menu->max = shared->mailbox->vcount;
2556
2557 struct EventMailbox ev_m = { shared->mailbox };
2559 }
2560 else
2561 {
2562 priv->menu->max = 0;
2564 }
2565
2566 return FR_SUCCESS;
2567}
void mutt_pattern_free(struct PatternList **pat)
Free a Pattern.
Definition compile.c:836
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:178
int find_first_message(struct MailboxView *mv)
Get index of first new message.
Definition dlg_index.c:327
enum MxStatus mx_mbox_sync(struct Mailbox *m)
Save changes to mailbox.
Definition mx.c:904
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_sync(), and mbox_close()
Definition mxapi.h:70
@ MX_STATUS_OK
No changes.
Definition mxapi.h:72
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition mxapi.h:75
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition notify_type.h:50
An Event that happened to a Mailbox.
Definition mailbox.h:192
struct SearchState * search_state
State of the current search.
Definition shared_data.h:45
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:147
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Tag messages matching a pattern - Implements index_function_t -.

Definition at line 2572 of file functions.c.

2573{
2574 struct IndexSharedData *shared = fdata->shared;
2575 struct IndexPrivateData *priv = fdata->priv;
2576 mutt_pattern_func(shared->mailbox_view, MUTT_TAG, _("Tag messages matching: "));
2578
2579 return FR_SUCCESS;
2580}
+ Here is the call graph for this function:

◆ op_main_undelete_pattern()

static int op_main_undelete_pattern ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Undelete messages matching a pattern - Implements index_function_t -.

Definition at line 2585 of file functions.c.

2587{
2588 struct IndexSharedData *shared = fdata->shared;
2589 struct IndexPrivateData *priv = fdata->priv;
2590 /* L10N: CHECK_ACL */
2591 /* L10N: Due to the implementation details we do not know whether we
2592 undelete zero, 1, 12, ... messages. So in English we use
2593 "messages". Your language might have other means to express this. */
2594 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
2595 return FR_ERROR;
2596
2598 _("Undelete messages matching: ")) == 0)
2599 {
2601 }
2602
2603 return FR_SUCCESS;
2604}
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition mutt.h:95
+ Here is the call graph for this function:

◆ op_main_untag_pattern()

static int op_main_untag_pattern ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Untag messages matching a pattern - Implements index_function_t -.

Definition at line 2609 of file functions.c.

2610{
2611 struct IndexSharedData *shared = fdata->shared;
2612 struct IndexPrivateData *priv = fdata->priv;
2613 if (mutt_pattern_func(shared->mailbox_view, MUTT_UNTAG, _("Untag messages matching: ")) == 0)
2615
2616 return FR_SUCCESS;
2617}
@ MUTT_UNTAG
Messages to be un-tagged.
Definition mutt.h:100
+ Here is the call graph for this function:

◆ op_mark_msg()

static int op_mark_msg ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 2622 of file functions.c.

2623{
2624 struct IndexSharedData *shared = fdata->shared;
2625 if (!shared->email)
2626 return FR_NO_ACTION;
2627
2628 int rc = FR_SUCCESS;
2629
2630 if (shared->email->env->message_id)
2631 {
2632 struct Buffer *buf = buf_pool_get();
2633
2634 /* L10N: This is the prompt for <mark-message>. Whatever they
2635 enter will be prefixed by $mark_macro_prefix and will become
2636 a macro hotkey to jump to the currently selected message. */
2637 if ((mw_get_field(_("Enter macro stroke: "), buf, MUTT_COMP_NONE, HC_OTHER,
2638 NULL, NULL) == 0) &&
2639 !buf_is_empty(buf))
2640 {
2641 const char *const c_mark_macro_prefix = cs_subset_string(shared->sub, "mark_macro_prefix");
2642 char str[256] = { 0 };
2643 snprintf(str, sizeof(str), "%s%s", c_mark_macro_prefix, buf_string(buf));
2644
2645 struct Buffer *msg_id = buf_pool_get();
2646 mutt_file_sanitize_regex(msg_id, shared->email->env->message_id);
2647 char macro[256] = { 0 };
2648 snprintf(macro, sizeof(macro), "<search>~i '%s'\n", buf_string(msg_id));
2649 buf_pool_release(&msg_id);
2650
2651 /* L10N: "message hotkey" is the key bindings menu description of a
2652 macro created by <mark-message>. */
2653 km_bind(fdata->mod_data->md_index, str, OP_MACRO, macro, _("message hotkey"), NULL);
2654
2655 /* L10N: This is echoed after <mark-message> creates a new hotkey
2656 macro. %s is the hotkey string ($mark_macro_prefix followed
2657 by whatever they typed at the prompt.) */
2658 buf_printf(buf, _("Message bound to %s"), str);
2659 mutt_message("%s", buf_string(buf));
2660 mutt_debug(LL_DEBUG1, "Mark: %s => %s\n", str, macro);
2661 }
2662 buf_pool_release(&buf);
2663 }
2664 else
2665 {
2666 /* L10N: This error is printed if <mark-message> can't find a
2667 Message-ID for the currently selected message in the index. */
2668 mutt_error(_("No message ID to macro"));
2669 rc = FR_ERROR;
2670 }
2671
2672 return rc;
2673}
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:624
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
enum CommandResult km_bind(const struct MenuDefinition *md, const char *key_str, int op, char *macro, char *desc, struct Buffer *err)
Set up a key binding.
Definition menu.c:52
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
struct IndexModuleData * mod_data
Index module data.
Definition functions.h:37
struct MenuDefinition * md_index
Index Menu Definition.
Definition module_data.h:34
+ Here is the call graph for this function:

◆ op_next_entry()

static int op_next_entry ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the next entry - Implements index_function_t -.

Definition at line 2678 of file functions.c.

2679{
2680 struct IndexSharedData *shared = fdata->shared;
2681 struct IndexPrivateData *priv = fdata->priv;
2682 int count = MAX(event->count, 1);
2683 int index = menu_get_index(priv->menu) + count;
2684
2685 if (index >= shared->mailbox->vcount)
2686 {
2687 index = shared->mailbox->vcount - 1;
2688 if (event->count == 0)
2689 {
2690 mutt_message(_("You are on the last message"));
2692 }
2693 }
2694
2695 menu_set_index(priv->menu, index);
2696 return FR_SUCCESS;
2697}
+ Here is the call graph for this function:

◆ op_pipe()

static int op_pipe ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 2702 of file functions.c.

2703{
2704 struct IndexSharedData *shared = fdata->shared;
2705 struct IndexPrivateData *priv = fdata->priv;
2706 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2707 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2708 mutt_pipe_message(shared->mailbox, &ea);
2709 ARRAY_FREE(&ea);
2710
2711 /* in an IMAP folder index with imap_peek=no, piping could change
2712 * new or old messages status to read. Redraw what's needed. */
2713 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2714 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2715 {
2717 }
2718
2719 return FR_SUCCESS;
2720}
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
void mutt_pipe_message(struct Mailbox *m, struct EmailArray *ea)
Pipe a message.
Definition external.c:404
+ Here is the call graph for this function:

◆ op_prev_entry()

static int op_prev_entry ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Move to the previous entry - Implements index_function_t -.

Definition at line 2725 of file functions.c.

2726{
2727 struct IndexSharedData *shared = fdata->shared;
2728 struct IndexPrivateData *priv = fdata->priv;
2729 int count = MAX(event->count, 1);
2730 int index = menu_get_index(priv->menu) - count;
2731
2732 if (index < 0)
2733 {
2734 index = 0;
2735 if (event->count == 0)
2736 {
2738 mutt_message(_("You are on the first message"));
2739 }
2740 }
2741
2742 menu_set_index(priv->menu, index);
2743 return FR_SUCCESS;
2744}
+ Here is the call graph for this function:

◆ op_print()

static int op_print ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Print the current entry - Implements index_function_t -.

Definition at line 2749 of file functions.c.

2750{
2751 struct IndexSharedData *shared = fdata->shared;
2752 struct IndexPrivateData *priv = fdata->priv;
2753 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2754 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2755 event->count);
2756 if (ARRAY_EMPTY(&ea))
2757 {
2758 ARRAY_FREE(&ea);
2759 return FR_NO_ACTION;
2760 }
2761 const int num = ARRAY_SIZE(&ea);
2762 const bool printed = mutt_print_message(shared->mailbox, &ea);
2763 ARRAY_FREE(&ea);
2764
2765 if (printed && !priv->tag_prefix)
2766 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, num);
2767
2768 /* in an IMAP folder index with imap_peek=no, printing could change
2769 * new or old messages status to read. Redraw what's needed. */
2770 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2771 if (printed && (shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2772 {
2773 menu_queue_redraw(priv->menu,
2774 ((priv->tag_prefix || (num > 1)) ? MENU_REDRAW_INDEX : MENU_REDRAW_CURRENT));
2775 }
2776
2777 return FR_SUCCESS;
2778}
bool mutt_print_message(struct Mailbox *m, struct EmailArray *ea)
Print a message.
Definition external.c:437
@ RESOLVE_NEXT_EMAIL
Next email, whatever its state.
Definition functions.c:318
+ Here is the call graph for this function:

◆ op_query()

static int op_query ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Query external program for addresses - Implements index_function_t -.

Definition at line 2783 of file functions.c.

2784{
2785 struct IndexSharedData *shared = fdata->shared;
2786 query_index(shared->mailbox, shared->sub);
2787 return FR_SUCCESS;
2788}
void query_index(struct Mailbox *m, struct ConfigSubset *sub)
Perform an Alias Query and display the results.
Definition dlg_query.c:491
+ Here is the call graph for this function:

◆ op_quit()

static int op_quit ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Save changes to mailbox and quit - Implements index_function_t -.

Definition at line 2793 of file functions.c.

2794{
2795 struct IndexSharedData *shared = fdata->shared;
2796 struct IndexPrivateData *priv = fdata->priv;
2797 if (shared->attach_msg)
2798 return FR_DONE;
2799
2800 if (query_quadoption(_("Quit NeoMutt?"), shared->sub, "quit") == MUTT_YES)
2801 {
2802 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
2803
2805 mutt_debug(LL_NOTIFY, "NT_GLOBAL_SHUTDOWN\n");
2807
2808 enum MxStatus check = MX_STATUS_OK;
2809 if (!shared->mailbox_view || ((check = mx_mbox_close(shared->mailbox)) == MX_STATUS_OK))
2810 {
2813 return FR_DONE;
2814 }
2815
2816 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2817 {
2818 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2819 }
2820
2821 menu_queue_redraw(priv->menu, MENU_REDRAW_FULL); /* new mail arrived? */
2823 }
2824
2825 return FR_NO_ACTION;
2826}
@ CMD_SHUTDOWN_HOOK
:shutdown-hook
Definition command.h:113
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:90
void exec_startup_shutdown_hook(enum CommandId id)
Execute any startup/shutdown hooks.
Definition exec.c:418
@ 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:595
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition neomutt.h:70
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition notify_type.h:46
struct Notify * notify
Notifications handler.
Definition neomutt.h:45
+ Here is the call graph for this function:

◆ op_recall_message()

static int op_recall_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Recall a postponed message - Implements index_function_t -.

Definition at line 2831 of file functions.c.

2832{
2833 struct IndexSharedData *shared = fdata->shared;
2834 struct IndexPrivateData *priv = fdata->priv;
2835 int rc = mutt_send_message(SEND_POSTPONED, NULL, NULL, shared->mailbox, NULL,
2836 shared->sub);
2838 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2839}
@ SEND_POSTPONED
Recall a postponed email.
Definition send.h:50
+ Here is the call graph for this function:

◆ op_reply()

static int op_reply ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Reply to a message - Implements index_function_t -.

Definition at line 2844 of file functions.c.

2845{
2846 struct IndexSharedData *shared = fdata->shared;
2847 struct IndexPrivateData *priv = fdata->priv;
2848 if (!shared->email)
2849 return FR_NO_ACTION;
2850 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2851 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2852 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
2853 if (c_pgp_auto_decode &&
2854 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
2855 {
2856 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
2858 }
2859 int rc = mutt_send_message(SEND_REPLY, NULL, NULL, shared->mailbox, &ea,
2860 shared->sub);
2861 ARRAY_FREE(&ea);
2863
2864 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2865}
+ Here is the call graph for this function:

◆ op_resend()

static int op_resend ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 2870 of file functions.c.

2871{
2872 struct IndexSharedData *shared = fdata->shared;
2873 struct IndexPrivateData *priv = fdata->priv;
2874 int rc = -1;
2875 if (priv->tag_prefix)
2876 {
2877 struct Mailbox *m = shared->mailbox;
2878 for (size_t i = 0; i < m->msg_count; i++)
2879 {
2880 struct Email *e = m->emails[i];
2881 if (!e)
2882 break;
2883 if (message_is_tagged(e))
2884 rc = mutt_resend_message(NULL, shared->mailbox, e, shared->sub);
2885 }
2886 }
2887 else
2888 {
2889 rc = mutt_resend_message(NULL, shared->mailbox, shared->email, shared->sub);
2890 }
2891
2893 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2894}
bool message_is_tagged(struct Email *e)
Is a message in the index tagged (and within limit)
Definition mview.c:363
int mutt_resend_message(FILE *fp, struct Mailbox *m, struct Email *e_cur, struct ConfigSubset *sub)
Resend an email.
Definition send.c:1561
+ Here is the call graph for this function:

◆ op_save()

static int op_save ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 2907 of file functions.c.

2908{
2909 struct IndexSharedData *shared = fdata->shared;
2910 struct IndexPrivateData *priv = fdata->priv;
2911 const int op = event->op;
2912 if (((op == OP_DECRYPT_COPY) || (op == OP_DECRYPT_SAVE)) && !WithCrypto)
2913 return FR_NOT_IMPL;
2914
2915 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2916 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2917 event->count);
2918 if (ARRAY_EMPTY(&ea))
2919 {
2920 ARRAY_FREE(&ea);
2921 return FR_NO_ACTION;
2922 }
2923 const int num = ARRAY_SIZE(&ea);
2924
2925 const enum MessageSaveOpt save_opt = ((op == OP_SAVE) || (op == OP_DECODE_SAVE) ||
2926 (op == OP_DECRYPT_SAVE)) ?
2927 SAVE_MOVE :
2928 SAVE_COPY;
2929
2930 enum MessageTransformOpt transform_opt =
2931 ((op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY)) ? TRANSFORM_DECODE :
2932 ((op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY)) ? TRANSFORM_DECRYPT :
2934
2935 const int rc = mutt_save_message(shared->mailbox, &ea, save_opt, transform_opt);
2936 if ((rc == 0) && (save_opt == SAVE_MOVE) && !priv->tag_prefix)
2937 {
2938 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
2939 }
2940 ARRAY_FREE(&ea);
2941
2942 if (priv->tag_prefix || (num > 1))
2944
2945 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2946}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
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 2957 of file functions.c.

2958{
2959 struct IndexSharedData *shared = fdata->shared;
2960 struct IndexPrivateData *priv = fdata->priv;
2961 SearchFlags flags = SEARCH_NONE;
2962 switch (event->op)
2963 {
2964 case OP_SEARCH:
2965 flags |= SEARCH_PROMPT;
2966 shared->search_state->reverse = false;
2967 break;
2968 case OP_SEARCH_REVERSE:
2969 flags |= SEARCH_PROMPT;
2970 shared->search_state->reverse = true;
2971 break;
2972 case OP_SEARCH_NEXT:
2973 break;
2974 case OP_SEARCH_OPPOSITE:
2975 flags |= SEARCH_OPPOSITE;
2976 break;
2977 }
2978
2979 // Initiating a search can happen on an empty mailbox, but
2980 // searching for next/previous/... needs to be on a message and
2981 // thus a non-empty mailbox
2982 int index = menu_get_index(priv->menu);
2983 index = mutt_search_command(shared->mailbox_view, priv->menu, index,
2984 shared->search_state, flags);
2985 if (index != -1)
2986 menu_set_index(priv->menu, index);
2987
2988 return FR_SUCCESS;
2989}
int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition pattern.c:462
uint8_t SearchFlags
@ SEARCH_NONE
No flags are set.
@ SEARCH_PROMPT
Ask for search input.
@ SEARCH_OPPOSITE
Search in the opposite direction.
bool reverse
search backwards
+ Here is the call graph for this function:

◆ op_sort()

static int op_sort ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Sort messages - Implements index_function_t -.

This function handles:

  • OP_SORT
  • OP_SORT_REVERSE

Definition at line 2998 of file functions.c.

2999{
3000 struct IndexSharedData *shared = fdata->shared;
3001 struct IndexPrivateData *priv = fdata->priv;
3002 if (!mutt_select_sort(event->op == OP_SORT_REVERSE))
3003 return FR_ERROR;
3004
3005 if (shared->mailbox && (shared->mailbox->msg_count != 0))
3006 {
3009 }
3010
3011 return FR_SUCCESS;
3012}
void resort_index(struct MailboxView *mv, struct Menu *menu)
Resort the index.
Definition dlg_index.c:387
bool mutt_select_sort(bool reverse)
Ask the user for a sort method.
Definition external.c:475
+ Here is the call graph for this function:

◆ op_tag()

static int op_tag ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Tag the current entry - Implements index_function_t -.

Definition at line 3017 of file functions.c.

3018{
3019 struct IndexSharedData *shared = fdata->shared;
3020 struct IndexPrivateData *priv = fdata->priv;
3021 const bool c_auto_tag = cs_subset_bool(shared->sub, "auto_tag");
3022 if (priv->tag_prefix && !c_auto_tag)
3023 {
3024 struct Mailbox *m = shared->mailbox;
3025 for (size_t i = 0; i < m->msg_count; i++)
3026 {
3027 struct Email *e = m->emails[i];
3028 if (!e)
3029 break;
3030 if (e->visible)
3031 mutt_set_flag(m, e, MUTT_TAG, false, true);
3032 }
3034 return FR_SUCCESS;
3035 }
3036
3037 if (!shared->email)
3038 return FR_NO_ACTION;
3039
3040 int count = MAX(event->count, 1);
3041 int current_index = menu_get_index(priv->menu);
3042
3043 for (int i = 0; i < count && current_index + i < shared->mailbox->vcount; i++)
3044 {
3045 struct Email *e = mutt_get_virt_email(shared->mailbox, current_index + i);
3046 if (e)
3047 mutt_set_flag(shared->mailbox, e, MUTT_TAG, !e->tagged, true);
3048 }
3049
3050 if (count > 0)
3051 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, count);
3052
3053 return FR_SUCCESS;
3054}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Tag the current thread - Implements index_function_t -.

This function handles:

  • OP_TAG_SUBTHREAD
  • OP_TAG_THREAD

Definition at line 3063 of file functions.c.

3064{
3065 struct IndexSharedData *shared = fdata->shared;
3066 struct IndexPrivateData *priv = fdata->priv;
3067 if (!shared->email)
3068 return FR_NO_ACTION;
3069
3070 const int op = event->op;
3072 !shared->email->tagged, (op != OP_TAG_THREAD));
3073 if (rc != -1)
3074 {
3075 const enum ResolveMethod rm = (op == OP_TAG_THREAD) ? RESOLVE_NEXT_THREAD :
3077 resolve_email(priv, shared, rm, 1);
3079 }
3080
3081 return FR_SUCCESS;
3082}
+ Here is the call graph for this function:

◆ op_toggle_new()

static int op_toggle_new ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 3087 of file functions.c.

3088{
3089 struct IndexSharedData *shared = fdata->shared;
3090 struct IndexPrivateData *priv = fdata->priv;
3091 /* L10N: CHECK_ACL */
3092 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't toggle new")))
3093 return FR_ERROR;
3094
3095 struct Mailbox *m = shared->mailbox;
3096 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3097 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
3098 event->count);
3099 if (ARRAY_EMPTY(&ea))
3100 {
3101 ARRAY_FREE(&ea);
3102 return FR_NO_ACTION;
3103 }
3104 const int num = ARRAY_SIZE(&ea);
3105
3106 struct Email **ep = NULL;
3107 ARRAY_FOREACH(ep, &ea)
3108 {
3109 if ((*ep)->read || (*ep)->old)
3110 mutt_set_flag(m, *ep, MUTT_NEW, true, true);
3111 else
3112 mutt_set_flag(m, *ep, MUTT_READ, true, true);
3113 }
3114 ARRAY_FREE(&ea);
3115
3116 if (priv->tag_prefix)
3117 {
3119 }
3120 else
3121 {
3122 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
3123 if (num > 1)
3125 }
3126
3127 return FR_SUCCESS;
3128}
@ MUTT_NEW
New messages.
Definition mutt.h:89
+ Here is the call graph for this function:

◆ op_toggle_write()

static int op_toggle_write ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 3133 of file functions.c.

3134{
3135 struct IndexSharedData *shared = fdata->shared;
3136 mx_toggle_write(shared->mailbox);
3137 return FR_SUCCESS;
3138}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Undelete the current entry - Implements index_function_t -.

Definition at line 3143 of file functions.c.

3144{
3145 struct IndexSharedData *shared = fdata->shared;
3146 struct IndexPrivateData *priv = fdata->priv;
3147 /* L10N: CHECK_ACL */
3148 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete message")))
3149 return FR_ERROR;
3150
3151 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3152 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
3153 event->count);
3154 if (ARRAY_EMPTY(&ea))
3155 {
3156 ARRAY_FREE(&ea);
3157 return FR_NO_ACTION;
3158 }
3159 const int num = ARRAY_SIZE(&ea);
3160
3161 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, false);
3162 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, false);
3163 ARRAY_FREE(&ea);
3164
3165 if (priv->tag_prefix)
3166 {
3168 }
3169 else
3170 {
3171 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, num);
3172 if (num > 1)
3174 }
3175
3176 return FR_SUCCESS;
3177}
+ Here is the call graph for this function:

◆ op_undelete_thread()

static int op_undelete_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Undelete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_UNDELETE_SUBTHREAD
  • OP_UNDELETE_THREAD

Definition at line 3186 of file functions.c.

3187{
3188 struct IndexSharedData *shared = fdata->shared;
3189 struct IndexPrivateData *priv = fdata->priv;
3190 /* L10N: CHECK_ACL */
3191 /* L10N: Due to the implementation details we do not know whether we
3192 undelete zero, 1, 12, ... messages. So in English we use
3193 "messages". Your language might have other means to express this. */
3194 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
3195 return FR_ERROR;
3196
3197 const int op = event->op;
3198 const bool subthread = (op != OP_UNDELETE_THREAD);
3199 int rc = 0;
3200 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3201 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
3202 priv->tag_prefix, subthread, event->count);
3203 const int num = ARRAY_SIZE(&ea);
3204
3205 struct Email **ep = NULL;
3206 ARRAY_FOREACH(ep, &ea)
3207 {
3208 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_DELETE, false, subthread);
3209 if (rc == -1)
3210 break;
3211 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_PURGE, false, subthread);
3212 if (rc == -1)
3213 break;
3214 }
3215 ARRAY_FREE(&ea);
3216
3217 if (rc == -1)
3218 return FR_ERROR;
3219
3220 if (priv->tag_prefix)
3221 {
3223 return FR_SUCCESS;
3224 }
3225
3226 const enum ResolveMethod rm = (op == OP_UNDELETE_THREAD) ? RESOLVE_NEXT_THREAD :
3228 resolve_email(priv, shared, rm, num);
3230 return FR_SUCCESS;
3231}
+ Here is the call graph for this function:

◆ op_view_attachments()

static int op_view_attachments ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Show MIME attachments - Implements index_function_t -.

Definition at line 3236 of file functions.c.

3237{
3238 struct IndexSharedData *shared = fdata->shared;
3239 struct IndexPrivateData *priv = fdata->priv;
3240 if (!shared->email)
3241 return FR_NO_ACTION;
3242
3243 enum FunctionRetval rc = FR_ERROR;
3244 struct Message *msg = mx_msg_open(shared->mailbox, shared->email);
3245 if (msg)
3246 {
3247 dlg_attach(fdata->n->sub, shared->mailbox_view, shared->email, msg->fp,
3248 shared->attach_msg);
3249 if (shared->email->attach_del)
3250 {
3251 shared->mailbox->changed = true;
3252 }
3253 mx_msg_close(shared->mailbox, &msg);
3254 rc = FR_SUCCESS;
3255 }
3257 return rc;
3258}
void dlg_attach(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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Manage autocrypt accounts - Implements index_function_t -.

Definition at line 3266 of file functions.c.

3267{
3268 dlg_autocrypt();
3269 return FR_SUCCESS;
3270}
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 3276 of file functions.c.

3277{
3278 struct IndexSharedData *shared = fdata->shared;
3279 if (!shared->mailbox || (shared->mailbox->type != MUTT_IMAP))
3280 return FR_NO_ACTION;
3281
3282 imap_check_mailbox(shared->mailbox, true);
3283 return FR_SUCCESS;
3284}
enum MxStatus imap_check_mailbox(struct Mailbox *m, bool force)
Use the NOOP or IDLE command to poll for new mail.
Definition imap.c:1220
+ Here is the call graph for this function:

◆ op_main_imap_logout_all()

static int op_main_imap_logout_all ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Logout from all IMAP servers - Implements index_function_t -.

Definition at line 3289 of file functions.c.

3290{
3291 struct IndexSharedData *shared = fdata->shared;
3292 struct IndexPrivateData *priv = fdata->priv;
3293 if (shared->mailbox && (shared->mailbox->type == MUTT_IMAP))
3294 {
3295 const enum MxStatus check = mx_mbox_close(shared->mailbox);
3296 if (check == MX_STATUS_OK)
3297 {
3299 }
3300 else
3301 {
3302 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
3303 {
3304 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
3305 }
3308 return FR_ERROR;
3309 }
3310 }
3312 mutt_message(_("Logged out of IMAP servers"));
3315
3316 return FR_SUCCESS;
3317}
void imap_logout_all(void)
Close all open connections.
Definition imap.c:667
+ Here is the call graph for this function:

◆ op_catchup()

static int op_catchup ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 3322 of file functions.c.

3323{
3324 struct IndexSharedData *shared = fdata->shared;
3325 struct IndexPrivateData *priv = fdata->priv;
3326 struct Mailbox *m = shared->mailbox;
3327 if (!m || (m->type != MUTT_NNTP))
3328 return FR_NO_ACTION;
3329
3330 struct NntpMboxData *mdata = m->mdata;
3331 if (mutt_newsgroup_catchup(m, mdata->adata, mdata->group))
3333
3334 return FR_SUCCESS;
3335}
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:48
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition newsrc.c:1239
void * mdata
Driver specific data.
Definition mailbox.h:134
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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

This function handles:

  • OP_GET_CHILDREN
  • OP_RECONSTRUCT_THREAD

Definition at line 3344 of file functions.c.

3345{
3346 struct IndexSharedData *shared = fdata->shared;
3347 struct IndexPrivateData *priv = fdata->priv;
3348 struct Mailbox *m = shared->mailbox;
3349 if (m->type != MUTT_NNTP)
3350 return FR_ERROR;
3351
3352 struct Email *e = shared->email;
3353 if (!e)
3354 return FR_NO_ACTION;
3355
3356 char buf[PATH_MAX] = { 0 };
3357 int oldmsgcount = m->msg_count;
3358 int oldindex = e->index;
3359 int rc = 0;
3360
3361 if (!e->env->message_id)
3362 {
3363 mutt_error(_("No Message-ID. Unable to perform operation."));
3364 return FR_ERROR;
3365 }
3366
3367 mutt_message(_("Fetching message headers..."));
3368 if (!m->id_hash)
3369 m->id_hash = mutt_make_id_hash(m);
3370 mutt_str_copy(buf, e->env->message_id, sizeof(buf));
3371
3372 const int op = event->op;
3373 /* trying to find msgid of the root message */
3374 if (op == OP_RECONSTRUCT_THREAD)
3375 {
3376 struct ListNode *ref = NULL;
3377 STAILQ_FOREACH(ref, &e->env->references, entries)
3378 {
3379 if (!mutt_hash_find(m->id_hash, ref->data))
3380 {
3381 rc = nntp_check_msgid(m, ref->data);
3382 if (rc < 0)
3383 return FR_ERROR;
3384 }
3385
3386 /* the last msgid in References is the root message */
3387 if (!STAILQ_NEXT(ref, entries))
3388 mutt_str_copy(buf, ref->data, sizeof(buf));
3389 }
3390 }
3391
3392 /* fetching all child messages */
3393 rc = nntp_check_children(m, buf);
3394
3395 /* at least one message has been loaded */
3396 if (m->msg_count > oldmsgcount)
3397 {
3398 bool verbose = m->verbose;
3399
3400 if (rc < 0)
3401 m->verbose = false;
3402
3403 struct MailboxView *mv = shared->mailbox_view;
3404 mutt_sort_headers(mv, (op == OP_RECONSTRUCT_THREAD));
3405 m->verbose = verbose;
3406
3407 /* if the root message was retrieved, move to it */
3408 struct Email *e2 = mutt_hash_find(m->id_hash, buf);
3409 if (e2)
3410 {
3411 menu_set_index(priv->menu, e2->vnum);
3412 }
3413 else
3414 {
3415 /* try to restore old position */
3416 for (int i = 0; i < m->msg_count; i++)
3417 {
3418 e2 = m->emails[i];
3419 if (!e2)
3420 break;
3421 if (e2->index == oldindex)
3422 {
3423 menu_set_index(priv->menu, e2->vnum);
3424 /* as an added courtesy, recenter the menu
3425 * with the current entry at the middle of the screen */
3427 }
3428 }
3429 }
3431 }
3432 else if (rc >= 0)
3433 {
3434 mutt_error(_("No deleted messages found in the thread"));
3435 return FR_ERROR;
3436 }
3437
3438 return FR_SUCCESS;
3439}
struct HashTable * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for Message-IDs.
Definition thread.c:1825
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:365
MenuRedrawFlags menu_current_middle(struct Menu *menu)
Move the current selection to the centre of the window.
Definition move.c:486
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:587
int nntp_check_msgid(struct Mailbox *m, const char *msgid)
Fetch article by Message-ID.
Definition nntp.c:2223
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition nntp.c:2294
#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:125
+ Here is the call graph for this function:

◆ op_get_message()

static int op_get_message ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Get parent of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_MESSAGE
  • OP_GET_PARENT

Definition at line 3448 of file functions.c.

3449{
3450 struct IndexSharedData *shared = fdata->shared;
3451 struct IndexPrivateData *priv = fdata->priv;
3452 struct Mailbox *m = shared->mailbox;
3453 if (m->type != MUTT_NNTP)
3454 return FR_SUCCESS;
3455
3456 int rc = FR_ERROR;
3457 struct Buffer *buf = buf_pool_get();
3458
3459 const int op = event->op;
3460 if (op == OP_GET_MESSAGE)
3461 {
3462 if ((mw_get_field(_("Enter Message-ID: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
3463 buf_is_empty(buf))
3464 {
3465 goto done;
3466 }
3467 }
3468 else
3469 {
3470 struct Email *e = shared->email;
3471 if (!e || STAILQ_EMPTY(&e->env->references))
3472 {
3473 mutt_error(_("Article has no parent reference"));
3474 goto done;
3475 }
3476 buf_strcpy(buf, STAILQ_FIRST(&e->env->references)->data);
3477 }
3478
3479 if (!m->id_hash)
3480 m->id_hash = mutt_make_id_hash(m);
3481 struct Email *e = mutt_hash_find(m->id_hash, buf_string(buf));
3482 if (e)
3483 {
3484 if (e->vnum != -1)
3485 {
3486 menu_set_index(priv->menu, e->vnum);
3487 }
3488 else if (e->collapsed)
3489 {
3491 mutt_set_vnum(m);
3492 menu_set_index(priv->menu, e->vnum);
3493 }
3494 else
3495 {
3496 mutt_error(_("Message is not visible in limited view"));
3497 }
3498 }
3499 else
3500 {
3501 mutt_message(_("Fetching %s from server..."), buf_string(buf));
3502 int rc2 = nntp_check_msgid(m, buf_string(buf));
3503 if (rc2 == 0)
3504 {
3505 e = m->emails[m->msg_count - 1];
3506 struct MailboxView *mv = shared->mailbox_view;
3507 mutt_sort_headers(mv, false);
3508 menu_set_index(priv->menu, e->vnum);
3510 rc = FR_SUCCESS;
3511 }
3512 else if (rc2 > 0)
3513 {
3514 mutt_error(_("Article %s not found on the server"), buf_string(buf));
3515 }
3516 }
3517
3518done:
3519 buf_pool_release(&buf);
3520 return rc;
3521}
#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 IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Open a different newsgroup - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_GROUP
  • OP_MAIN_CHANGE_GROUP_READONLY

Definition at line 3530 of file functions.c.

3531{
3533 struct IndexSharedData *shared = fdata->shared;
3534 struct IndexPrivateData *priv = fdata->priv;
3535 struct Buffer *folderbuf = buf_pool_get();
3536 buf_alloc(folderbuf, PATH_MAX);
3537
3538 OptNews = false;
3539 bool read_only;
3540 char *cp = NULL;
3541 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
3542 const int op = event->op;
3543 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_GROUP_READONLY))
3544 {
3545 cp = _("Open newsgroup in read-only mode");
3546 read_only = true;
3547 }
3548 else
3549 {
3550 cp = _("Open newsgroup");
3551 read_only = false;
3552 }
3553
3554 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
3555 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
3556 {
3557 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
3558 pretty_mailbox(folderbuf);
3559 }
3560
3561 OptNews = true;
3562 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
3563 if (!mod_data->current_news_srv)
3564 mod_data->current_news_srv = nntp_select_server(shared->mailbox, c_news_server, false);
3565 if (!mod_data->current_news_srv)
3566 goto changefoldercleanup2;
3567
3568 nntp_mailbox(shared->mailbox, folderbuf->data, folderbuf->dsize);
3569
3570 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
3571 MUTT_SEL_NONE) == -1)
3572 {
3573 goto changefoldercleanup2;
3574 }
3575
3576 /* Selected directory is okay, let's save it. */
3578
3579 if (buf_is_empty(folderbuf))
3580 {
3581 msgwin_clear_text(NULL);
3582 goto changefoldercleanup2;
3583 }
3584
3585 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
3586 if (m)
3587 {
3588 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
3589 }
3590 else
3591 {
3592 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
3593 }
3594 struct MuttWindow *dlg = dialog_find(priv->win_index);
3595 dlg->help_data = IndexNewsHelp;
3596
3597changefoldercleanup2:
3598 buf_pool_release(&folderbuf);
3599 return FR_SUCCESS;
3600}
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:53
@ MODULE_ID_NNTP
ModuleNntp, Nntp
Definition module_api.h:83
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:666
void nntp_mailbox(struct Mailbox *m, char *buf, size_t buflen)
Get first newsgroup with new messages.
Definition newsrc.c:1321
struct NntpAccountData * nntp_select_server(struct Mailbox *m, const char *server, bool leave_lock)
Open a connection to an NNTP server.
Definition newsrc.c:957
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.
Container for Accounts, Notifications.
Definition neomutt.h:41
Nntp private Module data.
Definition module_data.h:30
struct NntpAccountData * current_news_srv
Current NNTP news server.
Definition module_data.h:32
+ Here is the call graph for this function:

◆ op_post()

static int op_post ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Followup to newsgroup - Implements index_function_t -.

This function handles:

  • OP_FOLLOWUP
  • OP_FORWARD_TO_GROUP
  • OP_POST

Definition at line 3610 of file functions.c.

3611{
3612 struct IndexSharedData *shared = fdata->shared;
3613 struct IndexPrivateData *priv = fdata->priv;
3614 if (!shared->email)
3615 return FR_NO_ACTION;
3616
3617 const int op = event->op;
3618 if ((op != OP_FOLLOWUP) || !shared->email->env->followup_to ||
3619 !mutt_istr_equal(shared->email->env->followup_to, "poster") ||
3620 (query_quadoption(_("Reply by mail as poster prefers?"), shared->sub,
3621 "followup_to_poster") != MUTT_YES))
3622 {
3623 if (shared->mailbox && (shared->mailbox->type == MUTT_NNTP) &&
3624 !((struct NntpMboxData *) shared->mailbox->mdata)->allowed &&
3625 (query_quadoption(_("Posting to this group not allowed, may be moderated. Continue?"),
3626 shared->sub, "post_moderated") != MUTT_YES))
3627 {
3628 return FR_ERROR;
3629 }
3630 if (op == OP_POST)
3631 {
3632 mutt_send_message(SEND_NEWS, NULL, NULL, shared->mailbox, NULL, shared->sub);
3633 }
3634 else
3635 {
3636 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3637 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
3638 mutt_send_message(((op == OP_FOLLOWUP) ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS,
3639 NULL, NULL, shared->mailbox, &ea, shared->sub);
3640 ARRAY_FREE(&ea);
3641 }
3643 return FR_SUCCESS;
3644 }
3645
3646 struct KeyEvent event_r = { 0, OP_REPLY };
3647 return op_reply(fdata, &event_r);
3648}
static int op_reply(struct AttachFunctionData *fdata, const struct KeyEvent *event)
reply to a message - Implements attach_function_t -
Definition functions.c:688
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition string.c:678
@ SEND_NEWS
Reply to a news article.
Definition send.h:59
char * followup_to
List of 'followup-to' fields.
Definition envelope.h:80
An event such as a keypress.
Definition get.h:75
+ Here is the call graph for this function:

◆ op_main_entire_thread()

static int op_main_entire_thread ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

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

Definition at line 3654 of file functions.c.

3655{
3656 struct IndexSharedData *shared = fdata->shared;
3657 struct IndexPrivateData *priv = fdata->priv;
3659 {
3660 if (!shared->email || !shared->email->env || !shared->email->env->message_id)
3661 {
3662 mutt_message(_("No virtual folder and no Message-ID, aborting"));
3663 return FR_ERROR;
3664 } // no virtual folder, but we have Message-ID, reconstruct thread on-the-fly
3665
3666 struct Buffer *buf = buf_pool_get();
3667 buf_alloc(buf, PATH_MAX);
3668 buf_addstr(buf, "id:");
3669
3670 int msg_id_offset = 0;
3671 if ((shared->email->env->message_id)[0] == '<')
3672 msg_id_offset = 1;
3673
3674 buf_addstr(buf, shared->email->env->message_id + msg_id_offset);
3675
3676 size_t len = buf_len(buf);
3677 ASSERT(len > 0);
3678 if (buf->data[len - 1] == '>')
3679 buf->data[len - 1] = '\0';
3680
3681 change_folder_notmuch(priv->menu, buf->data, buf->dsize, &priv->oldcount, shared, false);
3682 buf_pool_release(&buf);
3683
3684 // If notmuch doesn't contain the message, we're left in an empty
3685 // vfolder. No messages are found, but nm_read_entire_thread assumes
3686 // a valid Message-ID and will throw a segfault.
3687 //
3688 // To prevent that, stay in the empty vfolder and print an error.
3689 if (!shared->mailbox)
3690 return FR_ERROR;
3691
3692 if (shared->mailbox->msg_count == 0)
3693 {
3694 mutt_error(_("failed to find message in notmuch database. try running 'notmuch new'."));
3695 return FR_ERROR;
3696 }
3697 }
3698 priv->oldcount = shared->mailbox->msg_count;
3699 int index = menu_get_index(priv->menu);
3700 struct Email *e_oldcur = mutt_get_virt_email(shared->mailbox, index);
3701 if (!e_oldcur)
3702 return FR_ERROR;
3703
3704 if (nm_read_entire_thread(shared->mailbox, e_oldcur) < 0)
3705 {
3706 mutt_message(_("Failed to read thread, aborting"));
3707 return FR_ERROR;
3708 }
3709
3710 // nm_read_entire_thread() may modify msg_count and menu won't be updated.
3711 priv->menu->max = shared->mailbox->msg_count;
3712
3713 if (priv->oldcount < shared->mailbox->msg_count)
3714 {
3715 /* nm_read_entire_thread() triggers mutt_sort_headers() if necessary */
3716 index = e_oldcur->vnum;
3717 if (e_oldcur->collapsed || shared->mailbox_view->collapsed)
3718 {
3719 index = mutt_uncollapse_thread(e_oldcur);
3720 mutt_set_vnum(shared->mailbox);
3721 }
3722 menu_set_index(priv->menu, index);
3724 }
3725
3726 return FR_SUCCESS;
3727}
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition buffer.c:497
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition buffer.c:233
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:752
int nm_read_entire_thread(struct Mailbox *m, struct Email *e)
Get the entire thread of an email.
Definition notmuch.c:1550
#define ASSERT(COND)
Definition signal2.h:59
+ Here is the call graph for this function:

◆ op_main_vfolder_from_query()

static int op_main_vfolder_from_query ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Generate virtual folder from query - Implements index_function_t -.

This function handles:

  • OP_MAIN_VFOLDER_FROM_QUERY
  • OP_MAIN_VFOLDER_FROM_QUERY_READONLY

Definition at line 3736 of file functions.c.

3738{
3739 struct IndexSharedData *shared = fdata->shared;
3740 struct IndexPrivateData *priv = fdata->priv;
3741 int rc = FR_SUCCESS;
3742 struct Buffer *buf = buf_pool_get();
3743
3744 if ((mw_get_field("Query: ", buf, MUTT_COMP_NONE, HC_OTHER, &CompleteNmQueryOps, NULL) != 0) ||
3745 buf_is_empty(buf))
3746 {
3747 mutt_message(_("No query, aborting"));
3748 rc = FR_NO_ACTION;
3749 goto done;
3750 }
3751
3752 // Keep copy of user's query to name the mailbox
3753 char *query_unencoded = buf_strdup(buf);
3754
3755 buf_alloc(buf, PATH_MAX);
3756 const int op = event->op;
3757 struct Mailbox *m_query = change_folder_notmuch(priv->menu, buf->data, buf->dsize,
3758 &priv->oldcount, shared,
3759 (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY));
3760 if (m_query)
3761 {
3762 FREE(&m_query->name);
3763 m_query->name = query_unencoded;
3764 query_unencoded = NULL;
3765 rc = FR_SUCCESS;
3766 }
3767 else
3768 {
3769 FREE(&query_unencoded);
3770 }
3771
3772done:
3773 buf_pool_release(&buf);
3774 return rc;
3775}
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition buffer.c:577
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
const struct CompleteOps CompleteNmQueryOps
Auto-Completion of NmQuerys.
Definition complete.c:284
char * name
A short name for the Mailbox.
Definition mailbox.h:84
+ Here is the call graph for this function:

◆ op_main_windowed_vfolder()

static int op_main_windowed_vfolder ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
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 3785 of file functions.c.

3787{
3788 struct IndexSharedData *shared = fdata->shared;
3789 struct IndexPrivateData *priv = fdata->priv;
3790 // Common guard clauses.
3792 {
3793 mutt_message(_("Windowed queries disabled"));
3794 return FR_ERROR;
3795 }
3796 const char *const c_nm_query_window_current_search = cs_subset_string(shared->sub, "nm_query_window_current_search");
3797 if (!c_nm_query_window_current_search)
3798 {
3799 mutt_message(_("No notmuch vfolder currently loaded"));
3800 return FR_ERROR;
3801 }
3802
3803 // Call the specific operation.
3804 switch (event->op)
3805 {
3806 case OP_MAIN_WINDOWED_VFOLDER_BACKWARD:
3808 break;
3809 case OP_MAIN_WINDOWED_VFOLDER_FORWARD:
3811 break;
3812 case OP_MAIN_WINDOWED_VFOLDER_RESET:
3814 break;
3815 }
3816
3817 // Common query window folder change.
3818 char buf[PATH_MAX] = { 0 };
3819 mutt_str_copy(buf, c_nm_query_window_current_search, sizeof(buf));
3820 change_folder_notmuch(priv->menu, buf, sizeof(buf), &priv->oldcount, shared, false);
3821
3822 return FR_SUCCESS;
3823}
void nm_query_window_reset(void)
Resets the vfolder window position to the present.
Definition notmuch.c:1725
void nm_query_window_backward(void)
Function to move the current search window backward in time.
Definition notmuch.c:1714
bool nm_query_window_available(void)
Are windowed queries enabled for use?
Definition notmuch.c:1677
void nm_query_window_forward(void)
Function to move the current search window forward in time.
Definition notmuch.c:1694
+ Here is the call graph for this function:

◆ op_main_fetch_mail()

static int op_main_fetch_mail ( struct IndexFunctionData * fdata,
const struct KeyEvent * event )
static

Retrieve mail from POP server - Implements index_function_t -.

Definition at line 3829 of file functions.c.

3830{
3831 struct IndexPrivateData *priv = fdata->priv;
3834 return FR_SUCCESS;
3835}
void pop_fetch_mail(void)
Fetch messages and save them in $spool_file.
Definition pop.c:530
+ Here is the call graph for this function: