[Top][All Lists]

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

Re: custom-set-variables considered harmful

From: Elias Mårtenson
Subject: Re: custom-set-variables considered harmful
Date: Wed, 29 Nov 2017 11:36:21 +0800

On 28 November 2017 at 22:12, Philippe Vaucher <address@hidden> wrote:

Note that as long as the `setq` is within the magical
custom-autogenerated-user-settings form, it will behave correctly even
if the variable has a setter function.  The difference will only affect
those users who take this code and then copy it elsewhere.

But setq doesn't have any concrete benefit other than familiarity to people who don't understand custom. I've spent more time than I wish on Freenode #emacs teaching people about custom. If c-s-v was used consistently that effort would be made a lot easier. 

The problem I have with c-s-v is that I don't see its benefits for configs like this:
[ lines of ‘setq’ invocations on ido variables ]

Can you maybe enlighten me about what problem c-s-v solves that would have me start to use it?

Your explicit ‘setq’ calls are perfectly fine as long as the variables you set do not have a setting function
assigned to them. However, if they do have setter functions, then the behaviour will not be correct.
It has been suggested that you manually look at the ‘defcustom’ definitions of the variables so that
you know which ones doesn't work with ‘setq’.

The only reason people can get away with not doing this is because there are so few custom variables
that use setter functions.

Thus, if you use ‘setq’ instead of ‘custom-set-variable’ you need to manually check every single
variable to ensure they don't have setter functions assigned. If you want to be thorough (nobody is)
you also need to check them every time your modules are updated. This is not just a theoretical
situation. It happened in gnu-apl-mode, a library for which I am the maintainer. In it, the
variable ‘gnu-apl-mode-map-prefix’ got a setter function after the fact.

Or, you could simply use ‘custom-set-variable’ everywhere and spare yourself the trouble.


reply via email to

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