LoginSignup
6
5

More than 5 years have passed since last update.

init.elにいつの間にかcustom-set-*が追加される件

Last updated at Posted at 2017-08-18

長年、init.elにいつの間にかcustom-set-variablescustom-set-facesが追加される現象に悩まされていました。

init.elにいつの間にか追加され、削除してもまた復活する

M-x customizeをしていないにもかかわらず、
こんなかんじのコードがinit.elに追加されます。

(custom-set-variables
  '(foo "bar"))

原因

私は、init-loaderを使ってinit.elを分割しているのですが、init.el 以外 のファイルにcustom-set-variablescustom-set-facesの記述を書いていたのでした。

  • init.elが読まれる
  • init-loaderから他のファイルが読まれる
  • そのファイルにcustom-set-*が記載されている
  • これにより、customizeした状態になる
  • Emacsがcustomizeした内容をinit.elに書き戻す

というような動作になっていたと思われます。

対応

よく理解せずにネットからコピってきたコード片にcustom-set-variablescustom-set-facesがあったので、setqに置き換えたり、不要なものは削除したりしました。

これで、init.elが意図せず書き換えられる事象は解消しました。

おわりに

ずっと、Emacsがどこかに、M-x customizeしたときの情報を隠し持っていて、それをinit.elに反映しているのだと思いこんでいたので、なかなか解決に至りませんでした。

同じ事象に悩む人がひとりでも助かると幸いです。

;; init.elを分割していない人は気にしないでいいと思います。
6
5
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5