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

Function Emacs“;“无效变量自定义设置变量”;错误,function,variables,emacs,initialization,customization,Function,Variables,Emacs,Initialization,Customization,我是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: (vo

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

我可以问一下错误到底是什么,以及如何在init文件中修复它吗?非常感谢

自定义设置变量
是一个函数,而不是变量。您需要一个表达式,它是一个列表,其
car
自定义设置变量

(自定义设置变量)
;自定义设置变量由自定义添加。
如果你手工编辑,可能会把它弄糟,所以要小心。
;init文件应该只包含一个这样的实例。
如果不止一个,它们就不能正常工作。
'(SOME-OPTION-OPTION-VALUE)
;; ...
)

并注意评论。似乎您编辑了该表达式,并删除了左括号,就在
自定义设置变量之前。这无疑是一个意外(打字错误)。它强调了定义变量
自定义文件
,使Emacs(Customize)不要插手init文件,而是将这些自动表达式放在
自定义文件
中的建议。

我会更进一步,建议积极避免“CustomizeEmacs”机制——这是一个缺点。@user888379:,你这样做是不对的谢谢,在添加左括号后,它恢复正常。根据您的建议,我可以询问一些关于如何使用“自定义文件”的可接近的参考资料吗?是:
C-h r I自定义文件
将带您到Emacs手册的节点,在这里显示该文件。@Drew我以前错过!
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))))