tags:

views:

45

answers:

1

I'd like to use a keycode with modifiers in my .emacs file. However my naive attempts have failed so far. For instance if I use:

(global-set-key [93] "\\")

The ¥ key on my keyboard will emit \. However, what I'd also like to do is:

(global-set-key "M-[93]" "\\") ;; doesn't work

My implementation says that:

error: Key sequence ⇧M - [ 9 3 ] starts with non-prefix key ⇧M

How do I use modifiers such as M, S with keys defined by keycode?

The back story is that I'm trying to modify my .emacs file to handle both the ¥ and \ behavior which exist on Japanese keyboards. For instance on an Apple keyboard, option-¥ would emit \ while ¥ would emit ¥. A different workaround is to use:

(setq ns-alternate-modifier 'option)

However this sets the option key as option. Which means meta must be defined on another key, which is inconvenient. Thus the motivation for this question.

+2  A: 

Run the command with M-x global-set-key and type the desired key combo. Then have Emacs output what it used to do the binding by doing C-x ESC ESC. Then you can copy that.

For more info than you ever wanted: the guide

J Cooper
`M-x global-set-key` is somewhat annoying as it demands a command, but I was able to just chose something arbitrary and then recover the key code from `C-x ESC ESC` Thanks!
speciousfool