ねんがんのMacbook Proをてにいれたぞ!

http://serif.hatelabo.jp/images/cache/939304e68a7f81a2dc307f128716c572cba0df09/e339bdf42d1ef91387772d5c5a9e9fd3e47c1795.gif

(あとでなんかかくよてい) かいた


Emacsは使えないけどEmacsキーバインドは好きなikikkoです、こんばんは。この度晴れてApple信者になったわけですが、WinからMac移行に当たって一番気にかけていたのがキーバインドなんです。

Win機を使っていたころは、XKeymacsで全アプリのキーバインドを入れ替えていました。なんで、Macでもキーバインドのカスタマイズは真っ先に調べたところです。で、MacではKeyRemap4MacBookでできそうだったんで、これでやってみようと思いました。KeyRemap4MacBookにはEmacsライクな設定も組み込まれているので、それを有効にするだけで大体は事足りるのですが、Eclipseが結構鬼門に。

何故かは知らない*1のですが、KeyRemap4MacBookの設定がEclipseでは除外されていました。なので、EclipseでもEmacsキーバインドが有効になるように、設定を追加。

あとは、補完のキー。Winのときから[Ctrl+Space]を使っていたので、それに合わせるように。EmacsのSet Markは[Ctrl+@]に割り当てて、Spotlightは多分使用頻度が低そうな[F1]に。

これらを設定したprivate.xmlが↓の感じです。あー疲れた。

<?xml version="1.0"?>
<root>
  <list>
    <item>
      <name>Private</name>
      <list>
      
        <item>
        <name>Emacs Mode</name>
          <list>
          
            <item> 
              <name>Force change C-ae to Command+Left/Right</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_controlAE_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::A, VK_CONTROL, KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L</autogen> 
                  <autogen>--KeyToKey-- KeyCode::E, VK_CONTROL, KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_controlAE_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::A, VK_CONTROL, KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L</autogen> 
                  <autogen>--KeyToKey-- KeyCode::E, VK_CONTROL, KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen>  
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_controlAE_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::A, VK_CONTROL, KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L</autogen> 
                  <autogen>--KeyToKey-- KeyCode::E, VK_CONTROL, KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_controlAE_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  <autogen>--KeyToKey-- KeyCode::A, VK_CONTROL, KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L</autogen> 
                  <autogen>--KeyToKey-- KeyCode::E, VK_CONTROL, KeyCode::CURSOR_RIGHT, ModifierFlag::COMMAND_L</autogen>  
                </item> 
              </list> 
            </item> 
            
            <item> 
              <name>Force change C-y to Command+V</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_controlY_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::Y, VK_CONTROL, KeyCode::V, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_controlY_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::Y, VK_CONTROL, KeyCode::V, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_controlY_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::Y, VK_CONTROL, KeyCode::V, ModifierFlag::COMMAND_L</autogen>
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_controlY_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  j<autogen>--KeyToKey-- KeyCode::Y, VK_CONTROL, KeyCode::V, ModifierFlag::COMMAND_L</autogen> 
                </item> 
              </list> 
            </item> 
            
            <item> 
              <name>Force change C-v to PageDown</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_controlV_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_CONTROL, KeyCode::PAGEDOWN</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_controlV_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_CONTROL, KeyCode::PAGEDOWN</autogen> 
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_controlV_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_CONTROL, KeyCode::PAGEDOWN</autogen>
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_controlV_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_CONTROL, KeyCode::PAGEDOWN</autogen> 
                </item> 
              </list> 
            </item> 
            
            <item> 
              <name>Force change Command-v to PageUp</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_commandV_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_COMMAND, KeyCode::PAGEUP</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_commandV_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_COMMAND, KeyCode::PAGEUP</autogen> 
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_commandV_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_COMMAND, KeyCode::PAGEUP</autogen>
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_commandV_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  <autogen>--KeyToKey-- KeyCode::V, VK_COMMAND, KeyCode::PAGEUP</autogen> 
                </item> 
              </list> 
            </item> 
            
            <item> 
              <name>Force change C-/ to Command+Z</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_controlZ_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::SLASH, VK_CONTROL, KeyCode::Z, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_controlZ_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::SLASH, VK_CONTROL, KeyCode::Z, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_controlZ_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::SLASH, VK_CONTROL, KeyCode::Z, ModifierFlag::COMMAND_L</autogen>
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_controlZ_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  <autogen>--KeyToKey-- KeyCode::SLASH, VK_CONTROL, KeyCode::Z, ModifierFlag::COMMAND_L</autogen> 
                </item> 
              </list> 
            </item> 
            
            <item> 
              <name>Force change C-S to Command+F</name> 
              <list> 
                <item> 
                  <name>In Emacs, Terminal</name> 
                  <identifier>private.emacsmode_force_controlS_term</identifier> 
                  <only>EMACS, TERMINAL</only> 
                  <autogen>--KeyToKey-- KeyCode::S, VK_CONTROL, KeyCode::F, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In X11</name> 
                  <identifier>private.emacsmode_force_controlS_x11</identifier> 
                  <only>X11</only> 
                  <autogen>--KeyToKey-- KeyCode::S, VK_CONTROL, KeyCode::F, ModifierFlag::COMMAND_L</autogen> 
                </item> 
                <item> 
                  <name>In VMware Fusion, Parallels Desktop, Remote Desktop Connection</name> 
                  <identifier>private.emacsmode_force_controlS_vm</identifier> 
                  <only>VIRTUALMACHINE, REMOTEDESKTOPCONNECTION</only> 
                  <autogen>--KeyToKey-- KeyCode::S, VK_CONTROL, KeyCode::F, ModifierFlag::COMMAND_L</autogen>
                </item> 
                <item> 
                  <name>In Eclipse</name> 
                  <identifier>private.emacsmode_force_controlS_eclipse</identifier> 
                  <only>ECLIPSE</only> 
                  <autogen>--KeyToKey-- KeyCode::S, VK_CONTROL, KeyCode::F, ModifierFlag::COMMAND_L</autogen> 
                </item> 
              </list> 
            </item> 
            
            <item>
              <name>[ex] Use Control+@ as MarkSet</name>
              <list> 
                <item> 
                  <!-- MarkSet Mode Core --> 
                  <name>MarkSet Mode detail</name> 
                  <appendix>Control+W to Command_L+X</appendix> 
                  <appendix>Option+W to Command_L+C</appendix> 
                  <appendix>Control+G to turn off MarkSet</appendix> 
                  <appendix>Control+@ to turn off MarkSet</appendix> 
                  <identifier vk_config="true">notsave.private.emacsmode_ex_controlSpace_core</identifier> 
                  <autogen>--ShowStatusMessage-- MarkSet</autogen> 
                  <autogen>--KeyToKey-- KeyCode::W,          VK_CONTROL | ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::VK_LOCK_SHIFT_L_FORCE_OFF, KeyCode::X, ModifierFlag::COMMAND_L, KeyCode::VK_CONFIG_FORCE_OFF_notsave_emacsmode_ex_controlSpace_core</autogen> 
                  <autogen>--KeyToKey-- KeyCode::W,          VK_OPTION  | ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::VK_LOCK_SHIFT_L_FORCE_OFF, KeyCode::C, ModifierFlag::COMMAND_L, KeyCode::VK_CONFIG_FORCE_OFF_notsave_emacsmode_ex_controlSpace_core</autogen> 
                  <autogen>--KeyToKey-- KeyCode::G,          VK_CONTROL | ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::VK_LOCK_SHIFT_L_FORCE_OFF,                                      KeyCode::VK_CONFIG_FORCE_OFF_notsave_emacsmode_ex_controlSpace_core</autogen>
                  <autogen>--KeyToKey-- KeyCode::JIS_ATMARK, VK_CONTROL | ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::VK_LOCK_SHIFT_L_FORCE_OFF,                                      KeyCode::VK_CONFIG_FORCE_OFF_notsave_emacsmode_ex_controlSpace_core</autogen>
                </item> 
                <item> 
                  <name>Enable Control+@</name> 
                  <identifier>private.emacsmode_ex_controlSpace</identifier> 
                  <!--
                    <not>EMACS, TERMINAL, VIRTUALMACHINE, REMOTEDESKTOPCONNECTION, X11, ECLIPSE</not> 
                  -->
                  <autogen>--KeyToKey-- KeyCode::JIS_ATMARK, VK_CONTROL | ModifierFlag::NONE, KeyCode::VK_LOCK_SHIFT_L_FORCE_ON, KeyCode::VK_CONFIG_FORCE_ON_notsave_emacsmode_ex_controlSpace_core</autogen> 
                </item> 
              </list>
            </item>
            
          </list>
        </item>
        
      </list>
    </item>
  </list>
</root>

*1:Eclipse内部の設定でキーバインドをカスタマイズできるから、KeyRemap4MacBookではなくてEclipse側でやってくれというポリシーなのかな?