Emacs:变量的符号值为void [英] Emacs: Symbol's value as variable is void

查看:437
本文介绍了Emacs:变量的符号值为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

符号作为变量的值为void: 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-模式基地图

(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)



推荐答案

p>这意味着,在您调用 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:变量的符号值为void的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆