如何保留通过“Mx自定义”设置的变量的注释 在 emacs 上?

发布于 2024-07-30 11:29:27 字数 253 浏览 0 评论 0原文

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

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

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

When I set variables through M-x customize, the values are stored in this big, auto-generated, alphabetically ordered list in my .emacs file.

The problem is I like to document why I chose a particular value other than the default for a particular variable. If I do that by adding elisp comments inside the auto-generated list, they are clobbered next time I customize another variable.

Is there a way to make Custom keep my comments, or is there some other standard way of annotating this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮是我掰弯的 2024-08-06 11:29:27

就我个人而言,我将所有设置从自定义中移至我的 .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.
 '(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"))

只有当你改变变量的值时,注释才会消失,而当你改变其他变量时,注释不会消失。 但我不确定这是否是正确的用法。 Ch f custom-set-variables 有更多信息。

Personally, I moved all of my settings out of customize and into my .emacs file. Mostly because I really dislike the UI for customize.

So, instead of this is my custom file:

(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))

I have:

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

That being said custom-set-variable does take a number of arguments, one of which is a comment. So you could do:

(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"))

The comment will only get blown away when you change the value of the variable, not when you change other variables. I'm not sure that this is the proper usage for this though. C-h f custom-set-variables has more info.

小耗子 2024-08-06 11:29:27

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

'(global-hi-lock-mode t nil nil "是!是是是是是是!")

(显然,当我发现这种定制时,我很兴奋。)

At least since 22.3, you can include a comment when you customize something. Click "State" -> "Add comment". This is saved in the customization commands in your .emacs:

'(global-hi-lock-mode t nil nil "Yes! Yes yes yes yes YES!")

(Apparently I was excited when I found that customization.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文