Disabling prefix key binding

你说的曾经没有我的故事 提交于 2019-12-11 07:47:09

问题


In shell mode on emacs, the current key binding for quitting the shell mode ('comint-interrupt-subjob) is "\C-c \C-c", and I want to change it to "\C-c" as in ordinary linux shell. I tried

(add-hook 'shell-mode-hook '(lambda ()
  (local-set-key "\C-c" 'comint-interrupt-subjob)
))

But it did not work. Probably I need to disable the prefix assigned to "\C-c". How can I do that?


回答1:


Try this:

(eval-after-load "shell"
  '(define-key shell-mode-map (kbd "C-c") 'comint-interrupt-subjob))

In general, when you define keys you should define them in particular keymaps, as opposed to just hoping the local-set-key does what you want.

Note: I prefer using kbd for describing keys, your "\C-c" would work just fine.




回答2:


(define-key (current-local-map) "^C" 'comint-interrupt-subjob)

This will do the work without the error checking of local-set-key



来源:https://stackoverflow.com/questions/6474502/disabling-prefix-key-binding

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