NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
functions.c File Reference

Index functions. More...

#include "config.h"
#include <ctype.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 "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 "browser.h"
#include "commands.h"
#include "context.h"
#include "hook.h"
#include "keymap.h"
#include "mutt_header.h"
#include "mutt_mailbox.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "mx.h"
#include "opcodes.h"
#include "options.h"
#include "private_data.h"
#include "protos.h"
#include "recvattach.h"
#include "score.h"
#include "shared_data.h"
#include "sort.h"
#include "autocrypt/lib.h"
#include "notmuch/lib.h"
#include "imap/lib.h"
#include "sidebar/lib.h"
#include "nntp/lib.h"
#include "nntp/mdata.h"
#include "pop/lib.h"
+ Include dependency graph for functions.c:

Go to the source code of this file.

Functions

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_stats (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 calculate message statistics for all mailboxes - 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_edit_type (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 edit attachment content type - 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_enter_command (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 enter a neomuttrc command - 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_help (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 this screen - 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_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 new 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_menu_move (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 move to the bottom of the page - 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_redraw (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 clear and redraw the screen - 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_shell_escape (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 invoke a command in a subshell - Implements index_function_t - More...
 
static int op_show_log_messages (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 show log (and debug) messages - 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_version (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 show the NeoMutt version number and date - 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_what_key (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 display the keycode for a key press - 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...
 
static int op_sidebar_next (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 move the highlight to the first mailbox - Implements index_function_t - More...
 
static int op_sidebar_open (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 open highlighted mailbox - Implements index_function_t - More...
 
static int op_sidebar_toggle_visible (struct IndexSharedData *shared, struct IndexPrivateData *priv, int op)
 make the sidebar (in)visible - Implements index_function_t - More...
 
bool prereq (struct Context *ctx, struct Menu *menu, CheckFlags checks)
 Check the pre-requisites for a function. More...
 
int index_function_dispatcher (struct MuttWindow *win_index, int op)
 Perform an Index function. More...
 

Variables

static const char * 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.

Function Documentation

◆ prereq()

bool prereq ( struct Context ctx,
struct Menu menu,
CheckFlags  checks 
)

Check the pre-requisites for a function.

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

Definition at line 2914 of file functions.c.

2915 {
2916  bool result = true;
2917 
2918  if (checks & (CHECK_MSGCOUNT | CHECK_VISIBLE | CHECK_READONLY))
2919  checks |= CHECK_IN_MAILBOX;
2920 
2921  if ((checks & CHECK_IN_MAILBOX) && (!ctx || !ctx->mailbox))
2922  {
2923  mutt_error(_("No mailbox is open"));
2924  result = false;
2925  }
2926 
2927  if (result && (checks & CHECK_MSGCOUNT) && (ctx->mailbox->msg_count == 0))
2928  {
2929  mutt_error(_("There are no messages"));
2930  result = false;
2931  }
2932 
2933  int index = menu_get_index(menu);
2934  if (result && (checks & CHECK_VISIBLE) && (index >= ctx->mailbox->vcount))
2935  {
2936  mutt_error(_("No visible messages"));
2937  result = false;
2938  }
2939 
2940  if (result && (checks & CHECK_READONLY) && ctx->mailbox->readonly)
2941  {
2942  mutt_error(_("Mailbox is read-only"));
2943  result = false;
2944  }
2945 
2946  if (result && (checks & CHECK_ATTACH) && OptAttachMsg)
2947  {
2948  mutt_error(_("Function not permitted in attach-message mode"));
2949  result = false;
2950  }
2951 
2952  if (!result)
2953  mutt_flushinp();
2954 
2955  return result;
2956 }
int msg_count
Total number of messages.
Definition: mailbox.h:91
#define mutt_error(...)
Definition: logging.h:88
#define CHECK_VISIBLE
Is the selected message visible in the index?
Definition: lib.h:71
void mutt_flushinp(void)
Empty all the keyboard buffers.
Definition: curs_lib.c:668
#define _(a)
Definition: message.h:28
int vcount
The number of virtual messages.
Definition: mailbox.h:102
struct Mailbox * mailbox
Definition: context.h:49
bool readonly
Don&#39;t allow changes to the mailbox.
Definition: mailbox.h:119
WHERE bool OptAttachMsg
(pseudo) used by attach-message
Definition: options.h:31
#define CHECK_IN_MAILBOX
Is there a mailbox open?
Definition: lib.h:69
#define CHECK_READONLY
Is the mailbox readonly?
Definition: lib.h:72
#define CHECK_ATTACH
Is the user in message-attach mode?
Definition: lib.h:73
#define CHECK_MSGCOUNT
Are there any messages?
Definition: lib.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index_function_dispatcher()

int index_function_dispatcher ( struct MuttWindow win_index,
int  op 
)

Perform an Index function.

Parameters
win_indexWindow for the Index
opOperation to perform, e.g. OP_MAIN_LIMIT
Return values
numIndexRetval or opcode

Definition at line 2964 of file functions.c.

2965 {
2966  if (!win_index)
2967  {
2969  return IR_ERROR;
2970  }
2971 
2972  struct IndexPrivateData *priv = win_index->parent->wdata;
2973  if (!priv)
2974  return IR_ERROR;
2975 
2976  struct MuttWindow *dlg = dialog_find(win_index);
2977  if (!dlg || !dlg->wdata)
2978  return IR_ERROR;
2979 
2980  struct IndexSharedData *shared = dlg->wdata;
2981 
2982  int rc = IR_UNKNOWN;
2983  for (size_t i = 0; IndexFunctions[i].op != OP_NULL; i++)
2984  {
2985  const struct IndexFunction *fn = &IndexFunctions[i];
2986  if (fn->op == op)
2987  {
2988  if (!prereq(shared->ctx, priv->menu, fn->flags))
2989  {
2990  rc = IR_ERROR;
2991  break;
2992  }
2993  rc = fn->function(shared, priv, op);
2994  break;
2995  }
2996  }
2997 
2998  return rc;
2999 }
struct IndexFunction IndexFunctions[]
All the NeoMutt functions that the Index supports.
Definition: functions.c:3004
struct Menu * menu
Menu controlling the index.
Definition: private_data.h:44
#define mutt_error(...)
Definition: logging.h:88
Private state data for the Index.
Definition: private_data.h:34
#define _(a)
Definition: message.h:28
Data shared between Index, Pager and Sidebar.
Definition: shared_data.h:36
static const char * Not_available_in_this_menu
Definition: functions.c:89
struct Context * ctx
Current Mailbox view.
Definition: shared_data.h:39
int op
Op code, e.g. OP_MAIN_LIMIT.
Definition: functions.h:61
bool prereq(struct Context *ctx, struct Menu *menu, CheckFlags checks)
Check the pre-requisites for a function.
Definition: functions.c:2914
A NeoMutt function.
Definition: functions.h:59
Unknown key.
Definition: functions.h:35
struct MuttWindow * parent
Parent Window.
Definition: mutt_window.h:135
index_function_t function
Function to call.
Definition: functions.h:62
Valid function - error occurred.
Definition: functions.h:40
void * wdata
Private data.
Definition: mutt_window.h:145
struct MuttWindow * dialog_find(struct MuttWindow *win)
Find the parent Dialog of a Window.
Definition: dialog.c:85
int flags
Prerequisites for the function, e.g. CHECK_IN_MAILBOX.
Definition: functions.h:63
+ 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
static
Initial value:
=
N_("Not available in this menu")
#define N_(a)
Definition: message.h:32

Definition at line 89 of file functions.c.

◆ IndexFunctions

struct IndexFunction IndexFunctions[]

All the NeoMutt functions that the Index supports.

Definition at line 3004 of file functions.c.