Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep comments on variables set through "M-x customize" on emacs?

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?

like image 414
agentofuser Avatar asked Aug 09 '09 06:08

agentofuser


1 Answers

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.

like image 129
seth Avatar answered Oct 04 '22 15:10

seth