TransWikia.com

How to Redefine Meta Key to Use Esc Key Only and Allow Using Alt Key for Another Purpose

Emacs Asked by Vikram on September 2, 2021

I am using ubuntu 18.04. The Esc-v scrolls up by a page as expected (classical Emacs command with Esc being the meta key). But I want to use Alt-v as a “paste command”. In other words: can I decouple the Alt key from Esc key so that Esc remains as the meta key but the Alt key is used for other stuff?

2 Answers

Emacs wants to make the ESC key equivalent to the Meta modifier. This actually is fine with your goal, which is to fre the Alt modifer. All you need to do is to stop Emacs's "remapping" of the Alt modifier, which it does when it sees that there's no Meta modifier. Details will vary depending on your system, but for me:

xmodmap -e 'remove mod1 = Meta_L'
xmodmap -e 'add mod3 = Meta_L'

makes convinces Emacs that I have a Meta modifier, and from then on, Emacw will not treat my Alt key as the Meta modifier but as the Alt modifier, so Alt-x turns into A-x rather than M-x.

Of course, you can also arrange to have both Alt and Meta modifier keys (e.g. by remapping the left and the right Alt keys differently, e.g. one to Alt_L and the other to Meta_R).

Answered by Stefan on September 2, 2021

Both the alt key and the esc key are setting the "Meta" modifier on the key.

Differentiating them without v significant collateral damage by breaking other meta binding is going to be difficult.

The easiest change to achieve what you desire might be to rebind something else to the scroll-down-command (which is what M-v is bound to by default).

A good option might be to define C-c v to scroll-down-command

From the manual:

Sequences consisting of C-c and a letter (either upper or lower case) are reserved for users; they are the only sequences reserved for users, so do not block them.

Answered by Realraptor on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP