0

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

Edit

Removing

(org-babel-do-load-languages
'org-babel-load-languages
'(
   (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?

user615536
  • 215
  • 1
  • 7
  • 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. – dalanicolai May 25 '22 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 May 25 '22 at 12:28
  • #' is an abbreviation for function. See the Elisp manual, node Anonymous Functions. – Drew May 25 '22 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 May 25 '22 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. – dalanicolai May 25 '22 at 16:51
  • thanks, I will try that – user615536 May 25 '22 at 18:48
  • You mention ~/.emacs.d/init.el and ~/.emacs. Note, that Emacs loads only one of them if you do not explicitly call (load "~/.emacs.d/init.el") in ~/.emacs. If you put (global-set-key (kbd "C-d") 'delete-backward-char) into ~/.emacs.d/init.el and a non-empty ~/.emacs exists (without (load "~/.emacs.d/init.el")) then the global-set-key is never evaluated. – Tobias May 25 '22 at 20:26

0 Answers0