简体   繁体   中英

Emacs "void-variable custom-set-variables" error

I am new to Emacs, and after playing around with some modes, I got an error message as follows:

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

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

Then, following the instruction I started Emacs with the --debug-init option, and here is the message:

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

Then I opened my.emacs file:

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

May I ask what exactly is the error, and how to fix it in the init file? Many thanks in advance!

custom-set-variables is a function, not a variable. You need and expression that's a list whose car is custom-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)
  ;; ...
 )

And note the comment. It seems that you edited that expression, and you deleted the opening parenthesis, just before custom-set-variables . This was no doubt an accident (typo). It underlines the advice to define variable custom-file , to make Emacs (Customize) keep its hands off your init file, and put such automatic expressions in your custom-file instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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