Karabiner config for emacs (iterm2)
MacOSの設定でCtrl-SpaceはデフォルトでIMの変更にアサインされている。
そのためemacsで頻出の Ctrl + Space による Mart setが動作しない。
Karabiner Element にこちらのカスタムルールを適用することで、
iTerm2についてはCtrl+SpaceをCtrl-Shift-2に書き換え、
emacs ではCtrl-Sift-2 = Ctrl-Spaceと認識させ、Mart set を使えるようにする。
本カスタマイズはUSキーボード版でチェックしています。日本語版だと各自チェックしてください。
{
"description": "iTerm2: Ctrl-Space → Ctrl-Shift-2 (^@)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "spacebar",
"modifiers": { "mandatory": ["control"], "optional": ["any"] }
},
"to": [
{ "key_code": "2", "modifiers": ["left_control", "left_shift"] }
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": ["^com\\.googlecode\\.iterm2(\\.nightly)?$"]
}
]
}
]
}
想定される副作用としては emacs 以外で Ctrl+Shift+2相当をつかっているキーバインドが、Ctrl+Spaceで勝手に動いてしまうことでしょうか。
JISキーボード版は以下で解決できるようですが、未チェックです。(Ctrl-[をターゲットにする)
{
"description": "iTerm2: Ctrl-Space → C-@ (JIS)",
"manipulators": [{
"type": "basic",
"from": { "key_code": "spacebar",
"modifiers": { "mandatory": ["control"], "optional": ["any"] }
},
"to": [
{ "key_code": "open_bracket", "modifiers": ["left_control", "left_shift"] }
],
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": ["^com\\.googlecode\\.iterm2(\\.nightly)?$"]
}
]
}]
}
もっと良いやり方があったら教えてください。