NeoMutt  2025-09-05-43-g177ed6
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
Index Function API

Prototype for an Index Function. More...

+ Collaboration diagram for Index Function API:

Functions

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

Detailed Description

Prototype for an Index Function.

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

Function Documentation

◆ op_alias_dialog()

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

Open the aliases dialog - Implements index_function_t -.

Definition at line 421 of file functions.c.

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

◆ op_attachment_edit_type()

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

Edit attachment content type - Implements index_function_t -.

Definition at line 431 of file functions.c.

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

◆ op_bounce_message()

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

Remail a message to another user - Implements index_function_t -.

Definition at line 445 of file functions.c.

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

◆ op_check_traditional()

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

Check for classic PGP - Implements index_function_t -.

Definition at line 459 of file functions.c.

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

◆ op_compose_to_sender()

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

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

Definition at line 482 of file functions.c.

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

◆ op_create_alias()

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

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

Definition at line 498 of file functions.c.

500{
501 struct AddressList *al = NULL;
502 if (shared->email && shared->email->env)
503 al = mutt_get_address(shared->email->env, NULL);
504 alias_create(al, shared->sub);
506
507 return FR_SUCCESS;
508}
void alias_create(struct AddressList *al, const struct ConfigSubset *sub)
Create a new Alias from an Address.
Definition alias.c:367
struct AddressList * mutt_get_address(struct Envelope *env, const char **prefix)
Get an Address from an Envelope.
Definition alias.c:327
struct Envelope * env
Envelope information.
Definition email.h:68
+ Here is the call graph for this function:

◆ op_delete()

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

Delete the current entry - Implements index_function_t -.

This function handles:

  • OP_DELETE
  • OP_PURGE_MESSAGE

Definition at line 517 of file functions.c.

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

◆ op_delete_thread()

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

Delete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_DELETE_SUBTHREAD
  • OP_DELETE_THREAD
  • OP_PURGE_THREAD

Definition at line 553 of file functions.c.

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

◆ op_display_address()

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

Display full address of sender - Implements index_function_t -.

Definition at line 588 of file functions.c.

590{
591 if (!shared->email)
592 return FR_NO_ACTION;
594
595 return FR_SUCCESS;
596}
void mutt_display_address(struct Envelope *env)
Display the address of a message.
Definition external.c:661
+ Here is the call graph for this function:

◆ op_display_message()

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

Display a message - Implements index_function_t -.

This function handles:

  • OP_DISPLAY_HEADERS
  • OP_DISPLAY_MESSAGE

Definition at line 605 of file functions.c.

607{
608 if (!shared->email)
609 return FR_NO_ACTION;
610
612
613 /* toggle the weeding of headers so that a user can press the key
614 * again while reading the message. */
615 if (op == OP_DISPLAY_HEADERS)
616 {
617 bool_str_toggle(shared->sub, "weed", NULL);
618 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, shared);
619 if (!window_is_focused(priv->win_index))
620 return FR_SUCCESS;
621 }
622
623 OptNeedResort = false;
624
625 if (mutt_using_threads() && shared->email->collapsed)
626 {
628 mutt_set_vnum(shared->mailbox);
629 const bool c_uncollapse_jump = cs_subset_bool(shared->sub, "uncollapse_jump");
630 if (c_uncollapse_jump)
632 }
633
634 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
635 if (c_pgp_auto_decode &&
636 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
637 {
638 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
639 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
640 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
642 ARRAY_FREE(&ea);
643 }
644 const int index = menu_get_index(priv->menu);
646
647 const char *const c_pager = pager_get_pager(NeoMutt->sub);
648 if (c_pager)
649 {
650 op = external_pager(shared->mailbox_view, shared->email, c_pager);
651 }
652 else
653 {
654 op = mutt_display_message(priv->win_index, shared);
655 }
656
658 if (op < OP_NULL)
659 {
660 OptNeedResort = false;
661 return FR_ERROR;
662 }
663
664 if (shared->mailbox)
665 {
667 shared->mailbox->msg_count, shared);
668 }
669
670 return op;
671}
int bool_str_toggle(struct ConfigSubset *sub, const char *name, struct Buffer *err)
Toggle the value of a bool.
Definition bool.c:229
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:542
bool OptNeedResort
(pseudo) used to force a re-sort
Definition globals.c:63
void mutt_message_hook(struct Mailbox *m, struct Email *e, HookFlags type)
Perform a message hook.
Definition hook.c:699
#define MUTT_MESSAGE_HOOK
message-hook: run before displaying a message
Definition hook.h:44
#define NT_INDEX_EMAIL
Email has changed.
Definition lib.h:72
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:160
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition menu.c:174
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition notify.c:173
off_t mutt_set_vnum(struct Mailbox *m)
Set the virtual index number of all the messages in a mailbox.
#define mutt_thread_next_unread(e)
#define mutt_using_threads()
#define mutt_uncollapse_thread(e)
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
struct MuttWindow * window_set_focus(struct MuttWindow *win)
Set the Window focus.
struct Email * mutt_get_virt_email(struct Mailbox *m, int vnum)
Get a virtual Email.
Definition mview.c:417
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition mxapi.h:63
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition notify_type.h:48
const char * pager_get_pager(struct ConfigSubset *sub)
Get the value of $pager.
Definition config.c:111
int mutt_display_message(struct MuttWindow *win_index, struct IndexSharedData *shared)
Display a message in the pager.
Definition message.c:446
int external_pager(struct MailboxView *mv, struct Email *e, const char *command)
Display a message in an external program.
Definition message.c:299
bool collapsed
Is this message part of a collapsed thread?
Definition email.h:120
struct MuttWindow * win_index
Window for the Index.
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition shared_data.h:44
int msg_count
Total number of messages.
Definition mailbox.h:88
Container for Accounts, Notifications.
Definition neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
+ Here is the call graph for this function:

◆ op_edit_label()

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

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

Definition at line 676 of file functions.c.

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

◆ op_edit_raw_message()

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

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

This function handles:

  • OP_EDIT_OR_VIEW_RAW_MESSAGE
  • OP_EDIT_RAW_MESSAGE
  • OP_VIEW_RAW_MESSAGE

Definition at line 711 of file functions.c.

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

◆ op_end_cond()

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

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

Definition at line 756 of file functions.c.

757{
758 return FR_SUCCESS;
759}

◆ op_exit()

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

Exit this menu - Implements index_function_t -.

Definition at line 764 of file functions.c.

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

◆ op_extract_keys()

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

Extract supported public keys - Implements index_function_t -.

Definition at line 785 of file functions.c.

787{
788 if (!WithCrypto)
789 return FR_NOT_IMPL;
790 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
791 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
793 ARRAY_FREE(&ea);
795
796 return FR_SUCCESS;
797}
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailArray *ea)
Extract keys from a message.
Definition crypt.c:859
+ Here is the call graph for this function:

◆ op_flag_message()

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

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

Definition at line 802 of file functions.c.

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

◆ op_forget_passphrase()

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

Wipe passphrases from memory - Implements index_function_t -.

Definition at line 838 of file functions.c.

840{
842 return FR_SUCCESS;
843}
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition crypt.c:90
+ Here is the call graph for this function:

◆ op_forward_message()

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

Forward a message with comments - Implements index_function_t -.

Definition at line 848 of file functions.c.

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

◆ op_group_reply()

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

Reply to all recipients - Implements index_function_t -.

This function handles:

  • OP_GROUP_CHAT_REPLY
  • OP_GROUP_REPLY

Definition at line 877 of file functions.c.

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

◆ op_jump()

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

Jump to an index number - Implements index_function_t -.

Definition at line 907 of file functions.c.

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

◆ op_list_reply()

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

Reply to specified mailing list - Implements index_function_t -.

Definition at line 957 of file functions.c.

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

◆ op_list_subscribe()

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

Subscribe to a mailing list - Implements index_function_t -.

Definition at line 981 of file functions.c.

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

◆ op_list_unsubscribe()

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

Unsubscribe from mailing list - Implements index_function_t -.

Definition at line 990 of file functions.c.

992{
994}
bool mutt_send_list_unsubscribe(struct Mailbox *m, struct Email *e)
Send a mailing-list unsubscription email.
Definition send.c:2981
+ Here is the call graph for this function:

◆ op_mail()

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

Compose a new mail message - Implements index_function_t -.

Definition at line 999 of file functions.c.

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

◆ op_mailbox_list()

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

List mailboxes with new mail - Implements index_function_t -.

Definition at line 1010 of file functions.c.

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

◆ op_mail_key()

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

Mail a PGP public key - Implements index_function_t -.

Definition at line 1020 of file functions.c.

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

◆ op_main_break_thread()

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

Break the thread in two - Implements index_function_t -.

Definition at line 1033 of file functions.c.

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

◆ op_main_change_folder()

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

Open a different folder - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_FOLDER
  • OP_MAIN_CHANGE_FOLDER_READONLY
  • OP_MAIN_CHANGE_VFOLDER

Definition at line 1081 of file functions.c.

1083{
1084 struct Buffer *folderbuf = buf_pool_get();
1085 buf_alloc(folderbuf, PATH_MAX);
1086
1087 char *cp = NULL;
1088 bool read_only;
1089 const bool c_read_only = cs_subset_bool(shared->sub, "read_only");
1090 if (shared->attach_msg || c_read_only || (op == OP_MAIN_CHANGE_FOLDER_READONLY))
1091 {
1092 cp = _("Open mailbox in read-only mode");
1093 read_only = true;
1094 }
1095 else
1096 {
1097 cp = _("Open mailbox");
1098 read_only = false;
1099 }
1100
1101 const bool c_change_folder_next = cs_subset_bool(shared->sub, "change_folder_next");
1102 if (c_change_folder_next && shared->mailbox && !buf_is_empty(&shared->mailbox->pathbuf))
1103 {
1104 buf_strcpy(folderbuf, mailbox_path(shared->mailbox));
1105 buf_pretty_mailbox(folderbuf);
1106 }
1107 /* By default, fill buf with the next mailbox that contains unread mail */
1108 mutt_mailbox_next(shared->mailbox_view ? shared->mailbox : NULL, folderbuf);
1109
1110 if (mw_enter_fname(cp, folderbuf, true, shared->mailbox, false, NULL, NULL,
1111 MUTT_SEL_NO_FLAGS) == -1)
1112 {
1113 goto changefoldercleanup;
1114 }
1115
1116 /* Selected directory is okay, let's save it. */
1118
1119 if (buf_is_empty(folderbuf))
1120 {
1121 msgwin_clear_text(NULL);
1122 goto changefoldercleanup;
1123 }
1124
1125 struct Mailbox *m = mx_mbox_find2(buf_string(folderbuf));
1126 if (m)
1127 {
1128 change_folder_mailbox(priv->menu, m, &priv->oldcount, shared, read_only);
1129 }
1130 else
1131 {
1132 change_folder_string(priv->menu, folderbuf, &priv->oldcount, shared, read_only);
1133 }
1134
1135changefoldercleanup:
1136 buf_pool_release(&folderbuf);
1138
1139 return FR_SUCCESS;
1140}
#define MUTT_SEL_NO_FLAGS
No flags are set.
Definition lib.h:57
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition buffer.c:395
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition buffer.c:337
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:223
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:611
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:757
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:519
#define PATH_MAX
Definition mutt.h:42
struct Mailbox * mutt_mailbox_next(struct Mailbox *m_cur, struct Buffer *s)
Incoming folders completion routine.
void buf_pretty_mailbox(struct Buffer *buf)
Shorten a mailbox path using '~' or '='.
Definition muttlib.c:518
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
Definition mx.c:1610
int oldcount
Old count of mails in the mailbox.
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:80
+ Here is the call graph for this function:

◆ op_main_collapse_all()

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

Collapse/uncollapse all threads - Implements index_function_t -.

Definition at line 1145 of file functions.c.

1147{
1148 if (!mutt_using_threads())
1149 {
1150 mutt_error(_("Threading is not enabled"));
1151 return FR_ERROR;
1152 }
1153 collapse_all(shared->mailbox_view, priv->menu, 1);
1154 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
1155
1156 return FR_SUCCESS;
1157}
void collapse_all(struct MailboxView *mv, struct Menu *menu, int toggle)
Collapse/uncollapse all threads.
Definition dlg_index.c:165
+ Here is the call graph for this function:

◆ op_main_collapse_thread()

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

Collapse/uncollapse current thread - Implements index_function_t -.

Definition at line 1162 of file functions.c.

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

◆ op_main_delete_pattern()

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

Delete messages matching a pattern - Implements index_function_t -.

Definition at line 1203 of file functions.c.

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

◆ op_main_limit()

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

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

This function handles:

  • OP_LIMIT_CURRENT_THREAD
  • OP_MAIN_LIMIT
  • OP_TOGGLE_READ

Definition at line 1227 of file functions.c.

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

◆ op_main_link_threads()

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

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

Definition at line 1292 of file functions.c.

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

◆ op_main_modify_tags()

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

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

This function handles:

  • OP_MAIN_MODIFY_TAGS
  • OP_MAIN_MODIFY_TAGS_THEN_HIDE

Definition at line 1349 of file functions.c.

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

◆ op_main_next_new()

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

Jump to the next new message - Implements index_function_t -.

This function handles:

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

Definition at line 1467 of file functions.c.

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

◆ op_main_next_thread()

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

Jump to the next thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_NEXT_SUBTHREAD
  • OP_MAIN_NEXT_THREAD
  • OP_MAIN_PREV_SUBTHREAD
  • OP_MAIN_PREV_THREAD

Definition at line 1591 of file functions.c.

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

◆ op_main_next_undeleted()

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

Move to the next undeleted message - Implements index_function_t -.

Definition at line 1633 of file functions.c.

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

◆ op_main_next_unread_mailbox()

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

Open next mailbox with unread mail - Implements index_function_t -.

Definition at line 1666 of file functions.c.

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

◆ op_main_prev_undeleted()

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

Move to the previous undeleted message - Implements index_function_t -.

Definition at line 1689 of file functions.c.

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

◆ op_main_quasi_delete()

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

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

Definition at line 1722 of file functions.c.

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

◆ op_main_read_thread()

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

Mark the current thread as read - Implements index_function_t -.

This function handles:

  • OP_MAIN_READ_SUBTHREAD
  • OP_MAIN_READ_THREAD

Definition at line 1758 of file functions.c.

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

◆ op_main_root_message()

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

Jump to root message in thread - Implements index_function_t -.

This function handles:

  • OP_MAIN_PARENT_MESSAGE
  • OP_MAIN_ROOT_MESSAGE

Definition at line 1788 of file functions.c.

1790{
1791 int index = mutt_parent_message(shared->email, op == OP_MAIN_ROOT_MESSAGE);
1792 if (index != -1)
1793 menu_set_index(priv->menu, index);
1794
1795 return FR_SUCCESS;
1796}
int mutt_parent_message(struct Email *e, bool find_root)
Find the parent of a message.
+ Here is the call graph for this function:

◆ op_main_set_flag()

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

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

This function handles:

  • OP_MAIN_CLEAR_FLAG
  • OP_MAIN_SET_FLAG

Definition at line 1805 of file functions.c.

1807{
1808 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
1809 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
1810
1811 if (mw_change_flag(shared->mailbox, &ea, (op == OP_MAIN_SET_FLAG)) == 0)
1812 {
1813 if (priv->tag_prefix)
1814 {
1816 }
1817 else
1818 {
1820 }
1821 }
1822 ARRAY_FREE(&ea);
1823
1824 return FR_SUCCESS;
1825}
int mw_change_flag(struct Mailbox *m, struct EmailArray *ea, bool bf)
Change the flag on a Message -.
Definition flags.c:454
+ Here is the call graph for this function:

◆ op_main_show_limit()

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

Show currently active limit pattern - Implements index_function_t -.

Definition at line 1830 of file functions.c.

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

◆ op_main_sync_folder()

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

Save changes to mailbox - Implements index_function_t -.

Definition at line 1851 of file functions.c.

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

◆ op_main_tag_pattern()

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

Tag messages matching a pattern - Implements index_function_t -.

Definition at line 1926 of file functions.c.

1928{
1929 mutt_pattern_func(shared->mailbox_view, MUTT_TAG, _("Tag messages matching: "));
1931
1932 return FR_SUCCESS;
1933}
+ Here is the call graph for this function:

◆ op_main_undelete_pattern()

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

Undelete messages matching a pattern - Implements index_function_t -.

Definition at line 1938 of file functions.c.

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

◆ op_main_untag_pattern()

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

Untag messages matching a pattern - Implements index_function_t -.

Definition at line 1960 of file functions.c.

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

◆ op_mark_msg()

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

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

Definition at line 1972 of file functions.c.

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

◆ op_next_entry()

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

Move to the next entry - Implements index_function_t -.

Definition at line 2027 of file functions.c.

2028{
2029 const int index = menu_get_index(priv->menu) + 1;
2030 if (index >= shared->mailbox->vcount)
2031 {
2032 mutt_message(_("You are on the last message"));
2033 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2034 return FR_ERROR;
2035 }
2036 menu_set_index(priv->menu, index);
2037 return FR_SUCCESS;
2038}
+ Here is the call graph for this function:

◆ op_pipe()

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

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

Definition at line 2043 of file functions.c.

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

◆ op_prev_entry()

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

Move to the previous entry - Implements index_function_t -.

Definition at line 2064 of file functions.c.

2065{
2066 int index = menu_get_index(priv->menu);
2067 if (index < 1)
2068 {
2069 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
2070 mutt_message(_("You are on the first message"));
2071 return FR_ERROR;
2072 }
2073 menu_set_index(priv->menu, index - 1);
2074 return FR_SUCCESS;
2075}
+ Here is the call graph for this function:

◆ op_print()

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

Print the current entry - Implements index_function_t -.

Definition at line 2080 of file functions.c.

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

◆ op_query()

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

Query external program for addresses - Implements index_function_t -.

Definition at line 2101 of file functions.c.

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

◆ op_quit()

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

Save changes to mailbox and quit - Implements index_function_t -.

Definition at line 2110 of file functions.c.

2111{
2112 if (shared->attach_msg)
2113 return FR_DONE;
2114
2115 if (query_quadoption(_("Quit NeoMutt?"), shared->sub, "quit") == MUTT_YES)
2116 {
2117 priv->oldcount = shared->mailbox ? shared->mailbox->msg_count : 0;
2118
2120 mutt_debug(LL_NOTIFY, "NT_GLOBAL_SHUTDOWN\n");
2122
2123 enum MxStatus check = MX_STATUS_OK;
2124 if (!shared->mailbox_view || ((check = mx_mbox_close(shared->mailbox)) == MX_STATUS_OK))
2125 {
2126 mview_free(&shared->mailbox_view);
2127 mailbox_free(&shared->mailbox);
2128 return FR_DONE;
2129 }
2130
2131 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2132 {
2133 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2134 }
2135
2136 menu_queue_redraw(priv->menu, MENU_REDRAW_FULL); /* new mail arrived? */
2138 }
2139
2140 return FR_NO_ACTION;
2141}
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:89
void mutt_startup_shutdown_hook(HookFlags type)
Execute any startup/shutdown hooks.
Definition hook.c:963
#define MUTT_SHUTDOWN_HOOK
shutdown-hook: run when leaving NeoMutt
Definition hook.h:55
@ LL_NOTIFY
Log of notifications.
Definition logging2.h:49
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
Definition mx.c:598
@ NT_GLOBAL_SHUTDOWN
NeoMutt is about to close.
Definition neomutt.h:68
@ NT_GLOBAL
Not object-related, NotifyGlobal.
Definition notify_type.h:46
struct Notify * notify
Notifications handler.
Definition neomutt.h:44
+ Here is the call graph for this function:

◆ op_recall_message()

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

Recall a postponed message - Implements index_function_t -.

Definition at line 2146 of file functions.c.

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

◆ op_reply()

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

Reply to a message - Implements index_function_t -.

Definition at line 2158 of file functions.c.

2159{
2160 if (!shared->email)
2161 return FR_NO_ACTION;
2162 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2163 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2164 const bool c_pgp_auto_decode = cs_subset_bool(shared->sub, "pgp_auto_decode");
2165 if (c_pgp_auto_decode &&
2166 (priv->tag_prefix || !(shared->email->security & PGP_TRADITIONAL_CHECKED)))
2167 {
2168 if (mutt_check_traditional_pgp(shared->mailbox, &ea))
2170 }
2171 int rc = mutt_send_message(SEND_REPLY, NULL, NULL, shared->mailbox, &ea,
2172 shared->sub);
2173 ARRAY_FREE(&ea);
2175
2176 return (rc == -1) ? FR_ERROR : FR_SUCCESS;
2177}
+ Here is the call graph for this function:

◆ op_resend()

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

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

Definition at line 2182 of file functions.c.

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

◆ op_save()

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

Make decrypted copy - Implements index_function_t -.

This function handles:

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

Definition at line 2217 of file functions.c.

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

◆ op_search()

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

Search for a regular expression - Implements index_function_t -.

This function handles:

  • OP_SEARCH
  • OP_SEARCH_NEXT
  • OP_SEARCH_OPPOSITE
  • OP_SEARCH_REVERSE

Definition at line 2257 of file functions.c.

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

◆ op_sort()

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

Sort messages - Implements index_function_t -.

This function handles:

  • OP_SORT
  • OP_SORT_REVERSE

Definition at line 2296 of file functions.c.

2297{
2298 if (!mutt_select_sort(op == OP_SORT_REVERSE))
2299 return FR_ERROR;
2300
2301 if (shared->mailbox && (shared->mailbox->msg_count != 0))
2302 {
2303 resort_index(shared->mailbox_view, priv->menu);
2305 }
2306
2307 return FR_SUCCESS;
2308}
void resort_index(struct MailboxView *mv, struct Menu *menu)
Resort the index.
Definition dlg_index.c:369
bool mutt_select_sort(bool reverse)
Ask the user for a sort method.
Definition external.c:476
+ Here is the call graph for this function:

◆ op_tag()

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

Tag the current entry - Implements index_function_t -.

Definition at line 2313 of file functions.c.

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

◆ op_tag_thread()

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

Tag the current thread - Implements index_function_t -.

This function handles:

  • OP_TAG_SUBTHREAD
  • OP_TAG_THREAD

Definition at line 2347 of file functions.c.

2348{
2349 if (!shared->email)
2350 return FR_NO_ACTION;
2351
2352 int rc = mutt_thread_set_flag(shared->mailbox, shared->email, MUTT_TAG,
2353 !shared->email->tagged, (op != OP_TAG_THREAD));
2354 if (rc != -1)
2355 {
2356 const enum ResolveMethod rm = (op == OP_TAG_THREAD) ? RESOLVE_NEXT_THREAD :
2358 resolve_email(priv, shared, rm);
2360 }
2361
2362 return FR_SUCCESS;
2363}
+ Here is the call graph for this function:

◆ op_toggle_new()

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

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

Definition at line 2368 of file functions.c.

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

◆ op_toggle_write()

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

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

Definition at line 2410 of file functions.c.

2412{
2413 mx_toggle_write(shared->mailbox);
2414 return FR_SUCCESS;
2415}
int mx_toggle_write(struct Mailbox *m)
Toggle the mailbox's readonly flag.
Definition mx.c:1812
+ Here is the call graph for this function:

◆ op_undelete()

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

Undelete the current entry - Implements index_function_t -.

Definition at line 2420 of file functions.c.

2421{
2422 /* L10N: CHECK_ACL */
2423 if (!check_acl(shared->mailbox, MUTT_ACL_DELETE, _("Can't undelete message")))
2424 return FR_ERROR;
2425
2426 struct EmailArray ea = ARRAY_HEAD_INITIALIZER;
2427 ea_add_tagged(&ea, shared->mailbox_view, shared->email, priv->tag_prefix);
2428
2429 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_DELETE, false);
2430 mutt_emails_set_flag(shared->mailbox, &ea, MUTT_PURGE, false);
2431 ARRAY_FREE(&ea);
2432
2433 if (priv->tag_prefix)
2434 {
2436 }
2437 else
2438 {
2439 resolve_email(priv, shared, RESOLVE_NEXT_EMAIL);
2440 }
2441
2442 return FR_SUCCESS;
2443}
+ Here is the call graph for this function:

◆ op_undelete_thread()

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

Undelete all messages in thread - Implements index_function_t -.

This function handles:

  • OP_UNDELETE_SUBTHREAD
  • OP_UNDELETE_THREAD

Definition at line 2452 of file functions.c.

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

◆ op_view_attachments()

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

Show MIME attachments - Implements index_function_t -.

Definition at line 2483 of file functions.c.

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

◆ op_autocrypt_acct_menu()

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

Manage autocrypt accounts - Implements index_function_t -.

Definition at line 2512 of file functions.c.

2514{
2515 dlg_autocrypt();
2516 return FR_SUCCESS;
2517}
void dlg_autocrypt(void)
Display the Autocrypt account Menu -.
+ Here is the call graph for this function:

◆ op_main_imap_fetch()

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

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

Definition at line 2523 of file functions.c.

2525{
2526 if (!shared->mailbox || (shared->mailbox->type != MUTT_IMAP))
2527 return FR_NO_ACTION;
2528
2529 imap_check_mailbox(shared->mailbox, true);
2530 return FR_SUCCESS;
2531}
enum MxStatus imap_check_mailbox(struct Mailbox *m, bool force)
Use the NOOP or IDLE command to poll for new mail.
Definition imap.c:1034
+ Here is the call graph for this function:

◆ op_main_imap_logout_all()

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

Logout from all IMAP servers - Implements index_function_t -.

Definition at line 2536 of file functions.c.

2538{
2539 if (shared->mailbox && (shared->mailbox->type == MUTT_IMAP))
2540 {
2541 const enum MxStatus check = mx_mbox_close(shared->mailbox);
2542 if (check == MX_STATUS_OK)
2543 {
2544 mview_free(&shared->mailbox_view);
2545 }
2546 else
2547 {
2548 if ((check == MX_STATUS_NEW_MAIL) || (check == MX_STATUS_REOPENED))
2549 {
2550 update_index(priv->menu, shared->mailbox_view, check, priv->oldcount, shared);
2551 }
2554 return FR_ERROR;
2555 }
2556 }
2558 mutt_message(_("Logged out of IMAP servers"));
2561
2562 return FR_SUCCESS;
2563}
void imap_logout_all(void)
Close all open connections.
Definition imap.c:556
+ Here is the call graph for this function:

◆ op_catchup()

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

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

Definition at line 2568 of file functions.c.

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

◆ op_get_children()

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

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

This function handles:

  • OP_GET_CHILDREN
  • OP_RECONSTRUCT_THREAD

Definition at line 2588 of file functions.c.

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

◆ op_get_message()

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

Get parent of the current message - Implements index_function_t -.

This function handles:

  • OP_GET_MESSAGE
  • OP_GET_PARENT

Definition at line 2689 of file functions.c.

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

◆ op_main_change_group()

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

Open a different newsgroup - Implements index_function_t -.

This function handles:

  • OP_MAIN_CHANGE_GROUP
  • OP_MAIN_CHANGE_GROUP_READONLY

Definition at line 2770 of file functions.c.

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

◆ op_post()

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

Followup to newsgroup - Implements index_function_t -.

This function handles:

  • OP_FOLLOWUP
  • OP_POST

Definition at line 2846 of file functions.c.

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

◆ op_main_entire_thread()

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

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

Definition at line 2886 of file functions.c.

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

◆ op_main_vfolder_from_query()

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

Generate virtual folder from query - Implements index_function_t -.

This function handles:

  • OP_MAIN_VFOLDER_FROM_QUERY
  • OP_MAIN_VFOLDER_FROM_QUERY_READONLY op_main_vfolder_from_query

Definition at line 2965 of file functions.c.

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

◆ op_main_windowed_vfolder()

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

Shifts virtual folder time window - Implements index_function_t -.

This function handles:

  • OP_MAIN_WINDOWED_VFOLDER_BACKWARD
  • OP_MAIN_WINDOWED_VFOLDER_FORWARD
  • OP_MAIN_WINDOWED_VFOLDER_RESET

Definition at line 3012 of file functions.c.

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

◆ op_main_fetch_mail()

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

Retrieve mail from POP server - Implements index_function_t -.

Definition at line 3054 of file functions.c.

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