help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: which one to use: custom-set-variables, customize-set-variable, or c


From: Drew Adams
Subject: RE: which one to use: custom-set-variables, customize-set-variable, or customize-set-value?
Date: Fri, 11 Dec 2015 10:53:30 -0800 (PST)

> After reading this thread, as well as the referenced
> http://permalink.gmane.org/gmane.emacs.bugs/107690, I tried to see if I
> should
> rectify some settings in my own init file. Indeed, I was using `setq' on a
> bunch of customizable options...
> 
> Given that checking each variable documentation to see the right way to
> set its value is error prone, I wrote the following macro and used it in
> almost all cases, replacing `setq' and `set-default' in my configuration:
> 
>     (defmacro csetq (variable value)
>       "Macro to set the value of a variable, possibly a custom user
> option."
>       `(funcall (or (get ',variable 'custom-set)
>                     (and (plist-member (symbol-plist ',variable)
> 'standard-value) 'set-default)
>                     'set)
>                 ',variable ,value))
> 
> While it seems working as expected, I like to hear other's opinion: do you
> see any problem with this approach?

You can do that.  But I would advise just using `customize-set-variable'
for a user option, and using `setq' or `setq-default' etc. for non-options.

That is much more readable in your code, IMO.

And no, you do not ever need to "check each variable documentation to
see the right way to set its value".  (And you should anyway not rely
on a variable's documentation for that.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]