问题描述
我想改变 - 键的行为。所以它会删除一个字向后。我创建了一个函数:
I wanted to change the behaviour of - key. So it will delete a word backward. I created a function:
(defun backward-delete-word (arg)
"Delete characters backward until encountering the beginning of a word.
With argument ARG, do this that many times."
(interactive "p")
(delete-region (point) (progn (backward-word arg) (point))))
然后将其插入 emacs.d
:
(global-set-key (kbd "\C-d") 'backward-delete-word)
它以基本模式工作,但在php模式下,它只会删除下一个字符。当我点击
It works in fundamental-mode, but in php-mode it just removes the next character. When I click
Emacs给出:
C-d runs the command c-electric-delete-forward, which is an
interactive compiled Lisp function in `cc-cmds.el'.
It is bound to C-d.
(c-electric-delete-forward ARG)
不知何故被重置为另一个功能。如何找出它在哪里重新设置并使其与我的功能一起工作?
Somehow, it was reset to another function. How to find out, where it was reset and make it work with my function instead?
推荐答案
我没有code> php-mode 所以我不能肯定地说,但绑定可能会覆盖在 php-mode-map
(其中,作为主要模式地图,优先级高于全球地图)。
I don't have php-mode
so I can't say for sure, but the binding is likely overriden in php-mode-map
(which, as a major mode map, has higher precedence than the global map).
您可以使用来检查列出所有可用的密钥绑定并在输出缓冲区中查找 Cd
或 c-electric-delete-forward
,以查看哪个键盘映射绑定被定义。
You can check by using to list all available key bindings and look for C-d
or c-electric-delete-forward
in the output buffer to see in which keymap the binding is defined.
假设 php-mode-map
覆盖绑定,你可以使用
Assuming php-mode-map
overrides the binding, you can disable it using
(define-key php-mode-map (kbd "C-d") nil)
这篇关于Emacs无法重设Ctrl-d键的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!