繁体   English   中英

Emacs“无效变量自定义设置变量”错误

[英]Emacs "void-variable custom-set-variables" error

我是 Emacs 的新手,在玩了一些模式后,我收到如下错误消息:

Warning (initialization): An error occurred while loading ‘/Users/Tao/.emacs’:

Symbol's value as variable is void: custom-set-variables

然后,按照说明,我使用 --debug-init 选项启动了 Emacs,这是消息:

Debugger entered--Lisp error: (void-variable custom-set-variables)
  eval-buffer(#<buffer  *load*> nil "/Users/Tao/.emacs" nil t)  ; Reading at buffer position 21
  load-with-code-conversion("/Users/Tao/.emacs" "/Users/Tao/.emacs" t t)
  load("~/.emacs" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode 0x1fee6b60d6f5>) #f(compiled-function () #<bytecode 0x1fee6b60d709>) t)
  command-line()
  normal-top-level()

然后我打开了 my.emacs 文件:

custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default default default italic underline success warning error])
 '(custom-enabled-themes '(tango-dark))
 '(package-selected-packages '(auctex proof-general)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
(require 'package)
;; (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3") ; see remark below
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
 (dolist (hook '(tex-mode-hook))
      (add-hook hook (lambda () (flyspell-mode 1))))

请问究竟是什么错误,以及如何在init文件中修复它? 提前谢谢了!

custom-set-variables是 function,而不是变量。 您需要和表达式是一个列表,其carcustom-set-variables

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(SOME-OPTION THE-OPTION-VALUE)
  ;; ...
 )

并注意评论。 似乎您编辑了该表达式,并在custom-set-variables之前删除了左括号。 这无疑是一个意外(错字)。 它强调了定义变量custom-file的建议,以使 Emacs (Customize) 远离您的 init 文件,并将此类自动表达式放在您的custom-file中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM