1

I would like to set Alt_L + j to 'backward-char, and set Alt_R + j to 'windmove-left. Following OSX Emacs: unbind just the right alt?, I tried the following configurations. But it does not work.

(setq ns-right-alternate-modifier nil)
(global-set-key (kbd "M-j") 'backward-char) ;; it works
(global-set-key (kbd "Alt_R-j") 'windmove-left) ;; it does not work
(global-set-key (kbd "M_R-j") 'windmove-left) ;; it does not work
(global-set-key (kbd "Meta_R-j") 'windmove-left) ;; it does not work

When opening my emacs, there are errors such as error: Key sequence A l t _ R - j starts with non-prefix key A. It seems Alt_R, M_R, Meta_R are illegal. I have no idea what it should be. Any suggestion is appreciated.

My .emacs has no content except the above statements. Here is the version. GNU Emacs 23.1.1(i486-pc-linux-gnu, GTK + Version 2.20.1) of 2012-05-18 on roseapple, modified by Debian.

Community
  • 1
  • 1
GTH
  • 11
  • 3

2 Answers2

1

Just ask Emacs. If the key sequence is recognised, then preceding it with C-hk will always give you the syntax to plug into kbd.

Edit:

You're reading the wrong bit.

The very first line tells you "(key sequence) runs the command..."

That tells you what which sequence you just typed. (The fact that the same command may also be bound to other keys is not what you're looking for.)

What you've done is bind the command to Ctrl + Meta + j (and I'm sure if you type that, it will work).

However, from what you've said it's clear that the actual reported key sequence was M-j which means that your right alt key is acting as the Meta modifier (most likely just like your left alt key), so chances are that you haven't succeeded in the first step of getting your OS to treat them differently.

phils
  • 71,335
  • 11
  • 153
  • 198
  • Input C-h k, and right alt + j, there are messages: "It is bound to M-j C-M-j". I try the configuration: (global-set-key (kbd "C-M-j") 'windmove-left) ;; Not work. – GTH Jun 23 '13 at 16:50
  • I misunderstood what you said. My intention is to use right alt + j, not Ctrl+Alt+j. It is exactly what "Not work" means. – GTH Jun 23 '13 at 20:23
1

Alt_R and Alt_L are keys, not modifiers. Those keys are associated (via e.g. xmodmap) to modifiers, but if you want to distinguish them you need to associate them to different modifiers (e.g. one to the "meta" modifier, and the other to the "alt" modifier). Emacs relies on the window-system to do this classification, so you'll have to do it via xmodmap.

Once that is done, you'll be able to bind things to [?\A-j] for one and [?\M-j] for the other.

Stefan
  • 27,908
  • 4
  • 53
  • 82