我的.emacs文件中的custom-set-variables和faces是什么?

35

这是我在.emacs文件中的内容,我能够更改它吗?

(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.
 )
(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.
 '(better-fringes-bitmap ((t (:foreground "#00dd44"))))
 '(font-lock-string-face ((((class color) (min-colors 88) (background light)) (:foreground "#113355")))))

到目前为止,我在这些行的上方添加了我想要的一切...

3个回答

71

正如Noufal所指出的那样,这些块是通过customize界面添加的。你可以将它们移动到单独的文件中,如果你喜欢的话。

只需将此内容添加到您的~/.emacs.d/init.el

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)

或者,如果你仍在使用老式的~/.emacs文件:

(setq custom-file "~/.custom.el")
(load custom-file)

一个更加复杂的代码片段,可以在任何情况下都能够使用:

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)

7
请查看这个问题,了解为什么称之为“老派”。 - jan-glx
“老式的~/.emacs文件”是什么意思?现在有没有其他更好的方法来使用~/.emacs呢? - HelloGoodbye
是的,现在惯例是有一个 ~/.emacs.d 目录,其中包含一个名为 init.el 的启动文件,它的工作方式类似于 ~/.emacs。这样,即使配置被拆分成多个文件,您也可以将其放置在一个自包含的位置中,并且如果存在,安装的 elisp 包也会被放置在该目录中。jan-glx 上面的评论提供了更多信息的链接。 - sanityinc
1
不要硬编码 ~/emacs.d/,我认为最好使用 expand-file-name(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) - Mohammad Banisaeid
1
@MohammadBanisaeid 总的来说,我同意,但我认为如果你有一个~/.emacs文件,那么user-emacs-directory将会是~,因此总体效果不会很一致/明确。我会编辑答案以反映这一点。 - sanityinc

17

当使用自定义系统时,这些行会添加到文件中。当您使用customize-*时,它们会被生成。默认情况下,自定义选项存储在.emacs文件中。通常不会手动编辑这些文件。您必须使用customize-*命令来进行编辑。


11

不要手动向这些行添加任何内容——因为在某些事件发生时,emacs 会将您的更改清除。相反,请使用customize-set-variable添加自定义变量和set-face-attribute添加自定义面:

(customize-set-variable 'blink-cursor-mode nil)
(set-face-attribute 'default nil :family "DejaVu Sans Mono")

有时为了自定义某个包的外观,需要先请求该包,然后设置其外观:

(require 'mumamo)
(set-face-attribute 'mumamo-background-chunk-major nil :background nil)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接