4

I have the command fill-paragraph mapped to key <escape> q, it is mapped by default in emacs.

Now I want to map the opposite command, unfill-paragraph, to key <escape> p.

However, when I do this all predefined commands with <escape> stops working. I need to explicitly remap all of them.

I am mapping the command like this:

(global-set-key (kbd "<escape> p" ) 'unfill-paragraph)

Is this the expected behavior? How can I map new commands to escape keys without clearing all predefined?

  • 1
    IMHO: Don't fiddle with <escape>. It's possible, but there are too many hard-coded thingies to work around (e.g. ESC ESC ESC). – Drew Jun 14 at 15:14
4

I have the command fill-paragraph mapped to key <escape> q, it is mapped by default in emacs.

In fact, it's mapped to ESC q by default, which is slightly different. ESC is the ascii escape character, while <escape> is the keyboard key at top left of your keyboard (but if you're using Emacs from a text terminal, the terminal probably sends ESC, not <escape>, when you press that key). When there is no binding for <escape> Emacs will translate it to ESC and lookup bindings for ESC instead.

So if you map your unfill-paragraph to ESC p things should work as you expect:

(global-set-key (kbd "ESC p" ) 'unfill-paragraph)

Note that ESC <key> is equivalent to M-<key> (i.e., you can probably use Alt+p and Alt+q as well, see (emacs) User Input)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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