0

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
  • 5
    Please edit your question title to make it more informative of what you want to do. – Dan Feb 3 '20 at 15:25
  • 1
    You can do the opposite, i.e. making escape not act like meta, with (define-key local-function-key-map (kbd "<escape>") nil). – Erik Feb 21 '20 at 17:03
0

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).

2
  • Should this appear in my .emacs file. When I put it in my .emacs file, I get an error when loading it. I also tried putting it in a file called .Xmodmap in my home directory. Does not seem to work – Vikram Feb 22 '20 at 20:19
  • No, these are commands to execute in a shell, e.g. a command line or a file like ~/.xsession. – Stefan Feb 22 '20 at 22:45
-1

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.

0

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.