I thought it twice.  Modifying functions.h will be even more confusing.

New proposal:

1.  Same original patches except for init.h.  The man page now will
show:

esc_key_aborts
       Type: boolean
       Default: no

       When set, ESC key is used instead Ctrl-G to abort commands.
       This option is intended for vi-like bindings users.

       Take in care ESC-key bindings (translated to Meta-key) will stop
       working in most cases.  We assume users interested in this
       option won't care about Meta-key emacs-like bindings, anyway, if
       you have any:

       bind <menu> \e<key> <command>

       defined in your ~/.muttrc be aware it could stop working.

       Note: mutt has several ESC-key bindings predefined that will
       still be shown in menus generating confusion.  To solve this a
       remove.esc.bindings.rc is provided that you can source from your
       ~/.muttrc.


2.  Instead of modifying functions.h, provide users with a
'remove.esc.bindings.rc' (mentioned in the man page).


# remove.esc.bindings.rc - Remove all ESC-key default bindings.
# To be used in conjunction with 'esc_key_aborts'.

bind generic    \e/     noop
bind generic    \e\t    noop
bind index      \e\t    noop
bind index      \ec     noop
bind index      \ev     noop
bind index      \eV     noop
bind index      \eC     noop
bind index      \es     noop
bind index      \ed     noop
bind index      \en     noop
bind index      \el     noop
bind index      \ep     noop
bind index      \er     noop
bind index      \ee     noop
bind index      \et     noop
bind index      \eu     noop
bind index      \eP     noop
bind index      \ek     noop
bind pager      \ec     noop
bind pager      \eC     noop
bind pager      \ed     noop
bind pager      \en     noop
bind pager      \ep     noop
bind pager      \er     noop
bind pager      \ee     noop
bind pager      \es     noop
bind pager      \eu     noop
bind pager      \e/     noop
bind pager      \eP     noop
bind pager      \ek     noop
bind attach     \ee     noop
bind attach     \eP     noop
bind compose    \ee     noop
bind compose    \ef     noop
bind compose    \ek     noop
bind editor     \eb     noop
bind editor     \ec     noop
bind editor     \el     noop
bind editor     \eu     noop
bind editor     \ef     noop
bind editor     \ed     noop


--- mutt-1.8.0/curs_lib.c       Fri Feb 24 19:29:36 2017
+++ mutt-1.8.0-modified/curs_lib.c      Thu Mar  2 17:47:55 2017
@@ -149,7 +149,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.8.0/init.h   Fri Feb 24 19:29:36 2017
+++ mutt-1.8.0-modified/init.h  Fri Mar  3 12:42:21 2017
@@ -776,6 +776,26 @@ 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
+  ** When \fIset\fP, ESC key is used instead Ctrl-G to abort commands.
+  ** This option is intended for vi-like bindings users.
+  ** .pp
+  ** Take in care ESC-key bindings (translated to Meta-key) will stop
+  ** working in most cases.  We assume users interested in this option
+  ** won't care about Meta-key emacs-like bindings, anyway, if you
+  ** have any:
+  ** .pp
+  ** bind <menu> \e<key> <command>
+  ** .pp
+  ** defined in your ~/.muttrc be aware it could stop working.
+  ** .pp
+  ** \fBNote:\fP mutt has several ESC-key bindings predefined that will
+  ** still be shown in menus generating confusion.  To solve this a
+  ** remove.esc.bindings.rc is provided that you can source from your
+  ** ~/.muttrc.
+  */
   { "fast_reply",      DT_BOOL, R_NONE, OPTFASTREPLY, 0 },
   /*
   ** .pp

--- mutt-1.8.0/keymap.c Fri Feb 24 19:29:36 2017
+++ mutt-1.8.0-modified/keymap.c        Thu Mar  2 17:48:34 2017
@@ -1133,16 +1133,32 @@ void mutt_what_key (void)
 {
   int ch;
 
-  mutt_window_mvprintw (MuttMessageWindow, 0, 0, _("Enter keys (^G to abort): 
"));
-  do {
-    ch = getch();
-    if (ch != ERR && ch != ctrl ('G'))
-    {
-      mutt_message(_("Char = %s, Octal = %o, Decimal = %d"),
-              km_keyname(ch), ch, ch);
+  if (option (OPTESCKEYABORTS))
+  {
+    mutt_window_mvprintw (MuttMessageWindow, 0, 0, _("Enter keys (ESC to 
abort): "));
+    do {
+      ch = getch();
+      if (ch != ERR && ch != '\033')
+      {
+        mutt_message(_("Char = %s, Octal = %o, Decimal = %d"),
+              km_keyname(ch), ch, ch);
+      }
     }
+    while (ch != ERR && ch != '\033');
   }
-  while (ch != ERR && ch != ctrl ('G'));
+  else
+  {
+    mutt_window_mvprintw (MuttMessageWindow, 0, 0, _("Enter keys (^G to 
abort): "));
+    do {
+      ch = getch();
+      if (ch != ERR && ch != ctrl ('G'))
+      {
+        mutt_message(_("Char = %s, Octal = %o, Decimal = %d"),
+              km_keyname(ch), ch, ch);
+      }
+    }
+    while (ch != ERR && ch != ctrl ('G'));
+  }
 
   mutt_flushinp();
   mutt_clear_error();

--- mutt-1.8.0/mutt.h   Fri Feb 24 19:29:36 2017
+++ mutt-1.8.0-modified/mutt.h  Thu Mar  2 17:48:42 2017
@@ -351,6 +351,7 @@ enum
   OPTEDITHDRS,
   OPTENCODEFROM,
   OPTENVFROM,
+  OPTESCKEYABORTS,
   OPTFASTREPLY,
   OPTFCCCLEAR,
   OPTFLAGSAFE,




Download all files from here:

https://roquesor.com/Downloads/muttesckey.tar.gz




Reply via email to