Rebinding "clear prompt" in mutt

mutt

It's not possible with key bindings. Ctrl-G is hardcoded in mutt at a lower level than the macro or keybinding processing (see mutt_getch() in mutt's source code, at the core of all user input in mutt that returns an error upon ^G).

macro editor \e '^G'

wouldn't work either.

What you can do is configure your terminal to send ^G upon pressing Escape

With xterm:

xterm -xrm 'XTerm.VT100.translations: #override <KeyPress> Escape: string(0x7)'

If you're using screen, you can also do

screen -X bindkey $'\e' stuff $'\a'

before calling mutt and restore it afterwards (unfortunately, it doesn't seem you can have per screen window key bindings in screen). Also, it's going to be a problem if your editor for email messages is vi.

neomutt

Since release 20200313 There's $abort_key config variable to change the default Ctrl-G.


It seems like a really bad idea to me to bind escape to ControlG also. I came here looking for a mutt solution, but since it seems there is none, I'll give an answer from what I'm doing for anyone who happens to stumble across this. It's not optimal but it won't affect any other programs:

macro editor \e "<enter><shell-escape>xdotool key control+g<enter>"

or

macro editor \e "<enter><shell-escape>xsendkey Control+g<enter>"

Using something like xdotool or xsendkey to fake control+g works and doesn't mess up escape everywhere else. There's a visual delay for me for it to exit the line editor, but index bindings will work immediately and the visual delay will be gone as soon as you use an index binding. The first enter is necessary so that mutt won't just type out "...." and make that into a header or search term or something.