I wanted to change the behaviour of Ctrl–d 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))))
Then inserted this into emacs.d:
(global-set-key (kbd "\C-d") 'backward-delete-word)
It works in fundamental-mode, but in php-mode it just removes the next character. When I click
Ctrl-h k Ctrl-d
Emacs gives this:
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?
I don’t have
php-modeso I can’t say for sure, but the binding is likely overriden inphp-mode-map(which, as a major mode map, has higher precedence than the global map).You can check by using C-h b to list all available key bindings and look for
C-dorc-electric-delete-forwardin the output buffer to see in which keymap the binding is defined.Assuming
php-mode-mapoverrides the C-d binding, you can disable it using