Emacs:符号作为变量的值是无效的 [英] Emacs: Symbol's value as variable is void
问题描述
这是我的~/.emacs
文件:
(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)
当我打开 emacs 时收到警告:
I'm getting a warning when I open up emacs:
警告(初始化):加载时发生错误c:/home/.emacs
:
Warning (initialization): An error occurred while loading
c:/home/.emacs
:
Symbol 作为变量的值是无效的:c-mode-base-map
Symbol's value as variable is void: c-mode-base-map
为确保正常运行,您应该调查并删除初始化文件中错误的原因.使用以下命令启动 Emacs--debug-init
选项以查看完整的错误回溯.
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.
我运行了 --debug-init
,这就是它返回的内容.我不知道我的意思:
I ran --debug-init
and this is what it returned. I don't know what I means:
调试器进入--Lisp错误:(void-variable c-mode-base-map
)
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)
推荐答案
这意味着,在您调用 define-key
时,c-mode-base-map
还没有被任何东西定义.
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)
然而,还有其他可能的修复方法,例如在模式挂钩中设置键绑定,或使用 eval-after-load
.您使用哪一种取决于您;我倾向于采用 KISS 方法,因为我通常不关心启动时间;但如果你这样做,你可能想要更懒惰的东西.
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.
这篇关于Emacs:符号作为变量的值是无效的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!