Hello,

I'm not quite skilled in C but I think I figured out how to add a
boolean variable 'esc_key_aborts' to set ESC key as an alternative to
the default emacs-like Ctrl-G to abort commands.  I guess vi-like users
will appreciate this feature.


--- mutt-1.7.2/mutt.h   Mon Dec  5 00:46:59 2016
+++ mutt-1.7.2-modified/mutt.h  Sat Feb 25 14:31:12 2017
@@ -340,6 +340,7 @@ enum
   OPTEDITHDRS,
   OPTENCODEFROM,
   OPTENVFROM,
+  OPTESCKEYABORTS,
   OPTFASTREPLY,
   OPTFCCCLEAR,
   OPTFOLLOWUPTO,

--- mutt-1.7.2/curs_lib.c       Mon Dec  5 00:46:59 2016
+++ mutt-1.7.2-modified/curs_lib.c      Sat Feb 25 14:45:01 2017
@@ -148,7 +148,10 @@ event_t mutt_getch (void)
 
   ret.ch = ch;
   ret.op = 0;
-  return (ch == ctrl ('G') ? err : ret);
+  if (option (OPTESCKEYABORTS))
+    return (ch == '\033' ? err : ret);
+  else
+    return (ch == ctrl ('G') ? err : ret);
 }
 
 int _mutt_get_field (const char *field, char *buf, size_t buflen, int 
complete, int multiple, char ***files, int *numfiles)

--- mutt-1.7.2/mutt.h   Mon Dec  5 00:46:59 2016
+++ mutt-1.7.2-modified/mutt.h  Sat Feb 25 14:31:12 2017
@@ -340,6 +340,7 @@ enum
   OPTEDITHDRS,
   OPTENCODEFROM,
   OPTENVFROM,
+  OPTESCKEYABORTS,
   OPTFASTREPLY,
   OPTFCCCLEAR,
   OPTFOLLOWUPTO,

--- mutt-1.7.2/init.h   Mon Dec  5 00:46:59 2016
+++ mutt-1.7.2-modified/init.h  Sat Feb 25 14:35:34 2017
@@ -762,6 +762,14 @@ struct option_t MuttVars[] = {
   ** .pp
   ** Escape character to use for functions in the built-in editor.
   */
+  { "esc_key_aborts",  DT_BOOL, R_NONE, OPTESCKEYABORTS, 0 },
+  /*
+  ** .pp
+  ** For vi-like bindings users.  Set this value to ``yes'' to use
+  ** ESC key instead of the default Ctrl-G to abort commands.  Take
+  ** in care some predifined emacs-like Meta prefixed bindings will
+  ** stop working.
+  */
   { "fast_reply",      DT_BOOL, R_NONE, OPTFASTREPLY, 0 },
   /*
   ** .pp

Reply via email to