灵异事件,Emacs 会在每次save cutom variables 之后插进去一大堆配置

这是我的本来的最新的custom-file,我没有再用Spacemacs,而是用的purcell的配置,其实这里面并没啥内容

(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.
 '(safe-local-variable-values
   (quote
    ((checkdoc-minor-mode . t)
     (mangle-whitespace . t)
     (no-byte-compile t))))
 '(session-use-package t nil (session)))
(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.
 '(custom-group-tag ((t (:height 1.0)))))

然后这是每次都插进去的一摸一样的配置,插在 custom-set-variables 里面

 '(compilation-message-face (quote default))
 '(cua-global-mark-cursor-color "#2aa198")
 '(cua-normal-cursor-color "#839496")
 '(cua-overwrite-cursor-color "#b58900")
 '(cua-read-only-cursor-color "#859900")
 '(highlight-changes-colors (quote ("#d33682" "#6c71c4")))
 '(highlight-symbol-colors
   (--map
    (solarized-color-blend it "#002b36" 0.25)
    (quote
     ("#b58900" "#2aa198" "#dc322f" "#6c71c4" "#859900" "#cb4b16" "#268bd2"))))
 '(highlight-symbol-foreground-color "#93a1a1")
 '(highlight-tail-colors
   (quote
    (("#073642" . 0)
     ("#546E00" . 20)
     ("#00736F" . 30)
     ("#00629D" . 50)
     ("#7B6000" . 60)
     ("#8B2C02" . 70)
     ("#93115C" . 85)
     ("#073642" . 100))))
 '(hl-bg-colors
   (quote
    ("#7B6000" "#8B2C02" "#990A1B" "#93115C" "#3F4D91" "#00629D" "#00736F" "#546E00")))
 '(hl-fg-colors
   (quote
    ("#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36")))
 '(magit-diff-use-overlays nil)
 '(nrepl-message-colors
   (quote
    ("#dc322f" "#cb4b16" "#b58900" "#546E00" "#B4C342" "#00629D" "#2aa198" "#d33682" "#6c71c4")))
 '(pos-tip-background-color "#073642")
 '(pos-tip-foreground-color "#93a1a1")
 '(safe-local-variable-values
   (quote
    ((no-byte-compile nil)
     (checkdoc-minor-mode . t)
     (mangle-whitespace . t)
     (no-byte-compile t))))
 '(session-use-package t nil (session))
 '(smartrep-mode-line-active-bg (solarized-color-blend "#859900" "#073642" 0.2))
 '(term-default-bg-color "#002b36")
 '(term-default-fg-color "#839496")
 '(vc-annotate-background-mode nil)
 '(weechat-color-list
   (quote
    (unspecified "#002b36" "#073642" "#990A1B" "#dc322f" "#546E00" "#859900" "#7B6000" "#b58900" "#00629D" "#268bd2" "#93115C" "#d33682" "#00736F" "#2aa198" "#839496" "#657b83")))
 '(xterm-color-names
   ["#073642" "#dc322f" "#859900" "#b58900" "#268bd2" "#d33682" "#2aa198" "#eee8d5"])
 '(xterm-color-names-bright
   ["#002b36" "#cb4b16" "#586e75" "#657b83" "#839496" "#6c71c4" "#93a1a1" "#fdf6e3"]))

明显是我之前使用Spacemacs 所残留下来的配置,然后Emacs机智地记住了,(不知道记在什么地方),然后每次我修改完一个variable以后点击save all 就插进去了。

然而最最灵异的事情在于,我完全找不到这段配置究竟在什么地方。Mac下使用mdfind(Spotlight)也找不到,然后Emacs已经重新编译了2次了,我的配置文件已经完全换新的了,然后cache文件我已经完全删掉过很多次了,然后elpa我也重新删掉重新装了,只不过旧的那个Spacemacs的配置我没舍得删,路径在 ~/.spacemacs.d/custom.el 内容很多,既有

 '(hl-bg-colors
   (quote
    ("#7B6000" "#8B2C02" "#990A1B" "#93115C" "#3F4D91" "#00629D" "#00736F" "#546E00")))
 '(hl-fg-colors
   (quote
    ("#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36" "#002b36")))

这种灵异事件中的,也有不在灵异事件中的其他配置。总共有200多行。

我的新配置中完全没有提到一点点 Spacemacs ,绞尽脑汁也想不出来Emacs是把过去很久之前的custom 信息保存下来的。而且还是选择性地记住了。

想问问大家有什么有效的排查手段,因为这个问题我绝对每次都能复现。

两边用一样的 color-theme ?

你用 session 么?

color-theme 不一样的,我新配置里面一共用了3种不同的color-theme, 旧的就只有solarized

session用,但是保存的路径在 ~/.emacs.d/cache/.session 我都有删掉的,而且打开一看里面也没有这些奇怪的配置

内容在这

我还启用了 projectile-bookmarks.eld recentf savehist auto-save-list place abbrev 全在.cache里面

----

我再补充点内容,

  1. 自从换配置之后我就没用过老的配置,也就是说没用老配置启动过Emacs
  2. 我排查的时候确定杀掉了进程,重新编译了Emacs,删掉了所有的cache和elpa,只留下新配置文件
1 个赞

查一下是哪个包写了 custom.el:

$ ag -Q '(customize-set-variable' elpa/
$ ag -Q '(set-face-attribute' elpa/

如果没有,就是内置的包。另外还有 local variables 也会改写 custom.el。

2 个赞

遇到过类似的。应该是 color scheme 的锅,给我插进去4、5行的样子。 还好我不折腾主题,到现在还没出什么大问题。

好像 global minor mode 也会

没有找到

我也觉得是color scheme的锅,先不管了,反正现在我也不怎么用到,以后保存变量的时候注意一下就是了

配色是必须要插 custom.el 的,hl-bg-colorssolarized.el 里就有:

$ ag "hl-fg-colors" elpa-25.2.1/solarized-theme-20161222.109/
elpa-25.2.1/solarized-theme-20161222.109/solarized.el
2178:     `(hl-fg-colors '(,base03 ,base03 ,base03 ,base03 ,base03 ,base03

(custom-theme-set-variables ...) 里边一大堆东西就是为 custom.el 准备的:

This function specifies the Custom theme theme’s variable settings.

https://www.gnu.org/software/emacs/manual/html_node/elisp/Custom-Themes.html


除了前面提到 customize-set-variable 方法, 还有 custom-set-variables,可以做个测试:

(custom-set-variables '(foobar nil))
(custom-save-all)

custom.el 反正也不用维护,插就插吧,眼不见不烦。

也许 home 目录下有一些隐藏文件没有删除(有些包会往 ~/ 下面写东西)。试试新建一个干净的 tmp 目录,然后把当前的 .emacs.d 拷贝到 tmp 下面,然后进入 tmp,用 HOME=$(pwd) emacs 试着启动一下,看下问题是否还在。

谢谢各位回复,我最后通过把整个旧的spacemacs.d 文件夹搬到Dropbox里面,然后重起解决了。

这玩意儿不就是颜色主题?