-->

C-S-DEL (Kill an entire line at once) doesn't

2019-08-04 07:12发布

问题:

This says that C-S-DEL is bound to kill-whole-line command that kills an entire line at once. I tried it on my macbook with emacs 24.5.1, however, it doesn't work at all. I then use C-h k C-S-DEL to check what happened when I press this hotkey. It says that, only DEL key is recognised other than Ctrl + Shift + DEL.

I install this emacs (version 24.5.1) via Homebrew and run it in iTerm2. It does't have a GUI version (I prefer to use in terminal), and is launched simply via emacs command.

How can I config my emacs to support C-S-DEL?

回答1:

It is possible, but it is a bit cumberstone. Use a tool like Karibinder to remap C-S-delete while using your terminal to a key sequence your terminal does receive. You can use M-x describe-unbound-keys with unbound.el to find such keys. Then, within your emacs configuration, you should remap those keys to the appropriate functions.

Here is an example of how you could remap C-S-delete to C-x n M-[ u with Karibinder by putting it in your private.xml file. Karabinder's documentation is very good.

  <appdef>
    <appname>TERMINAL</appname>
    <equal>com.apple.Terminal</equal>
  </appdef>

  <item>
    <name>Fix C-S-delete Emacs</name>
    <identifier>private.m_s_delete_emacs</identifier>
    <only>TERMINAL</only>
    <autogen>
        __KeyToKey__
        KeyCode::DELETE, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L,
        KeyCode::X, ModifierFlag::CONTROL_L, KeyCode::N, KeyCode::BRACKET_LEFT, ModifierFlag::OPTION_L, KeyCode::U
    </autogen>
  </item>

And then in your emacs configuration:

(global-set-key (kbd "C-x n M-[ u") 'kill-whole-line)

Perhaps there are more OS X users out there that prefer to use the terminal version of emacs over a GUI version. In that case, a comprehensive Karbiner & emacs configuration may be created by the community to cover all key sequences that use modifiers unsupported by the terminal. As of yet there is no such thing I believe, but I will update my answer if I find anything or if something is created.