C-S-DEL (Kill an entire line at once) doesn't work in my emacs

穿精又带淫゛_ 提交于 2020-01-05 12:59:19

问题


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.



来源:https://stackoverflow.com/questions/32026896/c-s-del-kill-an-entire-line-at-once-doesnt-work-in-my-emacs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!