我的 Emacs 配置文件中有这段 Elisp 代码:
(when (string= (getenv "TERM") "screen")
(custom-set-variables
(custom-set-faces
'(font-lock-comment-face ((((class color)
(min-colors 8)
(background dark))
(foreground red)))))))
当我启动 Emacs 时,我从这段代码中得到 Error setting nil: (setting-constant nil)
。虽然它看起来工作正常,但我知道这可能是一些隐藏问题的迹象。我不太了解 Elisp,因此我需要帮助。谁能解释一下这个错误并告诉我如何消除它?我使用的是 Emacs 24.3.1
最佳答案
恐怕这有很多问题。
custom-set-faces
和custom-set-variables
是两种不同的形式;你不应该在另一个内部调用一个。您不应该将对这些函数中的任何一个的调用包装在条件表达式中。当您使用
customize
界面时,这两种表单都会自动生成和更新,如果它们不是 init 文件中的顶级表单,Emacs 将找不到它们。这意味着它会在需要时为每个副本创建一个附加副本。这导致...您不得拥有这些表单的多个实例。事实上,Emacs 在生成表单时包含以下警告注释:
;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right.
现在你正在鼓励这种情况发生。
关于emacs - 在 Elisp 中调试 "Error setting nil",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28086626/