变量设置写到init.el中为什么不会自动运行

我设置有 (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. '(company-idle-delay 0) '(company-minimum-prefix-length 1) '(company-dabbrev-minimum-length 1) '(custom-safe-themes (quote (“6c62b1cd715d26eb5aa53843ed9a54fc2b0d7c5e0f5118d4efafa13d7715c56e” default)))) 为什么前三个company的变量在启动emacs时不会执行?我每次都需要按"C-x C-e"来强制执行

顺便还有一个问题, (setq make-backup-files nil) (setq auto-save-list-file-prefix nil) (setq auto-save-default nil) 这三句也是不会执行的,每次都会生成’auto-save-list/'目录,该如何解决?谢了

我设置有

(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.
 '(company-idle-delay 0)
 '(company-minimum-prefix-length 1)
 '(company-dabbrev-minimum-length 1)
 '(custom-safe-themes
   (quote
    ("6c62b1cd715d26eb5aa53843ed9a54fc2b0d7c5e0f5118d4efafa13d7715c56e" default))))

为什么前三个company的变量在启动emacs时不会执行?我每次都需要按 "C-x C-e" 来强制执行

顺便还有一个问题,

(setq make-backup-files nil) (setq auto-save-list-file-prefix nil) (setq auto-save-default nil) 

这三句也是不会执行的,每次都会生成’auto-save-list/'目录,该如何解决?谢了

(setq make-backup-files nil)
(setq auto-save-list-file-prefix nil)
(setq auto-save-default nil) 

;; If you edit it by hand, you could mess it up, so be careful.

最好不要手动改customize的代码,直接写在init.el里就好好:

(setq company-idle-delay 0)
(setq company-minimum-prefix-length 1)
(setq company-dabbrev-minimum-length 1)

autosave我不了解。

谢谢~我完了试试

上面这里说:如果是一个custom variable,最好用custom相关函数来set,因为如果包作者没用到custom的一些特性,这样和setq一样,如果用到了,这样会触发额外的操作,而setq就不正确。

不过真的需要custom函数来set的确实很少。

我的建议是有些load一个包就会产生的custom代码,设好custom-file然后让他写进去就行,自己要改动的,比如这里company的几个变量,在自己的init.el里手动写custom-set-variables之类(不过这里用setq应该是一样的吧)。

猜测是custom.el的加载顺序在company.el(也许是其他文件名)本身之后。不过在init.el里面设置应该是会生效的。

company我用setq-default设置了也不行。不过我把auto-save-list的变量用setq-default替换掉setq就可以了

这几个值如果你觉得设置没生效,可以在emacs启动后,使用 describe-variable 函数来查一下它们当前的值。

我觉得这个要么是楼主没设置对。要么就是后面加载的配置把你前面的设置覆盖掉了。

1 个赞