NeoMutt  2022-04-29-178-g3b62e6
Teaching an old dog new tricks
DOXYGEN
functions.c File Reference

Index functions. More...

#include "config.h"
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "functions.h"
#include "lib.h"
#include "attach/lib.h"
#include "browser/lib.h"
#include "enter/lib.h"
#include "menu/lib.h"
#include "ncrypt/lib.h"
#include "pager/lib.h"
#include "pattern/lib.h"
#include "progress/lib.h"
#include "question/lib.h"
#include "send/lib.h"
#include "commands.h"
#include "hook.h"
#include "keymap.h"
#include "mutt_header.h"
#include "mutt_mailbox.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "mview.h"
#include "mx.h"
#include "opcodes.h"
#include "options.h"
#include "private_data.h"
#include "protos.h"
#include "shared_data.h"
#include "sort.h"
#include "autocrypt/lib.h"
#include "notmuch/lib.h"
#include "imap/lib.h"
#include "nntp/lib.h"
#include "nntp/mdata.h"
#include "pop/lib.h"
#include <libintl.h>
+ Include dependency graph for functions.c:

Go to the source code of this file.

Enumerations

enum  ResolveMethod { RESOLVE_NEXT_EMAIL , RESOLVE_NEXT_UNDELETED , RESOLVE_NEXT_THREAD , RESOLVE_NEXT_SUBTHREAD }
 How to advance the cursor. More...
 

Functions

static bool resolve_email (struct IndexPrivateData *priv, struct IndexSharedData *shared, enum ResolveMethod rm)
 Pick the next Email to advance the cursor to. More...
 
bool index_next_undeleted (struct MuttWindow *win_index)
 Select the next undeleted Email (if possible) More...
 
static int op_alias_dialog (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open the aliases dialog - Implements index_function_t -. More...
 
static int op_attachment_edit_type (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Edit attachment content type - Implements index_function_t -. More...
 
static int op_bounce_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Remail a message to another user - Implements index_function_t -. More...
 
static int op_check_traditional (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Check for classic PGP - Implements index_function_t -. More...
 
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 -. More...
 
static int op_create_alias (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Create an alias from a message sender - Implements index_function_t -. More...
 
static int op_delete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete the current entry - Implements index_function_t -. More...
 
static int op_delete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete all messages in thread - Implements index_function_t -. More...
 
static int op_display_address (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display full address of sender - Implements index_function_t -. More...
 
static int op_display_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Display a message - Implements index_function_t -. More...
 
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 -. More...
 
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 -. More...
 
static int op_end_cond (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 End of conditional execution (noop) - Implements index_function_t -. More...
 
static int op_exit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Exit this menu - Implements index_function_t -. More...
 
static int op_extract_keys (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Extract supported public keys - Implements index_function_t -. More...
 
static int op_flag_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'important' flag - Implements index_function_t -. More...
 
static int op_forget_passphrase (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Wipe passphrases from memory - Implements index_function_t -. More...
 
static int op_forward_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Forward a message with comments - Implements index_function_t -. More...
 
static int op_group_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to all recipients - Implements index_function_t -. More...
 
static int op_jump (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to an index number - Implements index_function_t -. More...
 
static int op_list_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to specified mailing list - Implements index_function_t -. More...
 
static int op_list_subscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Subscribe to a mailing list - Implements index_function_t -. More...
 
static int op_list_unsubscribe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Unsubscribe from mailing list - Implements index_function_t -. More...
 
static int op_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Compose a new mail message - Implements index_function_t -. More...
 
static int op_mailbox_list (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 List mailboxes with new mail - Implements index_function_t -. More...
 
static int op_mail_key (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mail a PGP public key - Implements index_function_t -. More...
 
static int op_main_break_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Break the thread in two - Implements index_function_t -. More...
 
static int op_main_change_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different folder - Implements index_function_t -. More...
 
static int op_main_collapse_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse all threads - Implements index_function_t -. More...
 
static int op_main_collapse_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Collapse/uncollapse current thread - Implements index_function_t -. More...
 
static int op_main_delete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Delete messages matching a pattern - Implements index_function_t -. More...
 
static int op_main_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Limit view to current thread - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_modify_tags (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Modify (notmuch/imap) tags - Implements index_function_t -. More...
 
static int op_main_next_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next new message - Implements index_function_t -. More...
 
static int op_main_next_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to the next thread - Implements index_function_t -. More...
 
static int op_main_next_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next undeleted message - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_prev_undeleted (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous undeleted message - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_read_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark the current thread as read - Implements index_function_t -. More...
 
static int op_main_root_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Jump to root message in thread - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_show_limit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show currently active limit pattern - Implements index_function_t -. More...
 
static int op_main_sync_folder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox - Implements index_function_t -. More...
 
static int op_main_tag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag messages matching a pattern - Implements index_function_t -. More...
 
static int op_main_undelete_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete messages matching a pattern - Implements index_function_t -. More...
 
static int op_main_untag_pattern (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Untag messages matching a pattern - Implements index_function_t -. More...
 
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 -. More...
 
static int op_next_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the next entry - Implements index_function_t -. More...
 
static int op_pipe (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Pipe message/attachment to a shell command - Implements index_function_t -. More...
 
static int op_prev_entry (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Move to the previous entry - Implements index_function_t -. More...
 
static int op_print (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Print the current entry - Implements index_function_t -. More...
 
static int op_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Query external program for addresses - Implements index_function_t -. More...
 
static int op_quit (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Save changes to mailbox and quit - Implements index_function_t -. More...
 
static int op_recall_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Recall a postponed message - Implements index_function_t -. More...
 
static int op_reply (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Reply to a message - Implements index_function_t -. More...
 
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 -. More...
 
static int op_save (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Make decrypted copy - Implements index_function_t -. More...
 
static int op_search (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Search for a regular expression - Implements index_function_t -. More...
 
static int op_sort (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Sort messages - Implements index_function_t -. More...
 
static int op_tag (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current entry - Implements index_function_t -. More...
 
static int op_tag_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Tag the current thread - Implements index_function_t -. More...
 
static int op_toggle_new (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle a message's 'new' flag - Implements index_function_t -. More...
 
static int op_toggle_write (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Toggle whether the mailbox will be rewritten - Implements index_function_t -. More...
 
static int op_undelete (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete the current entry - Implements index_function_t -. More...
 
static int op_undelete_thread (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Undelete all messages in thread - Implements index_function_t -. More...
 
static int op_view_attachments (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Show MIME attachments - Implements index_function_t -. More...
 
static int op_autocrypt_acct_menu (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Manage autocrypt accounts - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_imap_logout_all (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Logout from all IMAP servers - Implements index_function_t -. More...
 
static int op_catchup (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Mark all articles in newsgroup as read - Implements index_function_t -. More...
 
static int op_get_children (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get all children of the current message - Implements index_function_t -. More...
 
static int op_get_message (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Get parent of the current message - Implements index_function_t -. More...
 
static int op_main_change_group (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Open a different newsgroup - Implements index_function_t -. More...
 
static int op_post (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Followup to newsgroup - Implements index_function_t -. More...
 
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 -. More...
 
static int op_main_vfolder_from_query (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Generate virtual folder from query - Implements index_function_t -. More...
 
static int op_main_windowed_vfolder (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Shifts virtual folder time window - Implements index_function_t -. More...
 
static int op_main_fetch_mail (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 Retrieve mail from POP server - Implements index_function_t -. More...
 
bool prereq (struct MailboxView *mv, struct Menu *menu, CheckFlags checks)
 Check the pre-requisites for a function. More...
 
int index_function_dispatcher (struct MuttWindow *win, int op)
 Perform an Index function - Implements function_dispatcher_t -. More...
 

Variables

static const char * Not_available_in_this_menu = N_("Not available in this menu")
 
struct IndexFunction IndexFunctions []
 All the NeoMutt functions that the Index supports. More...
 

Detailed Description

Index functions.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file functions.c.

Enumeration Type Documentation

◆ ResolveMethod

How to advance the cursor.

Enumerator
RESOLVE_NEXT_EMAIL 

Next email, whatever its state.

RESOLVE_NEXT_UNDELETED 

Next undeleted email.

RESOLVE_NEXT_THREAD 

Next top-level thread.

RESOLVE_NEXT_SUBTHREAD 

Next sibling sub-thread.

Definition at line 93 of file functions.c.

94{
99};
@ RESOLVE_NEXT_SUBTHREAD
Next sibling sub-thread.
Definition: functions.c:98
@ RESOLVE_NEXT_UNDELETED
Next undeleted email.
Definition: functions.c:96
@ RESOLVE_NEXT_EMAIL
Next email, whatever its state.
Definition: functions.c:95
@ RESOLVE_NEXT_THREAD
Next top-level thread.
Definition: functions.c:97

Function Documentation

◆ resolve_email()

static bool resolve_email ( struct IndexPrivateData priv,
struct IndexSharedData shared,
enum ResolveMethod  rm 
)
static

Pick the next Email to advance the cursor to.

Parameters
privPrivate Index data
sharedShared Index data
rmHow to advance the cursor, e.g. RESOLVE_NEXT_EMAIL
Return values
trueResolve succeeded

Definition at line 108 of file functions.c.

110{
111 if (!priv || !priv->menu || !shared || !shared->mailbox || !shared->email)
112 return false;
113
114 const bool c_resolve = cs_subset_bool(shared->sub, "resolve");
115 if (!c_resolve)
116 return false;
117
118 int index = -1;
119 switch (rm)
120 {
122 index = menu_get_index(priv->menu) + 1;
123 break;
124
126 {
127 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
128 index = ci_next_undeleted(shared->mailbox, menu_get_index(priv->menu), uncollapse);
129 break;
130 }
131
133 index = mutt_next_thread(shared->email);
134 break;
135
137 index = mutt_next_subthread(shared->email);
138 break;
139 }
140
141 if ((index < 0) || (index >= shared->mailbox->vcount))
142 {
143 // Resolve failed
144 notify_send(shared->notify, NT_INDEX, NT_INDEX_EMAIL, NULL);
145 return false;
146 }
147
148 menu_set_index(priv->menu, index);
149 return true;
150}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition: helpers.c:73
int ci_next_undeleted(struct Mailbox *m, int msgno, bool uncollapse)
Find the next undeleted email.
Definition: dlg_index.c:242
#define NT_INDEX_EMAIL
Email has changed.
Definition: lib.h:66
int menu_get_index(struct Menu *menu)
Get the current selection in the Menu.
Definition: menu.c:154
MenuRedrawFlags menu_set_index(struct Menu *menu, int index)
Set the current selection in the Menu.
Definition: menu.c:168
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:171
#define mutt_using_threads()
Definition: mutt_thread.h:100
#define mutt_next_subthread(e)
Definition: mutt_thread.h:108
#define mutt_next_thread(e)
Definition: mutt_thread.h:106
bool window_is_focused(const struct MuttWindow *win)
Does the given Window have the focus?
Definition: mutt_window.c:629
@ NT_INDEX
Index data has changed, NotifyIndex, IndexSharedData.
Definition: notify_type.h:48
struct MuttWindow * win_index
Window for the Index.
Definition: private_data.h:44
struct Menu * menu
Menu controlling the index.
Definition: private_data.h:43
struct Email * email
Currently selected Email.
Definition: shared_data.h:42
struct Mailbox * mailbox
Current Mailbox.
Definition: shared_data.h:41
struct ConfigSubset * sub
Config set to use.
Definition: shared_data.h:38
struct Notify * notify
Notifications: NotifyIndex, IndexSharedData.
Definition: shared_data.h:44
int vcount
The number of virtual messages.
Definition: mailbox.h:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_next_undeleted()

bool index_next_undeleted ( struct MuttWindow win_index)

Select the next undeleted Email (if possible)

Parameters
win_indexIndex Window
Return values
trueSelection succeeded

Definition at line 157 of file functions.c.

158{
159 struct MuttWindow *dlg = dialog_find(win_index);
160 if (!dlg)
161 return false;
162
163 struct Menu *menu = win_index->wdata;
164 struct IndexSharedData *shared = dlg->wdata;
165 if (!shared)
166 return false;
167
168 struct IndexPrivateData *priv = win_index->parent->wdata;
169 const bool uncollapse = mutt_using_threads() && !window_is_focused(priv->win_index);
170
171 int index = ci_next_undeleted(shared->mailbox, menu_get_index(menu), uncollapse);
172 if ((index < 0) || (index >= shared->mailbox->vcount))
173 {
174 // Selection failed
176 return false;
177 }
178
179 menu_set_index(menu, index);
180 return true;
181}
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:83
Private state data for the Index.
Definition: private_data.h:35
struct IndexSharedData * shared
Shared Index data.
Definition: private_data.h:42
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:37
Definition: lib.h:69
void * wdata
Private data.
Definition: mutt_window.h:145
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prereq()

bool prereq ( struct MailboxView mv,
struct Menu menu,
CheckFlags  checks 
)

Check the pre-requisites for a function.

Parameters
mvMailbox View
menuCurrent Menu
checksChecks to perform, see CheckFlags
Return values
trueThe checks pass successfully

Definition at line 2784 of file functions.c.

2785{
2786 bool result = true;
2787
2788 if (checks & (CHECK_MSGCOUNT | CHECK_VISIBLE | CHECK_READONLY))
2789 checks |= CHECK_IN_MAILBOX;
2790
2791 if ((checks & CHECK_IN_MAILBOX) && (!mv || !mv->mailbox))
2792 {
2793 mutt_error(_("No mailbox is open"));
2794 result = false;
2795 }
2796
2797 if (result && (checks & CHECK_MSGCOUNT) && (mv->mailbox->msg_count == 0))
2798 {
2799 mutt_error(_("There are no messages"));
2800 result = false;
2801 }
2802
2803 int index = menu_get_index(menu);
2804 if (result && (checks & CHECK_VISIBLE) && (index >= mv->mailbox->vcount))
2805 {
2806 mutt_error(_("No visible messages"));
2807 result = false;
2808 }
2809
2810 if (result && (checks & CHECK_READONLY) && mv->mailbox->readonly)
2811 {
2812 mutt_error(_("Mailbox is read-only"));
2813 result = false;
2814 }
2815
2816 if (result && (checks & CHECK_ATTACH) && OptAttachMsg)
2817 {
2818 mutt_error(_("Function not permitted in attach-message mode"));
2819 result = false;
2820 }
2821
2822 if (!result)
2823 mutt_flushinp();
2824
2825 return result;
2826}
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:593
#define mutt_error(...)
Definition: logging.h:87
#define CHECK_ATTACH
Is the user in message-attach mode?
Definition: lib.h:74
#define CHECK_VISIBLE
Is the selected message visible in the index?
Definition: lib.h:72
#define CHECK_IN_MAILBOX
Is there a mailbox open?
Definition: lib.h:70
#define CHECK_READONLY
Is the mailbox readonly?
Definition: lib.h:73
#define CHECK_MSGCOUNT
Are there any messages?
Definition: lib.h:71
#define _(a)
Definition: message.h:28
bool OptAttachMsg
(pseudo) used by attach-message
Definition: options.h:37
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:49
int msg_count
Total number of messages.
Definition: mailbox.h:88
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ Not_available_in_this_menu

const char* Not_available_in_this_menu = N_("Not available in this menu")
static

Definition at line 88 of file functions.c.

◆ IndexFunctions

struct IndexFunction IndexFunctions[]

All the NeoMutt functions that the Index supports.

Definition at line 2877 of file functions.c.