如何在emacs上通过“M-x customize”设置变量注释?

时间:2009-08-09 06:11:41

标签: emacs editor comments dot-emacs customization

当我通过M-x customize设置变量时,这些值会存储在我的.emacs文件中这个按字母排序的自动生成的大列中。

问题是我想记录为什么我选择特定值而不是特定变量的默认值。如果我通过在自动生成的列表中添加elisp注释来实现这一点,那么下次我自定义另一个变量时它们就会被破坏。

有没有办法让Custom保留我的评论,还是有其他标准的方法来注释?

2 个答案:

答案 0 :(得分:5)

就个人而言,我将所有设置从自定义中移出到我的.emacs文件中。主要是因为我真的不喜欢UI进行自定义。

所以,而不是这是我的自定义文件:

(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.
 '(scheme-program-name "scheme")
 '(tetris-use-glyphs nil))

我有:

 (setq
  scheme-program-name "scheme"      ; because I like it
  tetris-use-glyphs nil)            ; it's an example

那就是说custom-set-variable确实需要一些参数,其中一个是注释。所以你可以这样做:

(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.
 '(scheme-program-name "scheme" nil nil "this is a comment")
 '(tetris-use-glyphs nil nil nil "This is another comment"))

当您更改变量的值时,注释只会被吹走,而不是在您更改其他变量时。我不确定这是否适用于此。 C-h f custom-set-variables有更多信息。

答案 1 :(得分:4)

至少从22.3开始,您可以在自定义内容时添加注释。点击“状态” - > “添加评论”。这将保存在.emacs中的自定义命令中:

  

'(global-hi-lock-mode t nil nil“是的!是的是是是是!”)

(当我发现自定义时,显然我很兴奋。)