Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

By default, when entering information at the command prompt in mutt, you can clear the prompt with Ctrlg, as described in the manual:

^G              n/a             abort

I have been trying to bind this function to Escape. Unfortunately, abort is not listed in the available functions, either in the manual, or in the source.

I have tried using this in my .muttrc:

bind editor <esc>       abort

but it throws an error:

Error in /home/jason/.mutt/muttrc, line 143: abort: no such function in map

I have tried using a different map, like (generic) and experimented with other fictitious functions, like clear, to no avail.

How would I bind Escape to clear the prompt line?

share|improve this question
1  
Binding escape is not a good idea as the escape character (sent upon pressing escape) is also the prefix for escape sequences sent by all function keys like arrows, del, F1... –  Stephane Chazelas Sep 11 '12 at 6:20
    
That's a good point that I had not considered. Testing it, Escape needs to be sent twice to send a literal ^[ so it may not be a showstopper (I don't use any binds that rely on it anyway). –  jasonwryan Sep 11 '12 at 6:58
    
Esc, Esc would send two ESC characters. You can also press Esc once and wait about one second (the default timeout waiting for the rest of an escape sequence). –  Stephane Chazelas Sep 11 '12 at 9:19
    
Yes. First I have to work out how to bind it :) –  jasonwryan Sep 11 '12 at 9:20
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Upvoted: because it answers the question (ie., it's not possible). Could you please elaborate on the "hardcoded... at a lower level". And while the workaround is ingenious, it is not really practicable as I use Escape in a lot of other terminal programs--hence the desire to bind it here. –  jasonwryan Sep 11 '12 at 9:41
    
I've edited my answer with more details. I'm surprised you have Esc bound in other programs as it usually isn't in applications I know for the reason mentioned in comments above. –  Stephane Chazelas Sep 11 '12 at 11:22
    
Thank you: that is helpful. –  jasonwryan Sep 11 '12 at 17:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.