M-x global-set-key <RET> C-d delete-backward-char successfully rebinds C-d to delete-backward-char.

However, (global-set-key (kbd "C-d") 'delete-backward-char) in my ~/.emacs.d/init.el doesn't seem to have any effect. This related post doesn't solve it for me.

I am new to emacs, is there something wrong with the way I am entering my command in my init file. Note that other commands successfully working in my init file include ones such as:

(global-set-key (kbd "C-c a") #'org-agenda).

I don't understand why the # is needed here, but using a # did not solve my problem of remapping C-d



   (emacs-lisp . t)
   (R . t)
   (python . t)
   (scheme . t)
   (java . t))
   (latex . t)

from my ~/.emacs file causes things to work. But I would like to be able to keep these lines if possible. Any idea why these lines are problematic?

  • When testing with an init file, with only the line you mention here, C-d correctly triggers the command delete-backward-char (i.e. it deletes the inserted characters). What does C-h k C-d tell you? Placing #' before a symbol is called 'sharp quoting' its use and purpose is explained here. Commented May 25, 2022 at 11:15
  • 2
    What's the mode of the buffer where C-d is not working? It may be that it overrides the global keymap setting with its own. @dalanicolai's comment tells you how to check.
    – NickD
    Commented May 25, 2022 at 12:28
  • #' is an abbreviation for function. See the Elisp manual, node Anonymous Functions.
    – Drew
    Commented May 25, 2022 at 14:10
  • @dalanicolai C-h k C-d says that C-d runs the command delete-char (found in global-map). It seems that some lines in my .emacs file are causing problems, as shown in my update. I am testing things out in the scratch buffer and it works when I remove the problematic lines
    – user615536
    Commented May 25, 2022 at 16:07
  • 1
    To me, it looks like the parenthesis that is placed after (java . t) should really be placed after (latex . t). Otherwise, try to start Emacs via emacs --debug-iinit. Commented May 25, 2022 at 16:51


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.