This is my ~/.emacs
file:
(setq-default c-basic-offset 4 c-default-style "linux")
(setq-default tab-width 4 indent-tabs-mode t)
(define-key c-mode-base-map (kbd "RET") 'newline-and-indent)
I'm getting a warning when I open up emacs:
Warning (initialization): An error occurred while loading
c:/home/.emacs
:Symbol's value as variable is void:
c-mode-base-map
To ensure normal operations, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the
--debug-init
option to view a complete error backtrace.
I ran --debug-init
and this is what it returned. I don't know what I means:
Debugger entered--Lisp error: (void-variable
c-mode-base-map
)(define-key c-mode-base-map (kbd "RET") (quote newline-and-indent)) eval-buffer(#<buffer *load*> nil "c:/home/.emacs" nil t) ; Reading at buffer position 311 load-with-code-conversion("c:/home/.emacs" "c:/home/.emacs" t t) load("~/.emacs" t t)
What this means is that, at the point at which you invoke define-key
, c-mode-base-map
is not yet defined by anything.
The usual fix is to find out where this is defined and require that module. In this case:
(require 'cc-mode)
However there are other possible fixes as well, for example setting the key-binding in a mode hook, or using eval-after-load
. Which one you use is up to you; I tend to do the KISS approach since I don't generally care about startup time; but if you do you may want something lazier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With