Making Mutt Vi Users Friendly

Before reading this article take in care these two points:

The aim of these patches (download tarball) is to provide an option (esc_key_aborts) for Vi users convenience.  When enabled, it replaces the abort ^G key binding for ESC.  To enable it:

:set esc_key_aborts

Caveat: as it's warned in the man page entry included in these patches, while this option is enabled, the Esc+<key> (Meta+<key>) bindings stop functioning.  This does NOT affect arrows, Home, End, PgUp, PgDown, etc. or any other of those keys that generate escape sequences in themselves.

You'll find remove.esc.bindings.rc among the files included in this tarball, that sourced from your muttrc removes all ESC+key default key bindings.  This is just to avoid hardcoded key bindings still be shown in menus and help.  You may also try the vi.bindings.rc one.

Mutt maintainer disregarded my patches

In 2017 I published these patches on mut-dev mailing list[2].

You've may been wondering:

Why one key binding needs such special treatment?

Before letting suspicion and fear mislead your judgment (like it happened to those guys in mutt-dev list) take some time to perform the following tests:

  1. Open Mutt (as provided, WITHOUT my patches) in a xterm.
  2. Open XTerm menu (Ctrl+left_click) and deselect (in case it's active) the “Meta Sends Escape” option.
  3. Now try any Meta+key bound command under Mutt.

    They didn't work, did they?  Now, without touching anything:
  4. Type “:” under Mutt and write:

    :set meta_key
    
  5. Try again some Meta+key command.

Ah, the Meta+key bindings work again!  But in the second case thanks to a mutt option intended to make Meta work on shells, terminals or ttys that aren't able to handle it by themselves (see "meta_key" option in muttrc(5).)

Now you are aware of two important details, first that the cause of the “confusion,” i.e. the infamous Meta key, has been there since ever, second that whoever wrote the meta_key option hack wasn't afraid (as the current maintainer) of touching a “low level function.”  Let's take a look to curses_lib.c:

event_t mutt_getch (void)
{

  [...]

  if ((ch & 0x80) && option (OPTMETAKEY))
  {
    /* send ALT-x as ESC-x */
    ch &= ~0x80;
    mutt_unget_event (ch, 0);
    ret.ch = '\033';
    ret.op = 0;
    return ret;
  }

  [...]

}

This conditional is placed right above of where my patches insert the esc_key_aborts option.  Now you know that:

The Meta key is not a Mutt nor even a ncurses problem

From all keys used as modifiers (eg Ctrl, Shift, Alt,) the Meta one is a special problematic case that may need a different workaround depending on the environment you are.  If you haven't noticed this problem so far is because those who mounted the OS or the Linux distribution you've been using so far already took care of disguising this inconsistency in one way or another.

In ncurses case, it seems it doesn't provide an easy, clean way to make these two options live together, hence the developer has to decide if using Esc as a modifier or to abort. It does (ncurses), however, provide a way to make arrows, Home, End, PgUp, PgDown, etc. work (see “keypad” option in getch(3).)  So, again, the problematic case is the Meta key.  I'm pretty sure Mutt creators decided to hardcode the abort function to ^G just to avoid overcomplicated workarounds (as, for example, W3M developers also did.)

But the problem doesn't end there, Mutt developers hardcoded another 333 key bindings from which 39 are Esc prefixed (see functions.h.)  So, even if any of those “perfectionists” in mutt-dev list were able to translate their wishes to code (eg the one demanding that there must be a way to bind the abort function to any key,) unless the maintainer—“conservative” as they consider him (someone else turned Mutt into a command line version of Thunderbird while he was taking a nap)—let them remove the hardcoded key bindings, the “confusion” would still be there in any or other way.

In summary, my patches are another hack like the “meta_key” one (or like the other hundred you'll surely find digging in mutt code.)  But, if you're a vi user like me, tired of hitting the Esc key by mistake again and again and “curse” curses developers mothers :-), you know these patches deserved a chance.  And for all the explained above, I doubt you'll find a more clean, effective and harmless way to do it.


(2) The list doesn't show all the messages I sent (probably because of a mutt-dev list majordomo problem.)  The tarball posted in this message, was a second different proposal which I decided to discard, there was another message with a tarball containing the version I'm sharing in this article that isn't showed in the list.  It's also important to notice that my httpd logs at that time showed only one download of the tarballs I posted in that list, and it was from an IP located in Europe what means it wasn't the maintainer.  That's why, as I suggest in the title, I don't consider my patches were rejected, but plainly ignored.

The Ethical Concern

I've been using free software since 2005.  After having lots of discussions in mailing lists and forums along the years I came to the sad conclusion that, not just plain users (understandable since they aren't always able to see the whole picture) but also developers and even those who started free software movements don't have a clear, realistic idea of where the benefit and reason of sharing software source code is (or they did when they started and at some point they “voluntarily” forgot.)  This becomes evident in how their decisions and actions (eg treating users like cattle) end up benefiting what they should fight: monopolizing power.

Another thing I got tired of is the level of hypocrisy, hostility, irrationality and, over all, lack of common sense I suffered in mailing lists and forums.

So, this (personal) web site used to be plenty of free software related articles sharing configuration tips and shell scripting working examples for unix-like systems usage and administration, that was my modest contribution, but taking in care all the explained I've eventually lost interest in writing about the matter and since I wasn't willing to maintain what I'd already published here about free software, I deleted it, it was getting outdated anyways.


Back to “Writings”


GO BACK HOME