syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.65k stars 4.89k forks source link

HHKB:How to set the muhenkan(the diamond key) key as leader? #5102

Closed shuokay closed 8 years ago

shuokay commented 8 years ago

I am using hhkb pro2 on HHKB mode. I want to set the muhenkan(diamond) key instead of M-m as the spacemacs leader key? How to config the .spacemacs file?

sooheon commented 8 years ago

Check what key emacs registers the diamond key as, maybe try C-h k (for describe-key, which describes next key pressed) then the diamond key. You can set that as the dotspacemacs-leader-key variable in the dotspacemacs/init fn in your .spacemacs.

shuokay commented 8 years ago

@sooheon It seems C-h k can't describe a leader key or not registered key. Nothing output after C-h k diamond or C-h k Ctrl

StreakyCobra commented 8 years ago

I don't know at all this muhenkan key, but if it is a modifier like Ctrl or Alt, https://www.gnu.org/software/emacs/manual/html_node/emacs/Modifier-Keys.html says:

Although only the Control and META modifier keys are commonly used, Emacs supports three other modifier keys. These are called Super, Hyper and Alt.

It doesn't seems Emacs can support it.

If it is a normal key that is recognized, then it should display the … is undefined when you press it after C-h k. For instance I can do C-h k à and it displays à is undefined.

shuokay commented 8 years ago

@StreakyCobra According to your reply, I think the diamond key is META modifier. spacemacs have take Alt as META, then how can I make use of the real META key as spacemacs' SPC leader? Now I have make S-SPC as the leader, however it still need press 2 key.

StreakyCobra commented 8 years ago

You can try to press C-h k diamond-a to see if really emacs sees it as a modifier. If it says M-a it's meta, C-a it's control, S-a it's shift, if it says s-a it's Super, H-a it's meta, A-a its alt.

On the other side, if your diamond is really a modifier, I'm not really sure you can bind it as a normal key to use it as a leader.

shuokay commented 8 years ago

@StreakyCobra emacs does not see it as a modifier or any other key. when I press C-h diamond-a the emacs report it as only a single a.

StreakyCobra commented 8 years ago

So I'm afraid you can't do anything on Emacs/Spacemacs side. It's probably possible to tweak this key at operating system level to make it recognised as another one that can by used within Spacemacs, but this will apply to all applications then. So if you need it in other applications as diamond it's probably not an option.

shuokay commented 8 years ago

@StreakyCobra agree with you. But here is the output of xev command

KeyRelease event, serial 37, synthetic NO, window 0x5600001,
    root 0x1ea, subw 0x0, time 116953461, (402,599), root:(508,703),
    state 0x0, keycode 102 (keysym 0xff22, Muhenkan), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

As we can see, the keycode is 102, does this make any sense?

StreakyCobra commented 8 years ago

From the operating system point of view, yes it makes sense. My understanding is that Emacs don't support this key. Maybe it's possible to make it supported, but that would be a solution I'm not aware of.

shuokay commented 8 years ago

@StreakyCobra When I press diamond key in visual emacs, the result is

<muhenkan> is undefined
StreakyCobra commented 8 years ago

You was on terminal??

shuokay commented 8 years ago

@StreakyCobra When start emacs on terminal, nothing outputed, when start emacs with graphical interface, the minibuffer output is <muhenkan> is undefined

StreakyCobra commented 8 years ago

Why didn't you tell me you was using terminal mode before :stuck_out_tongue: The way in which keys are passed to emacs through the terminal is really oldish. Even the TAB key is not send as TAB but as C-i, so I'm not surprised the muhenkan is not supported. Glad to hear that it is actually supported by the GUI version though.

So in short you'll have to use the GUI version of emacs if you want a full support of your keyboard keys.

shuokay commented 8 years ago

@StreakyCobra so how can I define <muhenkan> as leader key? I am used to emacs in terminal. Maybe the <muhenkan> leader key wouldn't work for me, but I still want to learn the method to define a undefined key as the leader. PS, I am using S-SPC as the leader key. It need press 2 key, but I think it just fine to me before finding a better way.

StreakyCobra commented 8 years ago

@shuokay Try setting dotspacemacs-leader-key to <muhenkan> in your .spacemacs.

shuokay commented 8 years ago

@StreakyCobra this config work for visual emacs

dotspacemacs-emacs-leader-key "<muhenkan>"

Since I used to emacs in terminal mode, I still set S-SPC as my emacs leader key. I put this method here in case someone will need. Thank you very much @StreakyCobra

hthaneunt commented 6 years ago

I am using an hhkb with regular emacs and ran into the same problem. Turning dip SW1 "ON" allows linux to register <muhenkan> as <super>. Was able to change <super> to <meta> by these settings here.

You can also remap <muhenkan> as <meta> by following these instructions here. Just change the config so that the keycode will register as a <meta> event. I haven't tried it, but am assuming this would allow the key to be used in terminals.

Note: The <muhenkan> key is used to switch between two syllabic Japanese scripts. Described here and here.