NeoMutt  2025-12-11-1039-g550ac6
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()

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

Open the aliases dialog - Implements index_function_t -.

Definition at line 620 of file functions.c.

621{
622 struct IndexSharedData *shared = fdata->shared;
623 alias_dialog(shared->mailbox, shared->sub);
624 return FR_SUCCESS;
625}
@ 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:508
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()

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

Edit attachment content type - Implements index_function_t -.

Definition at line 630 of file functions.c.

631{
632 struct IndexSharedData *shared = fdata->shared;
633 struct IndexPrivateData *priv = fdata->priv;
634 if (!shared->email)
635 return FR_NO_ACTION;
637
639 return FR_SUCCESS;
640}
@ 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:1077
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()

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 645 of file functions.c.

646{
647 struct IndexSharedData *shared = fdata->shared;
648 struct IndexPrivateData *priv = fdata->priv;
649 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
650 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
651 index_bounce_message(shared->mailbox, &ea);
652 ARRAY_FREE(&ea);
653
654 return FR_SUCCESS;
655}
#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()

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

Check for classic PGP - Implements index_function_t -.

Definition at line 660 of file functions.c.

661{
662 struct IndexSharedData *shared = fdata->shared;
663 struct IndexPrivateData *priv = fdata->priv;
665 return FR_NOT_IMPL;
666 if (!shared->email)
667 return FR_NO_ACTION;
668
670 {
671 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
672 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
673 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
675 ARRAY_FREE(&ea);
676 }
677
678 return FR_SUCCESS;
679}
@ 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:1218
@ 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()

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 684 of file functions.c.

685{
686 struct IndexSharedData *shared = fdata->shared;
687 struct IndexPrivateData *priv = fdata->priv;
688 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
689 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
690 int rc = mutt_send_message(SEND_TO_SENDER, NULL, NULL, shared->mailbox, &ea,
691 shared->sub);
692 ARRAY_FREE(&ea);
694
695 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
696}
@ 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:2035
@ SEND_TO_SENDER
Compose new email to sender.
Definition send.h:57
Here is the call graph for this function:

◆ op_create_alias()

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 701 of file functions.c.

702{
703 struct IndexSharedData *shared = fdata->shared;
704 struct IndexPrivateData *priv = fdata->priv;
705 struct AddressList *al = NULL;
706 if (shared->email && shared->email->env)
707 al = mutt_get_address(shared->email->env, NULL);
708 alias_create(al, shared->sub);
710
711 return FR_SUCCESS;
712}
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()

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 721 of file functions.c.

722{
723 struct IndexSharedData *shared = fdata->shared;
724 struct IndexPrivateData *priv = fdata->priv;
725 /* L10N: CHECK_ACL */
726 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete message")))
727 return FR_ERROR;
728
729 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
730 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
731 event->count);
732 if (ARRAY_EMPTY(&ea))
733 {
734 ARRAY_FREE(&ea);
735 return FR_NO_ACTION;
736 }
737
738 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, true);
739 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, (event->op == OP_PURGE_MESSAGE));
740 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
741 if (c_delete_untag)
742 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_TAG, false);
743 ARRAY_FREE(&ea);
744
745 if (priv->tag_prefix)
746 {
748 }
749 else
750 {
751 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
752 }
753
754 return FR_SUCCESS;
755}
#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:480
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:371
@ RESOLVE_NEXT_UNDELETED
Next undeleted email.
Definition functions.c:324
@ 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()

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_SUBTHREAD
  • OP_PURGE_THREAD

Definition at line 874 of file functions.c.

875{
876 struct IndexSharedData *shared = fdata->shared;
877 struct IndexPrivateData *priv = fdata->priv;
878 /* L10N: CHECK_ACL */
879 /* L10N: Due to the implementation details we do not know whether we
880 delete zero, 1, 12, ... messages. So in English we use
881 "messages". Your language might have other means to express this. */
882 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
883 return FR_ERROR;
884 if (!shared->email)
885 return FR_NO_ACTION;
886
887 const int op = event->op;
888 const bool subthread = ((op == OP_DELETE_SUBTHREAD) || (op == OP_PURGE_SUBTHREAD));
889 int rc = 0;
890 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
891 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
892 priv->tag_prefix, subthread, event->count);
893
894 struct Email **ep = NULL;
895 ARRAY_FOREACH(ep, &ea)
896 {
897 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_DELETE, true, subthread);
898 if (rc == -1)
899 break;
900
901 if ((op == OP_PURGE_THREAD) || (op == OP_PURGE_SUBTHREAD))
902 {
903 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_PURGE, true, subthread);
904 if (rc == -1)
905 break;
906 }
907
908 const bool c_delete_untag = cs_subset_bool(shared->sub, "delete_untag");
909 if (c_delete_untag)
910 mutt_thread_set_flag(shared->mailbox, *ep, MUTT_TAG, false, subthread);
911 }
912 ARRAY_FREE(&ea);
913
914 if (rc == -1)
915 return FR_ERROR;
916
917 if (priv->tag_prefix)
918 {
920 return FR_SUCCESS;
921 }
922
923 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
925 return FR_SUCCESS;
926}
#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:568
The envelope/body of an email.
Definition email.h:39
Here is the call graph for this function:

◆ op_display_address()

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

Display full address of sender - Implements index_function_t -.

Definition at line 931 of file functions.c.

932{
933 struct IndexSharedData *shared = fdata->shared;
934 if (!shared->email)
935 return FR_NO_ACTION;
937
938 return FR_SUCCESS;
939}
void mutt_display_address(struct Envelope *env)
Display the address of a message.
Definition external.c:667
Here is the call graph for this function:

◆ op_display_message()

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 949 of file functions.c.

950{
951 struct IndexSharedData *shared = fdata->shared;
952 struct IndexPrivateData *priv = fdata->priv;
953 if (!shared->email)
954 return FR_NO_ACTION;
955
956 if (event->count > 0)
957 return op_jump(fdata, event);
958
959 int op = event->op;
960
961 if (op == OP_DISPLAY_MESSAGE)
962 {
963 if (!window_is_focused(priv->win_index))
964 return FR_SUCCESS;
965 }
966
968
969 /* toggle the weeding of headers so that a user can press the key
970 * again while reading the message. */
971 if (op == OP_DISPLAY_HEADERS)
972 {
973 bool_str_toggle(shared->sub, "weed", NULL);
975 if (!window_is_focused(priv->win_index))
976 return FR_SUCCESS;
977 }
978
979 OptNeedResort = false;
980
982 {
985 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
986 if (c_uncollapse_jump)
988 }
989
990 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
991 if (c_pgp_auto_decode &&
993 {
994 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
995 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
996 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
998 ARRAY_FREE(&ea);
999 }
1000 const int index = menu_get_index(priv->menu);
1002
1003 const char *const c_pager = pager_get_pager(fdata->n->sub);
1004 if (c_pager)
1005 {
1006 op = external_pager(shared->mailbox_view, shared->email, c_pager);
1007 }
1008 else
1009 {
1010 op = mutt_display_message(priv->win_index, shared);
1011 }
1012
1014 if (op < OP_NULL)
1015 {
1016 OptNeedResort = false;
1017 return FR_ERROR;
1018 }
1019
1020 if (shared->mailbox)
1021 {
1023 shared->mailbox->msg_count, shared);
1024 }
1025
1026 return op;
1027}
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()

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 1032 of file functions.c.

1033{
1034 struct IndexSharedData *shared = fdata->shared;
1035 struct IndexPrivateData *priv = fdata->priv;
1036 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1037 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1038 event->count);
1039 if (ARRAY_EMPTY(&ea))
1040 {
1041 ARRAY_FREE(&ea);
1042 return FR_NO_ACTION;
1043 }
1044 const int num = ARRAY_SIZE(&ea);
1045 int num_changed = mutt_label_message(shared->mailbox_view, &ea);
1046 ARRAY_FREE(&ea);
1047
1048 if (num_changed > 0)
1049 {
1050 shared->mailbox->changed = true;
1052 /* L10N: This is displayed when the x-label on one or more
1053 messages is edited. */
1054 mutt_message(ngettext("%d label changed", "%d labels changed", num_changed), num_changed);
1055
1056 if (!priv->tag_prefix)
1057 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
1058 return FR_SUCCESS;
1059 }
1060
1061 /* L10N: This is displayed when editing an x-label, but no messages
1062 were updated. Possibly due to canceling at the prompt or if the new
1063 label is the same as the old label. */
1064 mutt_message(_("No labels changed"));
1065 return FR_NO_ACTION;
1066}
#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()

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 1076 of file functions.c.

1077{
1078 struct IndexSharedData *shared = fdata->shared;
1079 struct IndexPrivateData *priv = fdata->priv;
1080 /* TODO split this into 3 cases? */
1081 bool edit;
1082 const int op = event->op;
1083 if (op == OP_EDIT_RAW_MESSAGE)
1084 {
1085 /* L10N: CHECK_ACL */
1086 if (!check_acl(shared->mailbox, MUTT_ACL_INSERT, _("Can't edit message")))
1087 return FR_ERROR;
1088 edit = true;
1089 }
1090 else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
1091 {
1093 }
1094 else
1095 {
1096 edit = false;
1097 }
1098
1099 if (!shared->email)
1100 return FR_NO_ACTION;
1101 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1102 if (c_pgp_auto_decode &&
1104 {
1105 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1106 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1107 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1109 ARRAY_FREE(&ea);
1110 }
1111 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1112 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1113 mutt_ev_message(shared->mailbox, &ea, edit ? EVM_EDIT : EVM_VIEW);
1114 ARRAY_FREE(&ea);
1116
1117 return FR_SUCCESS;
1118}
@ 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()

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

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

Definition at line 1123 of file functions.c.

1124{
1125 return FR_SUCCESS;
1126}

◆ op_exit()

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

Exit this menu - Implements index_function_t -.

Definition at line 1131 of file functions.c.

1132{
1133 struct IndexSharedData *shared = fdata->shared;
1134 if (shared->attach_msg)
1135 return FR_DONE;
1136
1137 if (query_quadoption(_("Exit NeoMutt without saving?"), shared->sub, "quit") == MUTT_YES)
1138 {
1139 if (shared->mailbox_view)
1140 {
1141 mx_fastclose_mailbox(shared->mailbox, false);
1142 mview_free(&shared->mailbox_view);
1143 }
1144 return FR_DONE;
1145 }
1146
1147 return FR_NO_ACTION;
1148}
@ 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()

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

Extract supported public keys - Implements index_function_t -.

Definition at line 1153 of file functions.c.

1154{
1155 struct IndexSharedData *shared = fdata->shared;
1156 struct IndexPrivateData *priv = fdata->priv;
1157 if (!WithCrypto)
1158 return FR_NOT_IMPL;
1159 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1160 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1162 ARRAY_FREE(&ea);
1164
1165 return FR_SUCCESS;
1166}
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()

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 1171 of file functions.c.

1172{
1173 struct IndexSharedData *shared = fdata->shared;
1174 struct IndexPrivateData *priv = fdata->priv;
1175 /* L10N: CHECK_ACL */
1176 if (!check_acl(shared->mailbox, MUTT_ACL_WRITE, _("Can't flag message")))
1177 return FR_ERROR;
1178
1179 struct Mailbox *m = shared->mailbox;
1180 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1181 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1182 event->count);
1183 if (ARRAY_EMPTY(&ea))
1184 {
1185 ARRAY_FREE(&ea);
1186 return FR_NO_ACTION;
1187 }
1188 const int num = ARRAY_SIZE(&ea);
1189
1190 struct Email **ep = NULL;
1191 ARRAY_FOREACH(ep, &ea)
1192 mutt_set_flag(m, *ep, MUTT_FLAG, !(*ep)->flagged, true);
1193 ARRAY_FREE(&ea);
1194
1195 if (priv->tag_prefix)
1196 {
1198 }
1199 else
1200 {
1201 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
1202 if (num > 1)
1204 }
1205
1206 return FR_SUCCESS;
1207}
@ 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()

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

Forward a message with comments - Implements index_function_t -.

Definition at line 1212 of file functions.c.

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

◆ op_group_reply()

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 1242 of file functions.c.

1243{
1244 struct IndexSharedData *shared = fdata->shared;
1245 struct IndexPrivateData *priv = fdata->priv;
1246 SendFlags replyflags = SEND_REPLY;
1247 if (event->op == OP_GROUP_REPLY)
1248 replyflags |= SEND_GROUP_REPLY;
1249 else
1250 replyflags |= SEND_GROUP_CHAT_REPLY;
1251 if (!shared->email)
1252 return FR_NO_ACTION;
1253 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1254 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1255 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
1256 if (c_pgp_auto_decode &&
1257 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
1258 {
1259 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
1261 }
1262 int rc = mutt_send_message(replyflags, NULL, NULL, shared->mailbox, &ea,
1263 shared->sub);
1264 ARRAY_FREE(&ea);
1266
1267 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
1268}
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()

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

Jump to an index number - Implements index_function_t -.

Definition at line 1273 of file functions.c.

1274{
1275 struct IndexSharedData *shared = fdata->shared;
1276 struct IndexPrivateData *priv = fdata->priv;
1277 int rc = FR_ERROR;
1278 struct Buffer *buf = buf_pool_get();
1279
1280 int num = event->count;
1281 if (num == 0)
1282 {
1283 if ((mw_get_field(_("Jump to message: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
1284 buf_is_empty(buf))
1285 {
1286 mutt_message(_("Nothing to do"));
1287 rc = FR_NO_ACTION;
1288 goto done;
1289 }
1290
1291 if (!mutt_str_atoi_full(buf_string(buf), &num))
1292 {
1293 mutt_warning(_("Argument must be a message number"));
1294 goto done;
1295 }
1296 }
1297
1298 if ((num < 1) || (num > shared->mailbox->msg_count))
1299 {
1300 mutt_warning(_("Invalid message number"));
1301 }
1302 else if (!shared->mailbox->emails[num - 1] ||
1303 !shared->mailbox->emails[num - 1]->visible)
1304 {
1305 mutt_warning(_("That message is not visible"));
1306 }
1307 else
1308 {
1309 struct Email *e = shared->mailbox->emails[num - 1];
1310
1311 if (mutt_messages_in_thread(shared->mailbox, e, MIT_POSITION) > 1)
1312 {
1314 mutt_set_vnum(shared->mailbox);
1315 }
1316 menu_set_index(priv->menu, e->vnum);
1317 rc = FR_SUCCESS;
1318 }
1319
1320done:
1321 buf_pool_release(&buf);
1322 return rc;
1323}
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()

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

Show mailing-list actions - Implements index_function_t -.

Definition at line 1328 of file functions.c.

1329{
1330 struct IndexSharedData *shared = fdata->shared;
1331 struct IndexPrivateData *priv = fdata->priv;
1332
1335 return FR_SUCCESS;
1336}
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()

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

Reply to specified mailing list - Implements index_function_t -.

Definition at line 1341 of file functions.c.

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

◆ op_list_subscribe()

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

Subscribe to a mailing list - Implements index_function_t -.

Definition at line 1367 of file functions.c.

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

◆ op_list_unsubscribe()

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

Unsubscribe from mailing list - Implements index_function_t -.

Definition at line 1376 of file functions.c.

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

◆ op_mail()

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

Compose a new mail message - Implements index_function_t -.

Definition at line 1385 of file functions.c.

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

◆ op_mailbox_list()

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

List mailboxes with new mail - Implements index_function_t -.

Definition at line 1398 of file functions.c.

1399{
1401 return FR_SUCCESS;
1402}
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()

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

Mail a PGP public key - Implements index_function_t -.

Definition at line 1407 of file functions.c.

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

◆ op_main_break_thread()

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 1422 of file functions.c.

1423{
1424 struct IndexSharedData *shared = fdata->shared;
1425 struct IndexPrivateData *priv = fdata->priv;
1426 struct Mailbox *m = shared->mailbox;
1427 /* L10N: CHECK_ACL */
1428 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't break thread")))
1429 return FR_ERROR;
1430
1431 struct Email *e = shared->email;
1432 if (!e)
1433 return FR_NO_ACTION;
1434
1435 const bool has_repeat_count = (event->count > 0);
1436
1437 if (!mutt_using_threads())
1438 {
1439 mutt_warning(_("Threading is not enabled"));
1440 return FR_ERROR;
1441 }
1442
1443 struct MailboxView *mv = shared->mailbox_view;
1444 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1445 if (ea_add_selection(&ea, mv, e, false, event->count) <= 0)
1446 {
1447 ARRAY_FREE(&ea);
1448 return FR_NO_ACTION;
1449 }
1450
1451 bool changed = false;
1452 struct Email **ep = NULL;
1453 ARRAY_FOREACH(ep, &ea)
1454 {
1455 e = *ep;
1456 if (!e || (STAILQ_EMPTY(&e->env->in_reply_to) && STAILQ_EMPTY(&e->env->references)))
1457 continue;
1458
1459 {
1461 changed = true;
1462 }
1463 }
1464 ARRAY_FREE(&ea);
1465
1466 if (changed)
1467 {
1468 mutt_sort_headers(mv, true);
1469 menu_set_index(priv->menu, shared->email->vnum);
1470 m->changed = true;
1471 mutt_message(_("Thread broken"));
1472
1474 }
1475 else if (!has_repeat_count)
1476 {
1477 mutt_error(_("Thread can't be broken, message is not part of a thread"));
1478 return FR_ERROR;
1479 }
1480
1481 return FR_SUCCESS;
1482}
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()

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_BROWSE_MAILBOXES
  • OP_MAIN_BROWSE_MAILBOXES_READONLY
  • OP_MAIN_CHANGE_FOLDER
  • OP_MAIN_CHANGE_FOLDER_READONLY
  • OP_MAIN_CHANGE_VFOLDER

Definition at line 1494 of file functions.c.

1495{
1496 struct IndexSharedData *shared = fdata->shared;
1497 struct IndexPrivateData *priv = fdata->priv;
1498 struct Buffer *folderbuf = buf_pool_get();
1499 buf_alloc(folderbuf, PATH_MAX);
1500
1501 const int op = event->op;
1502 const bool browse = (op == OP_MAIN_BROWSE_MAILBOXES) ||
1503 (op == OP_MAIN_BROWSE_MAILBOXES_READONLY);
1504 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
1505 const bool read_only = shared->attach_msg || c_read_only ||
1506 (op == OP_MAIN_BROWSE_MAILBOXES_READONLY) ||
1507 (op == OP_MAIN_CHANGE_FOLDER_READONLY);
1508
1509 if (browse)
1510 {
1512 shared->mailbox, NULL, NULL);
1513 }
1514 else
1515 {
1516 const char *cp = read_only ? _("Open mailbox in read-only mode") :
1517 _("Open mailbox");
1518
1519 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
1520 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
1521 {
1522 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
1523 pretty_mailbox(folderbuf);
1524 }
1525 /* By default, fill buf with the next mailbox that contains unread mail */
1526 mutt_mailbox_next(shared->mailbox_view ? shared->mailbox : NULL, folderbuf);
1527
1528 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
1529 MUTT_SEL_NONE) == -1)
1530 {
1531 goto changefoldercleanup;
1532 }
1533 }
1534
1535 /* Selected directory is okay, let's save it. */
1537
1538 if (buf_is_empty(folderbuf))
1539 {
1540 msgwin_clear_text(NULL);
1541 goto changefoldercleanup;
1542 }
1543
1544 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
1545 if (m)
1546 {
1547 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
1548 }
1549 else
1550 {
1551 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
1552 }
1553
1554changefoldercleanup:
1555 buf_pool_release(&folderbuf);
1557
1558 return FR_SUCCESS;
1559}
@ MUTT_SEL_MAILBOX
Select a mailbox.
Definition lib.h:60
@ MUTT_SEL_FOLDER
Select a local directory.
Definition lib.h:62
@ 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
void dlg_browser(struct Buffer *file, SelectFileFlags flags, struct Mailbox *m, char ***files, int *numfiles)
Let the user select a file -.
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:431
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()

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

Collapse/uncollapse all threads - Implements index_function_t -.

Definition at line 1564 of file functions.c.

1565{
1566 struct IndexSharedData *shared = fdata->shared;
1567 struct IndexPrivateData *priv = fdata->priv;
1568 if (!mutt_using_threads())
1569 {
1570 mutt_warning(_("Threading is not enabled"));
1571 return FR_ERROR;
1572 }
1575
1576 return FR_SUCCESS;
1577}
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()

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

Collapse all threads - Implements index_function_t -.

Definition at line 1582 of file functions.c.

1584{
1585 struct IndexSharedData *shared = fdata->shared;
1586 struct IndexPrivateData *priv = fdata->priv;
1587 if (!mutt_using_threads())
1588 {
1589 mutt_warning(_("Threading is not enabled"));
1590 return FR_ERROR;
1591 }
1592
1594 return FR_NO_ACTION;
1595
1598
1599 return FR_SUCCESS;
1600}
@ 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()

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

Collapse current thread - Implements index_function_t -.

Definition at line 1605 of file functions.c.

1606{
1607 struct IndexSharedData *shared = fdata->shared;
1608 struct IndexPrivateData *priv = fdata->priv;
1609 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1610 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1611 priv->tag_prefix, false, event->count);
1612 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_CLOSE);
1613 ARRAY_FREE(&ea);
1614 return rc;
1615}
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:787
Here is the call graph for this function:

◆ op_main_collapse_thread()

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

Collapse/uncollapse current thread - Implements index_function_t -.

Definition at line 1620 of file functions.c.

1621{
1622 struct IndexSharedData *shared = fdata->shared;
1623 struct IndexPrivateData *priv = fdata->priv;
1624 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1625 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1626 priv->tag_prefix, false, event->count);
1627 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_TOGGLE);
1628 ARRAY_FREE(&ea);
1629 return rc;
1630}
Here is the call graph for this function:

◆ op_main_open_all_threads()

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

Open all threads - Implements index_function_t -.

Definition at line 1635 of file functions.c.

1637{
1638 struct IndexSharedData *shared = fdata->shared;
1639 struct IndexPrivateData *priv = fdata->priv;
1640 if (!mutt_using_threads())
1641 {
1642 mutt_warning(_("Threading is not enabled"));
1643 return FR_ERROR;
1644 }
1645
1647 return FR_NO_ACTION;
1648
1651
1652 return FR_SUCCESS;
1653}
@ COLLAPSE_MODE_OPEN
Open all threads.
Definition lib.h:105
Here is the call graph for this function:

◆ op_main_open_thread()

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

Open current thread - Implements index_function_t -.

Definition at line 1658 of file functions.c.

1659{
1660 struct IndexSharedData *shared = fdata->shared;
1661 struct IndexPrivateData *priv = fdata->priv;
1662 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1663 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
1664 priv->tag_prefix, false, event->count);
1665 const int rc = op_main_change_thread(fdata, &ea, COLLAPSE_MODE_OPEN);
1666 ARRAY_FREE(&ea);
1667 return rc;
1668}
Here is the call graph for this function:

◆ op_main_delete_pattern()

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

Delete messages matching a pattern - Implements index_function_t -.

This function handles:

  • OP_MAIN_DELETE_PATTERN
  • OP_PURGE_PATTERN

Definition at line 1677 of file functions.c.

1678{
1679 struct IndexSharedData *shared = fdata->shared;
1680 struct IndexPrivateData *priv = fdata->priv;
1681 /* L10N: CHECK_ACL */
1682 /* L10N: Due to the implementation details we do not know whether we
1683 delete zero, 1, 12, ... messages. So in English we use
1684 "messages". Your language might have other means to express this. */
1685 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't delete messages")))
1686 return FR_ERROR;
1687
1688 const bool purge = (event->op == OP_PURGE_PATTERN);
1689 mutt_pattern_func(shared->mailbox_view, MUTT_DELETE, _("Delete messages matching: "));
1690 if (purge)
1693
1694 return FR_SUCCESS;
1695}
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()

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 1705 of file functions.c.

1706{
1707 struct IndexSharedData *shared = fdata->shared;
1708 struct IndexPrivateData *priv = fdata->priv;
1709 const bool lmt = mview_has_limit(shared->mailbox_view);
1710 int old_index = shared->email ? shared->email->index : -1;
1711 const int op = event->op;
1712 if (op == OP_TOGGLE_READ)
1713 {
1714 struct Buffer *buf2 = buf_pool_get();
1715
1716 if (!lmt || !mutt_strn_equal(shared->mailbox_view->pattern, "!~R!~D~s", 8))
1717 {
1718 buf_printf(buf2, "!~R!~D~s%s", lmt ? shared->mailbox_view->pattern : ".*");
1719 }
1720 else
1721 {
1722 const char *pat = shared->mailbox_view->pattern + 8;
1723 if ((*pat == '\0') || mutt_strn_equal(pat, ".*", 2))
1724 buf_strcpy(buf2, "~A");
1725 else
1726 buf_strcpy(buf2, pat);
1727 }
1729 buf_pool_release(&buf2);
1731 }
1732
1733 if (((op == OP_LIMIT_CURRENT_THREAD) &&
1734 mutt_limit_current_thread(shared->mailbox_view, shared->email)) ||
1735 (op == OP_TOGGLE_READ) ||
1736 ((op == OP_MAIN_LIMIT) && (mutt_pattern_func(shared->mailbox_view, MUTT_LIMIT,
1737 _("Limit to messages matching: ")) == 0)))
1738 {
1739 priv->menu->max = shared->mailbox->vcount;
1740 menu_set_index(priv->menu, 0);
1741 if (old_index >= 0)
1742 {
1743 /* try to find what used to be the current message */
1744 for (size_t i = 0; i < shared->mailbox->vcount; i++)
1745 {
1746 struct Email *e = mutt_get_virt_email(shared->mailbox, i);
1747 if (!e)
1748 continue;
1749 if (e->index == old_index)
1750 {
1751 menu_set_index(priv->menu, i);
1752 break;
1753 }
1754 }
1755 }
1756
1757 if ((shared->mailbox->msg_count != 0) && mutt_using_threads())
1758 {
1759 const bool c_collapse_all = cs_subset_bool(shared->sub, "collapse_all");
1760 if (c_collapse_all)
1763 }
1764 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1766 }
1767 if (lmt)
1768 mutt_message(_("To view all messages, limit to \"all\""));
1769
1770 return FR_SUCCESS;
1771}
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()

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 1779 of file functions.c.

1780{
1781 struct IndexSharedData *shared = fdata->shared;
1782 struct IndexPrivateData *priv = fdata->priv;
1783 struct Mailbox *m = shared->mailbox;
1784 /* L10N: CHECK_ACL */
1785 if (!check_acl(m, MUTT_ACL_WRITE, _("Can't link threads")))
1786 return FR_ERROR;
1787
1788 struct Email *e = shared->email;
1789 if (!e)
1790 return FR_NO_ACTION;
1791
1792 enum FunctionRetval rc = FR_ERROR;
1793
1794 if (!mutt_using_threads())
1795 {
1796 mutt_warning(_("Threading is not enabled"));
1797 rc = FR_ERROR;
1798 }
1799 else if (!e->env->message_id)
1800 {
1801 mutt_error(_("No Message-ID: header available to link thread"));
1802 }
1803 else
1804 {
1805 struct MailboxView *mv = shared->mailbox_view;
1806 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1807
1808 // If there's a repeat-count, use it.
1809 // If not, behave as if <tag-prefix> has been pressed.
1810 const bool tag_prefix = (event->count < 1);
1811 ea_add_selection(&ea, mv, e, tag_prefix, event->count);
1812
1813 if (!tag_prefix)
1814 {
1815 struct Email **ep = ARRAY_GET(&ea, 0);
1816 if (ep && (*ep == e))
1817 ARRAY_REMOVE(&ea, ep);
1818 }
1819
1820 if (mutt_link_threads(e, &ea, m))
1821 {
1822 mutt_sort_headers(mv, true);
1823 menu_set_index(priv->menu, e->vnum);
1824
1825 m->changed = true;
1826 mutt_message(_("Threads linked"));
1827 rc = FR_SUCCESS;
1828 }
1829 else
1830 {
1831 mutt_error(_("No thread linked"));
1832 rc = FR_ERROR;
1833 }
1834
1835 ARRAY_FREE(&ea);
1836 }
1837
1839 return rc;
1840}
#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()

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 1849 of file functions.c.

1850{
1851 struct IndexSharedData *shared = fdata->shared;
1852 struct IndexPrivateData *priv = fdata->priv;
1853 int rc = FR_ERROR;
1854 struct Buffer *buf = NULL;
1855 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1856
1857 if (!shared->mailbox)
1858 goto done;
1859 struct Mailbox *m = shared->mailbox;
1860 if (!mx_tags_is_supported(m))
1861 {
1862 mutt_message(_("Folder doesn't support tagging, aborting"));
1863 goto done;
1864 }
1865 if (!shared->email)
1866 {
1867 rc = FR_NO_ACTION;
1868 goto done;
1869 }
1870
1871 const int op = event->op;
1872 struct Buffer *tags = buf_pool_get();
1873 if (!priv->tag_prefix)
1874 driver_tags_get_with_hidden(&shared->email->tags, tags);
1875 /* Prompt the user to edit the tag string */
1876 buf = buf_pool_get();
1877 int rc2 = mx_tags_edit(m, buf_string(tags), buf);
1878 buf_pool_release(&tags);
1879 if (rc2 < 0)
1880 {
1881 goto done;
1882 }
1883 else if (rc2 == 0)
1884 {
1885 mutt_message(_("No tag specified, aborting"));
1886 goto done;
1887 }
1888
1889 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
1890 event->count);
1891 const int num = ARRAY_SIZE(&ea);
1892
1893 if (priv->tag_prefix || (num > 1))
1894 {
1895 struct Progress *progress = NULL;
1896
1897 if (m->verbose)
1898 {
1899 progress = progress_new(MUTT_PROGRESS_WRITE, num);
1900 progress_set_message(progress, _("Update tags..."));
1901 }
1902
1903#ifdef USE_NOTMUCH
1904 if (m->type == MUTT_NOTMUCH)
1905 nm_db_longrun_init(m, true);
1906#endif
1907 struct Email **ep = NULL;
1908 int px = 0;
1909 ARRAY_FOREACH(ep, &ea)
1910 {
1911 struct Email *e = *ep;
1912
1913 progress_update(progress, ++px, -1);
1914 mx_tags_commit(m, e, buf_string(buf));
1915 e->attr_color = NULL;
1916 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1917 {
1918 bool still_queried = false;
1919#ifdef USE_NOTMUCH
1920 if (m->type == MUTT_NOTMUCH)
1921 still_queried = nm_message_is_still_queried(m, e);
1922#endif
1923 e->quasi_deleted = !still_queried;
1924 m->changed = true;
1925 }
1926 }
1927 progress_free(&progress);
1928#ifdef USE_NOTMUCH
1929 if (m->type == MUTT_NOTMUCH)
1931#endif
1933 if (!priv->tag_prefix)
1935 (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE) ? 1 : num);
1936 }
1937 else
1938 {
1939 if (mx_tags_commit(m, shared->email, buf_string(buf)))
1940 {
1941 mutt_message(_("Failed to modify tags, aborting"));
1942 goto done;
1943 }
1944 shared->email->attr_color = NULL;
1945 if (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE)
1946 {
1947 bool still_queried = false;
1948#ifdef USE_NOTMUCH
1949 if (m->type == MUTT_NOTMUCH)
1950 still_queried = nm_message_is_still_queried(m, shared->email);
1951#endif
1952 shared->email->quasi_deleted = !still_queried;
1953 m->changed = true;
1954 }
1955
1957 (op == OP_MAIN_MODIFY_TAGS_THEN_HIDE) ? 1 : num);
1958 }
1959 rc = FR_SUCCESS;
1960
1961done:
1962 ARRAY_FREE(&ea);
1963 buf_pool_release(&buf);
1964 return rc;
1965}
@ 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()

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 1987 of file functions.c.

1988{
1989 int first_unread = -1;
1990 int first_new = -1;
1991 int mcur = start;
1992 const bool threaded = mutt_using_threads();
1993
1994 for (int i = 0; i < m->vcount; i++)
1995 {
1996 if (forwards)
1997 {
1998 mcur++;
1999 if (mcur > (m->vcount - 1))
2000 mcur = 0;
2001 }
2002 else
2003 {
2004 mcur--;
2005 if (mcur < 0)
2006 mcur = m->vcount - 1;
2007 }
2008
2009 struct Email *e = mutt_get_virt_email(m, mcur);
2010 if (!e)
2011 break;
2012 if (e->collapsed && threaded)
2013 {
2014 int unread = mutt_thread_contains_unread(e);
2015 if ((unread != 0) && (first_unread == -1))
2016 first_unread = mcur;
2017 if ((unread == 1) && (first_new == -1))
2018 first_new = mcur;
2019 }
2020 else if (!e->deleted && !e->read)
2021 {
2022 if (first_unread == -1)
2023 first_unread = mcur;
2024 if (!e->old && (first_new == -1))
2025 first_new = mcur;
2026 }
2027
2028 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD)) && (first_unread != -1))
2029 break;
2030 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
2031 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2032 (first_new != -1))
2033 {
2034 break;
2035 }
2036 }
2037
2038 if (((op == OP_MAIN_NEXT_NEW) || (op == OP_MAIN_PREV_NEW) ||
2039 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2040 (first_new != -1))
2041 {
2042 return first_new;
2043 }
2044 if (((op == OP_MAIN_NEXT_UNREAD) || (op == OP_MAIN_PREV_UNREAD) ||
2045 (op == OP_MAIN_NEXT_NEW_THEN_UNREAD) || (op == OP_MAIN_PREV_NEW_THEN_UNREAD)) &&
2046 (first_unread != -1))
2047 {
2048 return first_unread;
2049 }
2050
2051 return -1;
2052}
#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()

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 2132 of file functions.c.

2133{
2134 struct IndexSharedData *shared = fdata->shared;
2135 struct IndexPrivateData *priv = fdata->priv;
2136 const int op = event->op;
2137 const int count = event->count;
2138 const bool forwards = (op == OP_MAIN_NEXT_THREAD) || (op == OP_MAIN_NEXT_SUBTHREAD);
2139 const bool subthreads = (op == OP_MAIN_NEXT_SUBTHREAD) || (op == OP_MAIN_PREV_SUBTHREAD);
2140
2141 if (count > 0)
2142 {
2143 for (int i = 0; i < count; i++)
2144 {
2145 int index = mutt_aside_thread(shared->email, forwards, subthreads);
2146 if (index == -1)
2147 break;
2148 menu_set_index(priv->menu, index);
2149 }
2150 return FR_SUCCESS;
2151 }
2152
2153 int index = mutt_aside_thread(shared->email, forwards, subthreads);
2154
2155 if (index != -1)
2156 menu_set_index(priv->menu, index);
2157
2158 if (index < 0)
2159 {
2160 if (forwards)
2161 mutt_error(_("No more threads"));
2162 else
2163 mutt_error(_("You are on the first thread"));
2164
2166 return FR_ERROR;
2167 }
2168
2169 return FR_SUCCESS;
2170}
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()

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 2175 of file functions.c.

2176{
2177 struct IndexSharedData *shared = fdata->shared;
2178 struct IndexPrivateData *priv = fdata->priv;
2179 const int count = event->count;
2180 int index = menu_get_index(priv->menu);
2181
2182 if (count > 0)
2183 {
2184 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2185 int last_good = index;
2186 for (int i = 0; i < count; i++)
2187 {
2188 int next = find_next_undeleted(shared->mailbox_view, index, uncollapse);
2189 if (next == -1)
2190 break;
2191 last_good = next;
2192 index = next;
2193 }
2194 if (last_good != menu_get_index(priv->menu))
2195 {
2196 menu_set_index(priv->menu, last_good);
2197 if (uncollapse)
2199 }
2200 return FR_SUCCESS;
2201 }
2202
2203 if (index >= (shared->mailbox->vcount - 1))
2204 {
2206 mutt_message(_("You are on the last message"));
2207 return FR_ERROR;
2208 }
2209
2210 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2211
2212 index = find_next_undeleted(shared->mailbox_view, index, uncollapse);
2213 if (index != -1)
2214 {
2215 menu_set_index(priv->menu, index);
2216 if (uncollapse)
2218 }
2219
2220 if (index == -1)
2221 {
2223 mutt_error(_("No undeleted messages"));
2224 return FR_ERROR;
2225 }
2226
2227 return FR_SUCCESS;
2228}
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()

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 2233 of file functions.c.

2235{
2236 struct IndexSharedData *shared = fdata->shared;
2237 struct IndexPrivateData *priv = fdata->priv;
2238 struct Mailbox *m = shared->mailbox;
2239
2240 struct Buffer *folderbuf = buf_pool_get();
2241 buf_strcpy(folderbuf, mailbox_path(m));
2242 m = mutt_mailbox_next_unread(m, folderbuf);
2243 buf_pool_release(&folderbuf);
2244
2245 if (!m)
2246 {
2247 mutt_error(_("No mailboxes have new mail"));
2248 return FR_ERROR;
2249 }
2250
2251 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
2252 return FR_SUCCESS;
2253}
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()

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 2258 of file functions.c.

2260{
2261 struct IndexSharedData *shared = fdata->shared;
2262 struct IndexPrivateData *priv = fdata->priv;
2263 struct Mailbox *m = shared->mailbox;
2264
2265 struct Buffer *folderbuf = buf_pool_get();
2266 buf_strcpy(folderbuf, mailbox_path(m));
2267 m = mutt_mailbox_prev_unread(m, folderbuf);
2268 buf_pool_release(&folderbuf);
2269
2270 if (!m)
2271 {
2272 mutt_error(_("No mailboxes have new mail"));
2273 return FR_ERROR;
2274 }
2275
2276 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, false);
2277 return FR_SUCCESS;
2278}
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()

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 2283 of file functions.c.

2284{
2285 struct IndexSharedData *shared = fdata->shared;
2286 struct IndexPrivateData *priv = fdata->priv;
2287 const int count = event->count;
2288 int index = menu_get_index(priv->menu);
2289
2290 if (count > 0)
2291 {
2292 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2293 int last_good = index;
2294 for (int i = 0; i < count; i++)
2295 {
2296 int prev = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
2297 if (prev == -1)
2298 break;
2299 last_good = prev;
2300 index = prev;
2301 }
2302 if (last_good != menu_get_index(priv->menu))
2303 {
2304 menu_set_index(priv->menu, last_good);
2305 if (uncollapse)
2307 }
2308 return FR_SUCCESS;
2309 }
2310
2311 if (index < 1)
2312 {
2314 mutt_message(_("You are on the first message"));
2315 return FR_ERROR;
2316 }
2317
2318 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
2319
2320 index = find_previous_undeleted(shared->mailbox_view, index, uncollapse);
2321 if (index != -1)
2322 {
2323 menu_set_index(priv->menu, index);
2324 if (uncollapse)
2326 }
2327
2328 if (index == -1)
2329 {
2330 mutt_error(_("No undeleted messages"));
2332 return FR_ERROR;
2333 }
2334
2335 return FR_SUCCESS;
2336}
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()

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 2341 of file functions.c.

2342{
2343 struct IndexSharedData *shared = fdata->shared;
2344 struct IndexPrivateData *priv = fdata->priv;
2345 struct Mailbox *m = shared->mailbox;
2346 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2347 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2348 event->count);
2349 if (ARRAY_EMPTY(&ea))
2350 {
2351 ARRAY_FREE(&ea);
2352 return FR_NO_ACTION;
2353 }
2354 const int num = ARRAY_SIZE(&ea);
2355
2356 struct Email **ep = NULL;
2357 ARRAY_FOREACH(ep, &ea)
2358 {
2359 (*ep)->quasi_deleted = true;
2360 m->changed = true;
2361 }
2362 ARRAY_FREE(&ea);
2363
2364 if (priv->tag_prefix || (num > 1))
2366
2367 return FR_SUCCESS;
2368}
Here is the call graph for this function:

◆ op_main_read_thread()

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 2377 of file functions.c.

2378{
2379 struct IndexSharedData *shared = fdata->shared;
2380 struct IndexPrivateData *priv = fdata->priv;
2381 /* L10N: CHECK_ACL */
2382 /* L10N: Due to the implementation details we do not know whether we
2383 mark zero, 1, 12, ... messages as read. So in English we use
2384 "messages". Your language might have other means to express this. */
2385 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't mark messages as read")))
2386 return FR_ERROR;
2387
2388 const int op = event->op;
2389 const bool subthread = (op != OP_MAIN_READ_THREAD);
2390 int rc = 0;
2391 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2392 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
2393 priv->tag_prefix, subthread, event->count);
2394 const int num = ARRAY_SIZE(&ea);
2395
2396 struct Email **ep = NULL;
2397 ARRAY_FOREACH(ep, &ea)
2398 {
2399 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_READ, true, subthread);
2400 if (rc == -1)
2401 break;
2402 }
2403 ARRAY_FREE(&ea);
2404
2405 if (rc == -1)
2406 return FR_ERROR;
2407
2408 if (priv->tag_prefix)
2409 {
2411 return FR_SUCCESS;
2412 }
2413
2414 const enum ResolveMethod rm = (op == OP_MAIN_READ_THREAD) ? RESOLVE_NEXT_THREAD :
2416 resolve_email(priv, shared, rm, num);
2418 return FR_SUCCESS;
2419}
@ MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition mailbox.h:70
ResolveMethod
How to advance the cursor.
Definition functions.c:322
@ RESOLVE_NEXT_SUBTHREAD
Next sibling sub-thread.
Definition functions.c:326
@ RESOLVE_NEXT_THREAD
Next top-level thread.
Definition functions.c:325
@ MUTT_READ
Messages that have been read.
Definition mutt.h:92
Here is the call graph for this function:

◆ op_main_root_message()

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 2431 of file functions.c.

2432{
2433 struct IndexSharedData *shared = fdata->shared;
2434 struct IndexPrivateData *priv = fdata->priv;
2435 int count = event->op == OP_MAIN_ROOT_MESSAGE ? 0 : MAX(event->count, 1);
2436 int index = mutt_parent_message(shared->email, event->op == OP_MAIN_ROOT_MESSAGE, count);
2437 if (index != -1)
2438 menu_set_index(priv->menu, index);
2439
2440 return FR_SUCCESS;
2441}
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()

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 2450 of file functions.c.

2451{
2452 struct IndexSharedData *shared = fdata->shared;
2453 struct IndexPrivateData *priv = fdata->priv;
2454 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2455 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2456 event->count);
2457 if (ARRAY_EMPTY(&ea))
2458 {
2459 ARRAY_FREE(&ea);
2460 return FR_NO_ACTION;
2461 }
2462 const int num = ARRAY_SIZE(&ea);
2463
2464 if (mw_change_flag(shared->mailbox, &ea, (event->op == OP_MAIN_SET_FLAG)) == 0)
2465 {
2466 if (priv->tag_prefix)
2467 {
2469 }
2470 else
2471 {
2472 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
2473 if (num > 1)
2475 }
2476 }
2477 ARRAY_FREE(&ea);
2478
2479 return FR_SUCCESS;
2480}
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()

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 2485 of file functions.c.

2486{
2487 struct IndexSharedData *shared = fdata->shared;
2488 if (mview_has_limit(shared->mailbox_view))
2489 {
2490 struct Buffer *buf = buf_pool_get();
2491 /* L10N: ask for a limit to apply */
2492 buf_printf(buf, _("Limit: %s"), shared->mailbox_view->pattern);
2493 mutt_message("%s", buf_string(buf));
2494 buf_pool_release(&buf);
2495 }
2496 else
2497 {
2498 mutt_message(_("No limit pattern is in effect"));
2499 }
2500
2501 return FR_SUCCESS;
2502}
Here is the call graph for this function:

◆ op_main_sync_folder()

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

Save changes to mailbox - Implements index_function_t -.

Definition at line 2507 of file functions.c.

2508{
2509 struct IndexSharedData *shared = fdata->shared;
2510 struct IndexPrivateData *priv = fdata->priv;
2512 return FR_NO_ACTION;
2513
2514 int ovc = shared->mailbox->vcount;
2515 int oc = shared->mailbox->msg_count;
2516 struct Email *e = NULL;
2517
2518 /* don't attempt to move the cursor if there are no visible messages in the current limit */
2519 int index = menu_get_index(priv->menu);
2520 if (index < shared->mailbox->vcount)
2521 {
2522 /* threads may be reordered, so figure out what header the cursor
2523 * should be on. */
2524 int newidx = index;
2525 if (!shared->email)
2526 return FR_NO_ACTION;
2527 if (shared->email->deleted)
2528 newidx = find_next_undeleted(shared->mailbox_view, index, false);
2529 if (newidx < 0)
2530 newidx = find_previous_undeleted(shared->mailbox_view, index, false);
2531 if (newidx >= 0)
2532 e = mutt_get_virt_email(shared->mailbox, newidx);
2533 }
2534
2535 enum MxStatus check = mx_mbox_sync(shared->mailbox);
2536 if (check == MX_STATUS_OK)
2537 {
2538 if (e && (shared->mailbox->vcount != ovc))
2539 {
2540 for (size_t i = 0; i < shared->mailbox->vcount; i++)
2541 {
2542 struct Email *e2 = mutt_get_virt_email(shared->mailbox, i);
2543 if (e2 == e)
2544 {
2545 menu_set_index(priv->menu, i);
2546 break;
2547 }
2548 }
2549 }
2551 }
2552 else if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2553 {
2554 update_index(priv->menu, shared->mailbox_view, check, oc, shared);
2555 }
2556
2557 /* do a sanity check even if mx_mbox_sync failed. */
2558
2559 index = menu_get_index(priv->menu);
2560 if ((index < 0) || (shared->mailbox && (index >= shared->mailbox->vcount)))
2561 {
2563 }
2564
2565 /* check for a fatal error, or all messages deleted */
2566 if (shared->mailbox && buf_is_empty(&shared->mailbox->pathbuf))
2567 {
2568 mview_free(&shared->mailbox_view);
2569 }
2570
2571 if (shared->mailbox)
2572 {
2573 priv->menu->max = shared->mailbox->vcount;
2575
2576 struct EventMailbox ev_m = { shared->mailbox };
2578 }
2579 else
2580 {
2581 priv->menu->max = 0;
2583 }
2584
2585 return FR_SUCCESS;
2586}
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()

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 2591 of file functions.c.

2592{
2593 struct IndexSharedData *shared = fdata->shared;
2594 struct IndexPrivateData *priv = fdata->priv;
2595 mutt_pattern_func(shared->mailbox_view, MUTT_TAG, _("Tag messages matching: "));
2597
2598 return FR_SUCCESS;
2599}
Here is the call graph for this function:

◆ op_main_undelete_pattern()

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 2604 of file functions.c.

2606{
2607 struct IndexSharedData *shared = fdata->shared;
2608 struct IndexPrivateData *priv = fdata->priv;
2609 /* L10N: CHECK_ACL */
2610 /* L10N: Due to the implementation details we do not know whether we
2611 undelete zero, 1, 12, ... messages. So in English we use
2612 "messages". Your language might have other means to express this. */
2613 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
2614 return FR_ERROR;
2615
2617 _("Undelete messages matching: ")) == 0)
2618 {
2620 }
2621
2622 return FR_SUCCESS;
2623}
@ MUTT_UNDELETE
Messages to be un-deleted.
Definition mutt.h:95
Here is the call graph for this function:

◆ op_main_untag_pattern()

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 2628 of file functions.c.

2629{
2630 struct IndexSharedData *shared = fdata->shared;
2631 struct IndexPrivateData *priv = fdata->priv;
2632 if (mutt_pattern_func(shared->mailbox_view, MUTT_UNTAG, _("Untag messages matching: ")) == 0)
2634
2635 return FR_SUCCESS;
2636}
@ MUTT_UNTAG
Messages to be un-tagged.
Definition mutt.h:100
Here is the call graph for this function:

◆ op_mark_msg()

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 2641 of file functions.c.

2642{
2643 struct IndexSharedData *shared = fdata->shared;
2644 if (!shared->email)
2645 return FR_NO_ACTION;
2646
2647 int rc = FR_SUCCESS;
2648
2649 if (shared->email->env->message_id)
2650 {
2651 struct Buffer *buf = buf_pool_get();
2652
2653 /* L10N: This is the prompt for <mark-message>. Whatever they
2654 enter will be prefixed by $mark_macro_prefix and will become
2655 a macro hotkey to jump to the currently selected message. */
2656 if ((mw_get_field(_("Enter macro stroke: "), buf, MUTT_COMP_NONE, HC_OTHER,
2657 NULL, NULL) == 0) &&
2658 !buf_is_empty(buf))
2659 {
2660 const char *const c_mark_macro_prefix = cs_subset_string(shared->sub, "mark_macro_prefix");
2661 char str[256] = { 0 };
2662 snprintf(str, sizeof(str), "%s%s", c_mark_macro_prefix, buf_string(buf));
2663
2664 struct Buffer *msg_id = buf_pool_get();
2665 mutt_file_sanitize_regex(msg_id, shared->email->env->message_id);
2666 char macro[256] = { 0 };
2667 snprintf(macro, sizeof(macro), "<search>~i '%s'\n", buf_string(msg_id));
2668 buf_pool_release(&msg_id);
2669
2670 /* L10N: "message hotkey" is the key bindings menu description of a
2671 macro created by <mark-message>. */
2672 km_bind(fdata->mod_data->md_index, str, OP_MACRO, macro, _("message hotkey"), NULL);
2673
2674 /* L10N: This is echoed after <mark-message> creates a new hotkey
2675 macro. %s is the hotkey string ($mark_macro_prefix followed
2676 by whatever they typed at the prompt.) */
2677 buf_printf(buf, _("Message bound to %s"), str);
2678 mutt_message("%s", buf_string(buf));
2679 mutt_debug(LL_DEBUG1, "Mark: %s => %s\n", str, macro);
2680 }
2681 buf_pool_release(&buf);
2682 }
2683 else
2684 {
2685 /* L10N: This error is printed if <mark-message> can't find a
2686 Message-ID for the currently selected message in the index. */
2687 mutt_error(_("No message ID to macro"));
2688 rc = FR_ERROR;
2689 }
2690
2691 return rc;
2692}
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()

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

Move to the next entry - Implements index_function_t -.

Definition at line 2697 of file functions.c.

2698{
2699 struct IndexSharedData *shared = fdata->shared;
2700 struct IndexPrivateData *priv = fdata->priv;
2701 int count = MAX(event->count, 1);
2702 int index = menu_get_index(priv->menu) + count;
2703
2704 if (index >= shared->mailbox->vcount)
2705 {
2706 index = shared->mailbox->vcount - 1;
2707 if (event->count == 0)
2708 {
2709 mutt_message(_("You are on the last message"));
2711 }
2712 }
2713
2714 menu_set_index(priv->menu, index);
2715 return FR_SUCCESS;
2716}
Here is the call graph for this function:

◆ op_pipe()

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 2721 of file functions.c.

2722{
2723 struct IndexSharedData *shared = fdata->shared;
2724 struct IndexPrivateData *priv = fdata->priv;
2725 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2726 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2727 mutt_pipe_message(shared->mailbox, &ea);
2728 ARRAY_FREE(&ea);
2729
2730 /* in an IMAP folder index with imap_peek=no, piping could change
2731 * new or old messages status to read. Redraw what's needed. */
2732 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2733 if ((shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2734 {
2736 }
2737
2738 return FR_SUCCESS;
2739}
@ 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()

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

Move to the previous entry - Implements index_function_t -.

Definition at line 2744 of file functions.c.

2745{
2746 struct IndexSharedData *shared = fdata->shared;
2747 struct IndexPrivateData *priv = fdata->priv;
2748 int count = MAX(event->count, 1);
2749 int index = menu_get_index(priv->menu) - count;
2750
2751 if (index < 0)
2752 {
2753 index = 0;
2754 if (event->count == 0)
2755 {
2757 mutt_message(_("You are on the first message"));
2758 }
2759 }
2760
2761 menu_set_index(priv->menu, index);
2762 return FR_SUCCESS;
2763}
Here is the call graph for this function:

◆ op_print()

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

Print the current entry - Implements index_function_t -.

Definition at line 2768 of file functions.c.

2769{
2770 struct IndexSharedData *shared = fdata->shared;
2771 struct IndexPrivateData *priv = fdata->priv;
2772 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2773 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2774 event->count);
2775 if (ARRAY_EMPTY(&ea))
2776 {
2777 ARRAY_FREE(&ea);
2778 return FR_NO_ACTION;
2779 }
2780 const int num = ARRAY_SIZE(&ea);
2781 const bool printed = mutt_print_message(shared->mailbox, &ea);
2782 ARRAY_FREE(&ea);
2783
2784 if (printed && !priv->tag_prefix)
2785 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, num);
2786
2787 /* in an IMAP folder index with imap_peek=no, printing could change
2788 * new or old messages status to read. Redraw what's needed. */
2789 const bool c_imap_peek = cs_subset_bool(shared->sub, "imap_peek");
2790 if (printed && (shared->mailbox->type == MUTT_IMAP) && !c_imap_peek)
2791 {
2792 menu_queue_redraw(priv->menu,
2793 ((priv->tag_prefix || (num > 1)) ? MENU_REDRAW_INDEX : MENU_REDRAW_CURRENT));
2794 }
2795
2796 return FR_SUCCESS;
2797}
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:323
Here is the call graph for this function:

◆ op_query()

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

Query external program for addresses - Implements index_function_t -.

Definition at line 2802 of file functions.c.

2803{
2804 struct IndexSharedData *shared = fdata->shared;
2805 query_index(shared->mailbox, shared->sub);
2806 return FR_SUCCESS;
2807}
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()

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

Save changes to mailbox and quit - Implements index_function_t -.

Definition at line 2812 of file functions.c.

2813{
2814 struct IndexSharedData *shared = fdata->shared;
2815 struct IndexPrivateData *priv = fdata->priv;
2816 if (shared->attach_msg)
2817 return FR_DONE;
2818
2819 if (query_quadoption(_("Quit NeoMutt?"), shared->sub, "quit") == MUTT_YES)
2820 {
2821 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
2822
2824 mutt_debug(LL_NOTIFY, "NT_GLOBAL_SHUTDOWN\n");
2826
2827 enum MxStatus check = MX_STATUS_OK;
2828 if (!shared->mailbox_view || ((check = mx_mbox_close(shared->mailbox)) == MX_STATUS_OK))
2829 {
2832 return FR_DONE;
2833 }
2834
2835 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2836 {
2837 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2838 }
2839
2840 menu_queue_redraw(priv->menu, MENU_REDRAW_FULL); /* new mail arrived? */
2842 }
2843
2844 return FR_NO_ACTION;
2845}
@ 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()

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

Recall a postponed message - Implements index_function_t -.

Definition at line 2850 of file functions.c.

2851{
2852 struct IndexSharedData *shared = fdata->shared;
2853 struct IndexPrivateData *priv = fdata->priv;
2854 int rc = mutt_send_message(SEND_POSTPONED, NULL, NULL, shared->mailbox, NULL,
2855 shared->sub);
2857 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2858}
@ SEND_POSTPONED
Recall a postponed email.
Definition send.h:50
Here is the call graph for this function:

◆ op_reply()

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

Reply to a message - Implements index_function_t -.

Definition at line 2863 of file functions.c.

2864{
2865 struct IndexSharedData *shared = fdata->shared;
2866 struct IndexPrivateData *priv = fdata->priv;
2867 if (!shared->email)
2868 return FR_NO_ACTION;
2869 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2870 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2871 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
2872 if (c_pgp_auto_decode &&
2873 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
2874 {
2875 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
2877 }
2878 int rc = mutt_send_message(SEND_REPLY, NULL, NULL, shared->mailbox, &ea,
2879 shared->sub);
2880 ARRAY_FREE(&ea);
2882
2883 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2884}
Here is the call graph for this function:

◆ op_resend()

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 2889 of file functions.c.

2890{
2891 struct IndexSharedData *shared = fdata->shared;
2892 struct IndexPrivateData *priv = fdata->priv;
2893 int rc = -1;
2894 if (priv->tag_prefix)
2895 {
2896 struct Mailbox *m = shared->mailbox;
2897 for (size_t i = 0; i < m->msg_count; i++)
2898 {
2899 struct Email *e = m->emails[i];
2900 if (!e)
2901 break;
2902 if (message_is_tagged(e))
2903 rc = mutt_resend_message(NULL, shared->mailbox, e, shared->sub);
2904 }
2905 }
2906 else
2907 {
2908 rc = mutt_resend_message(NULL, shared->mailbox, shared->email, shared->sub);
2909 }
2910
2912 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2913}
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()

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 2926 of file functions.c.

2927{
2928 struct IndexSharedData *shared = fdata->shared;
2929 struct IndexPrivateData *priv = fdata->priv;
2930 const int op = event->op;
2931 if (((op == OP_DECRYPT_COPY) || (op == OP_DECRYPT_SAVE)) && !WithCrypto)
2932 return FR_NOT_IMPL;
2933
2934 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2935 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
2936 event->count);
2937 if (ARRAY_EMPTY(&ea))
2938 {
2939 ARRAY_FREE(&ea);
2940 return FR_NO_ACTION;
2941 }
2942 const int num = ARRAY_SIZE(&ea);
2943
2944 const enum MessageSaveOpt save_opt = ((op == OP_SAVE) || (op == OP_DECODE_SAVE) ||
2945 (op == OP_DECRYPT_SAVE)) ?
2946 SAVE_MOVE :
2947 SAVE_COPY;
2948
2949 enum MessageTransformOpt transform_opt =
2950 ((op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY)) ? TRANSFORM_DECODE :
2951 ((op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY)) ? TRANSFORM_DECRYPT :
2953
2954 const int rc = mutt_save_message(shared->mailbox, &ea, save_opt, transform_opt);
2955 if ((rc == 0) && (save_opt == SAVE_MOVE) && !priv->tag_prefix)
2956 {
2957 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, 1);
2958 }
2959 ARRAY_FREE(&ea);
2960
2961 if (priv->tag_prefix || (num > 1))
2963
2964 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2965}
int mutt_save_message(struct Mailbox *m, struct EmailArray *ea, enum MessageSaveOpt save_opt, enum MessageTransformOpt transform_opt)
Save an email.
Definition external.c:784
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()

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 2976 of file functions.c.

2977{
2978 struct IndexSharedData *shared = fdata->shared;
2979 struct IndexPrivateData *priv = fdata->priv;
2980 SearchFlags flags = SEARCH_NONE;
2981 switch (event->op)
2982 {
2983 case OP_SEARCH:
2984 flags |= SEARCH_PROMPT;
2985 shared->search_state->reverse = false;
2986 break;
2987 case OP_SEARCH_REVERSE:
2988 flags |= SEARCH_PROMPT;
2989 shared->search_state->reverse = true;
2990 break;
2991 case OP_SEARCH_NEXT:
2992 break;
2993 case OP_SEARCH_OPPOSITE:
2994 flags |= SEARCH_OPPOSITE;
2995 break;
2996
2997 default:
2998 break;
2999 }
3000
3001 // Initiating a search can happen on an empty mailbox, but
3002 // searching for next/previous/... needs to be on a message and
3003 // thus a non-empty mailbox
3004 int index = menu_get_index(priv->menu);
3005 index = mutt_search_command(shared->mailbox_view, priv->menu, index,
3006 shared->search_state, flags);
3007 if (index != -1)
3008 menu_set_index(priv->menu, index);
3009
3010 return FR_SUCCESS;
3011}
int mutt_search_command(struct MailboxView *mv, struct Menu *menu, int cur, struct SearchState *state, SearchFlags flags)
Perform a search.
Definition pattern.c:465
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()

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 3020 of file functions.c.

3021{
3022 struct IndexSharedData *shared = fdata->shared;
3023 struct IndexPrivateData *priv = fdata->priv;
3024 if (!mutt_select_sort(event->op == OP_SORT_REVERSE))
3025 return FR_ERROR;
3026
3027 if (shared->mailbox && (shared->mailbox->msg_count != 0))
3028 {
3031 }
3032
3033 return FR_SUCCESS;
3034}
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()

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

Tag the current entry - Implements index_function_t -.

Definition at line 3039 of file functions.c.

3040{
3041 struct IndexSharedData *shared = fdata->shared;
3042 struct IndexPrivateData *priv = fdata->priv;
3043 const bool c_auto_tag = cs_subset_bool(shared->sub, "auto_tag");
3044 if (priv->tag_prefix && !c_auto_tag)
3045 {
3046 struct Mailbox *m = shared->mailbox;
3047 for (size_t i = 0; i < m->msg_count; i++)
3048 {
3049 struct Email *e = m->emails[i];
3050 if (!e)
3051 continue;
3052 if (e->visible)
3053 mutt_set_flag(m, e, MUTT_TAG, false, true);
3054 }
3056 return FR_SUCCESS;
3057 }
3058
3059 if (!shared->email)
3060 return FR_NO_ACTION;
3061
3062 int count = MAX(event->count, 1);
3063 int current_index = menu_get_index(priv->menu);
3064
3065 for (int i = 0; i < count && current_index + i < shared->mailbox->vcount; i++)
3066 {
3067 struct Email *e = mutt_get_virt_email(shared->mailbox, current_index + i);
3068 if (e)
3069 mutt_set_flag(shared->mailbox, e, MUTT_TAG, !e->tagged, true);
3070 }
3071
3072 if (count > 0)
3073 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, count);
3074
3075 return FR_SUCCESS;
3076}
bool tagged
Email is tagged.
Definition email.h:107
Here is the call graph for this function:

◆ op_tag_thread()

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 3085 of file functions.c.

3086{
3087 struct IndexSharedData *shared = fdata->shared;
3088 struct IndexPrivateData *priv = fdata->priv;
3089 if (!shared->email)
3090 return FR_NO_ACTION;
3091
3092 const int op = event->op;
3094 !shared->email->tagged, (op != OP_TAG_THREAD));
3095 if (rc != -1)
3096 {
3097 const enum ResolveMethod rm = (op == OP_TAG_THREAD) ? RESOLVE_NEXT_THREAD :
3099 resolve_email(priv, shared, rm, 1);
3101 }
3102
3103 return FR_SUCCESS;
3104}
Here is the call graph for this function:

◆ op_toggle_new()

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 3109 of file functions.c.

3110{
3111 struct IndexSharedData *shared = fdata->shared;
3112 struct IndexPrivateData *priv = fdata->priv;
3113 /* L10N: CHECK_ACL */
3114 if (!check_acl(shared->mailbox, MUTT_ACL_SEEN, _("Can't toggle new")))
3115 return FR_ERROR;
3116
3117 struct Mailbox *m = shared->mailbox;
3118 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3119 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
3120 event->count);
3121 if (ARRAY_EMPTY(&ea))
3122 {
3123 ARRAY_FREE(&ea);
3124 return FR_NO_ACTION;
3125 }
3126 const int num = ARRAY_SIZE(&ea);
3127
3128 struct Email **ep = NULL;
3129 ARRAY_FOREACH(ep, &ea)
3130 {
3131 if ((*ep)->read || (*ep)->old)
3132 mutt_set_flag(m, *ep, MUTT_NEW, true, true);
3133 else
3134 mutt_set_flag(m, *ep, MUTT_READ, true, true);
3135 }
3136 ARRAY_FREE(&ea);
3137
3138 if (priv->tag_prefix)
3139 {
3141 }
3142 else
3143 {
3144 resolve_email(priv, shared, RESOLVE_NEXT_UNDELETED, num);
3145 if (num > 1)
3147 }
3148
3149 return FR_SUCCESS;
3150}
@ MUTT_NEW
New messages.
Definition mutt.h:89
Here is the call graph for this function:

◆ op_toggle_write()

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 3155 of file functions.c.

3156{
3157 struct IndexSharedData *shared = fdata->shared;
3158 mx_toggle_write(shared->mailbox);
3159 return FR_SUCCESS;
3160}
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()

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

Undelete the current entry - Implements index_function_t -.

Definition at line 3165 of file functions.c.

3166{
3167 struct IndexSharedData *shared = fdata->shared;
3168 struct IndexPrivateData *priv = fdata->priv;
3169 /* L10N: CHECK_ACL */
3170 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete message")))
3171 return FR_ERROR;
3172
3173 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3174 ea_add_selection(&ea, shared->mailbox_view, shared->email, priv->tag_prefix,
3175 event->count);
3176 if (ARRAY_EMPTY(&ea))
3177 {
3178 ARRAY_FREE(&ea);
3179 return FR_NO_ACTION;
3180 }
3181 const int num = ARRAY_SIZE(&ea);
3182
3183 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, false);
3184 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, false);
3185 ARRAY_FREE(&ea);
3186
3187 if (priv->tag_prefix)
3188 {
3190 }
3191 else
3192 {
3193 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL, num);
3194 if (num > 1)
3196 }
3197
3198 return FR_SUCCESS;
3199}
Here is the call graph for this function:

◆ op_undelete_thread()

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 3208 of file functions.c.

3209{
3210 struct IndexSharedData *shared = fdata->shared;
3211 struct IndexPrivateData *priv = fdata->priv;
3212 /* L10N: CHECK_ACL */
3213 /* L10N: Due to the implementation details we do not know whether we
3214 undelete zero, 1, 12, ... messages. So in English we use
3215 "messages". Your language might have other means to express this. */
3216 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete messages")))
3217 return FR_ERROR;
3218
3219 const int op = event->op;
3220 const bool subthread = (op != OP_UNDELETE_THREAD);
3221 int rc = 0;
3222 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3223 ea_add_selection_threads(&ea, shared->mailbox_view, shared->email,
3224 priv->tag_prefix, subthread, event->count);
3225 const int num = ARRAY_SIZE(&ea);
3226
3227 struct Email **ep = NULL;
3228 ARRAY_FOREACH(ep, &ea)
3229 {
3230 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_DELETE, false, subthread);
3231 if (rc == -1)
3232 break;
3233 rc = mutt_thread_set_flag(shared->mailbox, *ep, MUTT_PURGE, false, subthread);
3234 if (rc == -1)
3235 break;
3236 }
3237 ARRAY_FREE(&ea);
3238
3239 if (rc == -1)
3240 return FR_ERROR;
3241
3242 if (priv->tag_prefix)
3243 {
3245 return FR_SUCCESS;
3246 }
3247
3248 const enum ResolveMethod rm = (op == OP_UNDELETE_THREAD) ? RESOLVE_NEXT_THREAD :
3250 resolve_email(priv, shared, rm, num);
3252 return FR_SUCCESS;
3253}
Here is the call graph for this function:

◆ op_view_attachments()

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

Show MIME attachments - Implements index_function_t -.

Definition at line 3258 of file functions.c.

3259{
3260 struct IndexSharedData *shared = fdata->shared;
3261 struct IndexPrivateData *priv = fdata->priv;
3262 if (!shared->email)
3263 return FR_NO_ACTION;
3264
3265 enum FunctionRetval rc = FR_ERROR;
3266 struct Message *msg = mx_msg_open(shared->mailbox, shared->email);
3267 if (msg)
3268 {
3269 dlg_attach(fdata->n->sub, shared->mailbox_view, shared->email, msg->fp,
3270 shared->attach_msg);
3271 if (shared->email->attach_del)
3272 {
3273 shared->mailbox->changed = true;
3274 }
3275 mx_msg_close(shared->mailbox, &msg);
3276 rc = FR_SUCCESS;
3277 }
3279 return rc;
3280}
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()

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

Manage autocrypt accounts - Implements index_function_t -.

Definition at line 3288 of file functions.c.

3289{
3290 dlg_autocrypt();
3291 return FR_SUCCESS;
3292}
void dlg_autocrypt(void)
Display the Autocrypt account Menu -.
Here is the call graph for this function:

◆ op_main_imap_fetch()

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 3298 of file functions.c.

3299{
3300 struct IndexSharedData *shared = fdata->shared;
3301 if (!shared->mailbox || (shared->mailbox->type != MUTT_IMAP))
3302 return FR_NO_ACTION;
3303
3304 imap_check_mailbox(shared->mailbox, true);
3305 return FR_SUCCESS;
3306}
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()

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 3311 of file functions.c.

3312{
3313 struct IndexSharedData *shared = fdata->shared;
3314 struct IndexPrivateData *priv = fdata->priv;
3315 if (shared->mailbox && (shared->mailbox->type == MUTT_IMAP))
3316 {
3317 const enum MxStatus check = mx_mbox_close(shared->mailbox);
3318 if (check == MX_STATUS_OK)
3319 {
3321 }
3322 else
3323 {
3324 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
3325 {
3326 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
3327 }
3330 return FR_ERROR;
3331 }
3332 }
3334 mutt_message(_("Logged out of IMAP servers"));
3337
3338 return FR_SUCCESS;
3339}
void imap_logout_all(void)
Close all open connections.
Definition imap.c:667
Here is the call graph for this function:

◆ op_catchup()

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 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 || (m->type != MUTT_NNTP))
3350 return FR_NO_ACTION;
3351
3352 struct NntpMboxData *mdata = m->mdata;
3353 if (mutt_newsgroup_catchup(m, mdata->adata, mdata->group))
3355
3356 return FR_SUCCESS;
3357}
@ 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()

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 3366 of file functions.c.

3367{
3368 struct IndexSharedData *shared = fdata->shared;
3369 struct IndexPrivateData *priv = fdata->priv;
3370 struct Mailbox *m = shared->mailbox;
3371 if (m->type != MUTT_NNTP)
3372 return FR_ERROR;
3373
3374 struct Email *e = shared->email;
3375 if (!e)
3376 return FR_NO_ACTION;
3377
3378 char buf[PATH_MAX] = { 0 };
3379 int oldmsgcount = m->msg_count;
3380 int oldindex = e->index;
3381 int rc = 0;
3382
3383 if (!e->env->message_id)
3384 {
3385 mutt_error(_("No Message-ID. Unable to perform operation."));
3386 return FR_ERROR;
3387 }
3388
3389 mutt_message(_("Fetching message headers..."));
3390 if (!m->id_hash)
3391 m->id_hash = mutt_make_id_hash(m);
3392 mutt_str_copy(buf, e->env->message_id, sizeof(buf));
3393
3394 const int op = event->op;
3395 /* trying to find msgid of the root message */
3396 if (op == OP_RECONSTRUCT_THREAD)
3397 {
3398 struct ListNode *ref = NULL;
3399 STAILQ_FOREACH(ref, &e->env->references, entries)
3400 {
3401 if (!mutt_hash_find(m->id_hash, ref->data))
3402 {
3403 rc = nntp_check_msgid(m, ref->data);
3404 if (rc < 0)
3405 return FR_ERROR;
3406 }
3407
3408 /* the last msgid in References is the root message */
3409 if (!STAILQ_NEXT(ref, entries))
3410 mutt_str_copy(buf, ref->data, sizeof(buf));
3411 }
3412 }
3413
3414 /* fetching all child messages */
3415 rc = nntp_check_children(m, buf);
3416
3417 /* at least one message has been loaded */
3418 if (m->msg_count > oldmsgcount)
3419 {
3420 bool verbose = m->verbose;
3421
3422 if (rc < 0)
3423 m->verbose = false;
3424
3425 struct MailboxView *mv = shared->mailbox_view;
3426 mutt_sort_headers(mv, (op == OP_RECONSTRUCT_THREAD));
3427 m->verbose = verbose;
3428
3429 /* if the root message was retrieved, move to it */
3430 struct Email *e2 = mutt_hash_find(m->id_hash, buf);
3431 if (e2)
3432 {
3433 menu_set_index(priv->menu, e2->vnum);
3434 }
3435 else
3436 {
3437 /* try to restore old position */
3438 for (int i = 0; i < m->msg_count; i++)
3439 {
3440 e2 = m->emails[i];
3441 if (!e2)
3442 break;
3443 if (e2->index == oldindex)
3444 {
3445 menu_set_index(priv->menu, e2->vnum);
3446 /* as an added courtesy, recenter the menu
3447 * with the current entry at the middle of the screen */
3449 }
3450 }
3451 }
3453 }
3454 else if (rc >= 0)
3455 {
3456 mutt_error(_("No deleted messages found in the thread"));
3457 return FR_ERROR;
3458 }
3459
3460 return FR_SUCCESS;
3461}
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:2227
int nntp_check_children(struct Mailbox *m, const char *msgid)
Fetch children of article with the Message-ID.
Definition nntp.c:2298
#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()

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 3470 of file functions.c.

3471{
3472 struct IndexSharedData *shared = fdata->shared;
3473 struct IndexPrivateData *priv = fdata->priv;
3474 struct Mailbox *m = shared->mailbox;
3475 if (m->type != MUTT_NNTP)
3476 return FR_SUCCESS;
3477
3478 int rc = FR_ERROR;
3479 struct Buffer *buf = buf_pool_get();
3480
3481 const int op = event->op;
3482 if (op == OP_GET_MESSAGE)
3483 {
3484 if ((mw_get_field(_("Enter Message-ID: "), buf, MUTT_COMP_NONE, HC_OTHER, NULL, NULL) != 0) ||
3485 buf_is_empty(buf))
3486 {
3487 goto done;
3488 }
3489 }
3490 else
3491 {
3492 struct Email *e = shared->email;
3493 if (!e || STAILQ_EMPTY(&e->env->references))
3494 {
3495 mutt_error(_("Article has no parent reference"));
3496 goto done;
3497 }
3498 buf_strcpy(buf, STAILQ_FIRST(&e->env->references)->data);
3499 }
3500
3501 if (!m->id_hash)
3502 m->id_hash = mutt_make_id_hash(m);
3503 struct Email *e = mutt_hash_find(m->id_hash, buf_string(buf));
3504 if (e)
3505 {
3506 if (e->vnum != -1)
3507 {
3508 menu_set_index(priv->menu, e->vnum);
3509 }
3510 else if (e->collapsed)
3511 {
3513 mutt_set_vnum(m);
3514 menu_set_index(priv->menu, e->vnum);
3515 }
3516 else
3517 {
3518 mutt_error(_("Message is not visible in limited view"));
3519 }
3520 }
3521 else
3522 {
3523 mutt_message(_("Fetching %s from server..."), buf_string(buf));
3524 int rc2 = nntp_check_msgid(m, buf_string(buf));
3525 if (rc2 == 0)
3526 {
3527 e = m->emails[m->msg_count - 1];
3528 struct MailboxView *mv = shared->mailbox_view;
3529 mutt_sort_headers(mv, false);
3530 menu_set_index(priv->menu, e->vnum);
3532 rc = FR_SUCCESS;
3533 }
3534 else if (rc2 > 0)
3535 {
3536 mutt_error(_("Article %s not found on the server"), buf_string(buf));
3537 }
3538 }
3539
3540done:
3541 buf_pool_release(&buf);
3542 return rc;
3543}
#define STAILQ_FIRST(head)
Definition queue.h:388
Here is the call graph for this function:

◆ op_main_change_group()

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 3552 of file functions.c.

3553{
3555 struct IndexSharedData *shared = fdata->shared;
3556 struct IndexPrivateData *priv = fdata->priv;
3557 struct Buffer *folderbuf = buf_pool_get();
3558 buf_alloc(folderbuf, PATH_MAX);
3559
3560 OptNews = false;
3561 bool read_only;
3562 char *cp = NULL;
3563 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
3564 const int op = event->op;
3565 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_GROUP_READONLY))
3566 {
3567 cp = _("Open newsgroup in read-only mode");
3568 read_only = true;
3569 }
3570 else
3571 {
3572 cp = _("Open newsgroup");
3573 read_only = false;
3574 }
3575
3576 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
3577 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
3578 {
3579 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
3580 pretty_mailbox(folderbuf);
3581 }
3582
3583 OptNews = true;
3584 const char *const c_news_server = cs_subset_string(shared->sub, "news_server");
3585 if (!mod_data->current_news_srv)
3586 mod_data->current_news_srv = nntp_select_server(shared->mailbox, c_news_server, false);
3587 if (!mod_data->current_news_srv)
3588 goto changefoldercleanup2;
3589
3590 nntp_mailbox(shared->mailbox, folderbuf->data, folderbuf->dsize);
3591
3592 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
3593 MUTT_SEL_NONE) == -1)
3594 {
3595 goto changefoldercleanup2;
3596 }
3597
3598 /* Selected directory is okay, let's save it. */
3600
3601 if (buf_is_empty(folderbuf))
3602 {
3603 msgwin_clear_text(NULL);
3604 goto changefoldercleanup2;
3605 }
3606
3607 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
3608 if (m)
3609 {
3610 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
3611 }
3612 else
3613 {
3614 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
3615 }
3616 struct MuttWindow *dlg = dialog_find(priv->win_index);
3617 dlg->help_data = IndexNewsHelp;
3618
3619changefoldercleanup2:
3620 buf_pool_release(&folderbuf);
3621 return FR_SUCCESS;
3622}
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()

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 3632 of file functions.c.

3633{
3634 struct IndexSharedData *shared = fdata->shared;
3635 struct IndexPrivateData *priv = fdata->priv;
3636 if (!shared->email)
3637 return FR_NO_ACTION;
3638
3639 const int op = event->op;
3640 if ((op != OP_FOLLOWUP) || !shared->email->env->followup_to ||
3641 !mutt_istr_equal(shared->email->env->followup_to, "poster") ||
3642 (query_quadoption(_("Reply by mail as poster prefers?"), shared->sub,
3643 "followup_to_poster") != MUTT_YES))
3644 {
3645 if (shared->mailbox && (shared->mailbox->type == MUTT_NNTP) &&
3646 !((struct NntpMboxData *) shared->mailbox->mdata)->allowed &&
3647 (query_quadoption(_("Posting to this group not allowed, may be moderated. Continue?"),
3648 shared->sub, "post_moderated") != MUTT_YES))
3649 {
3650 return FR_ERROR;
3651 }
3652 if (op == OP_POST)
3653 {
3654 mutt_send_message(SEND_NEWS, NULL, NULL, shared->mailbox, NULL, shared->sub);
3655 }
3656 else
3657 {
3658 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
3659 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
3660 mutt_send_message(((op == OP_FOLLOWUP) ? SEND_REPLY : SEND_FORWARD) | SEND_NEWS,
3661 NULL, NULL, shared->mailbox, &ea, shared->sub);
3662 ARRAY_FREE(&ea);
3663 }
3665 return FR_SUCCESS;
3666 }
3667
3668 struct KeyEvent event_r = { 0, OP_REPLY };
3669 return op_reply(fdata, &event_r);
3670}
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()

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 3676 of file functions.c.

3677{
3678 struct IndexSharedData *shared = fdata->shared;
3679 struct IndexPrivateData *priv = fdata->priv;
3681 {
3682 if (!shared->email || !shared->email->env || !shared->email->env->message_id)
3683 {
3684 mutt_message(_("No virtual folder and no Message-ID, aborting"));
3685 return FR_ERROR;
3686 } // no virtual folder, but we have Message-ID, reconstruct thread on-the-fly
3687
3688 struct Buffer *buf = buf_pool_get();
3689 buf_alloc(buf, PATH_MAX);
3690 buf_addstr(buf, "id:");
3691
3692 int msg_id_offset = 0;
3693 if ((shared->email->env->message_id)[0] == '<')
3694 msg_id_offset = 1;
3695
3696 buf_addstr(buf, shared->email->env->message_id + msg_id_offset);
3697
3698 size_t len = buf_len(buf);
3699 ASSERT(len > 0);
3700 if (buf->data[len - 1] == '>')
3701 buf->data[len - 1] = '\0';
3702
3703 change_folder_notmuch(priv->menu, buf->data, buf->dsize, &priv->oldcount, shared, false);
3704 buf_pool_release(&buf);
3705
3706 // If notmuch doesn't contain the message, we're left in an empty
3707 // vfolder. No messages are found, but nm_read_entire_thread assumes
3708 // a valid Message-ID and will throw a segfault.
3709 //
3710 // To prevent that, stay in the empty vfolder and print an error.
3711 if (!shared->mailbox)
3712 return FR_ERROR;
3713
3714 if (shared->mailbox->msg_count == 0)
3715 {
3716 mutt_error(_("failed to find message in notmuch database. try running 'notmuch new'."));
3717 return FR_ERROR;
3718 }
3719 }
3720 priv->oldcount = shared->mailbox->msg_count;
3721 int index = menu_get_index(priv->menu);
3722 struct Email *e_oldcur = mutt_get_virt_email(shared->mailbox, index);
3723 if (!e_oldcur)
3724 return FR_ERROR;
3725
3726 if (nm_read_entire_thread(shared->mailbox, e_oldcur) < 0)
3727 {
3728 mutt_message(_("Failed to read thread, aborting"));
3729 return FR_ERROR;
3730 }
3731
3732 // nm_read_entire_thread() may modify msg_count and menu won't be updated.
3733 priv->menu->max = shared->mailbox->msg_count;
3734
3735 if (priv->oldcount < shared->mailbox->msg_count)
3736 {
3737 /* nm_read_entire_thread() triggers mutt_sort_headers() if necessary */
3738 index = e_oldcur->vnum;
3739 if (e_oldcur->collapsed || shared->mailbox_view->collapsed)
3740 {
3741 index = mutt_uncollapse_thread(e_oldcur);
3742 mutt_set_vnum(shared->mailbox);
3743 }
3744 menu_set_index(priv->menu, index);
3746 }
3747
3748 return FR_SUCCESS;
3749}
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()

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 3758 of file functions.c.

3760{
3761 struct IndexSharedData *shared = fdata->shared;
3762 struct IndexPrivateData *priv = fdata->priv;
3763 int rc = FR_SUCCESS;
3764 struct Buffer *buf = buf_pool_get();
3765
3766 if ((mw_get_field("Query: ", buf, MUTT_COMP_NONE, HC_OTHER, &CompleteNmQueryOps, NULL) != 0) ||
3767 buf_is_empty(buf))
3768 {
3769 mutt_message(_("No query, aborting"));
3770 rc = FR_NO_ACTION;
3771 goto done;
3772 }
3773
3774 // Keep copy of user's query to name the mailbox
3775 char *query_unencoded = buf_strdup(buf);
3776
3777 buf_alloc(buf, PATH_MAX);
3778 const int op = event->op;
3779 struct Mailbox *m_query = change_folder_notmuch(priv->menu, buf->data, buf->dsize,
3780 &priv->oldcount, shared,
3781 (op == OP_MAIN_VFOLDER_FROM_QUERY_READONLY));
3782 if (m_query)
3783 {
3784 FREE(&m_query->name);
3785 m_query->name = query_unencoded;
3786 query_unencoded = NULL;
3787 rc = FR_SUCCESS;
3788 }
3789 else
3790 {
3791 FREE(&query_unencoded);
3792 }
3793
3794done:
3795 buf_pool_release(&buf);
3796 return rc;
3797}
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()

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 3807 of file functions.c.

3809{
3810 struct IndexSharedData *shared = fdata->shared;
3811 struct IndexPrivateData *priv = fdata->priv;
3812 // Common guard clauses.
3814 {
3815 mutt_message(_("Windowed queries disabled"));
3816 return FR_ERROR;
3817 }
3818 const char *const c_nm_query_window_current_search = cs_subset_string(shared->sub, "nm_query_window_current_search");
3819 if (!c_nm_query_window_current_search)
3820 {
3821 mutt_message(_("No notmuch vfolder currently loaded"));
3822 return FR_ERROR;
3823 }
3824
3825 // Call the specific operation.
3826 switch (event->op)
3827 {
3828 case OP_MAIN_WINDOWED_VFOLDER_BACKWARD:
3830 break;
3831 case OP_MAIN_WINDOWED_VFOLDER_FORWARD:
3833 break;
3834 case OP_MAIN_WINDOWED_VFOLDER_RESET:
3836 break;
3837
3838 default:
3839 break;
3840 }
3841
3842 // Common query window folder change.
3843 char buf[PATH_MAX] = { 0 };
3844 mutt_str_copy(buf, c_nm_query_window_current_search, sizeof(buf));
3845 change_folder_notmuch(priv->menu, buf, sizeof(buf), &priv->oldcount, shared, false);
3846
3847 return FR_SUCCESS;
3848}
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()

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 3854 of file functions.c.

3855{
3856 struct IndexPrivateData *priv = fdata->priv;
3859 return FR_SUCCESS;
3860}
void pop_fetch_mail(void)
Fetch messages and save them in $spool_file.
Definition pop.c:533
Here is the call graph for this function: