emacs-devel
[Top][All Lists]
Advanced

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

custom-set-variables considered harmful


From: Stefan Monnier
Subject: custom-set-variables considered harmful
Date: Sat, 04 Nov 2017 13:10:11 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

I keep seeing people copy and pasting part of calls to
custom-set-variables, and getting all confused about it.

I think we should stop using it.  Here's a proposal for that.

When writing customizations, instead of writing

    (custom-set-variables
     ;; Big ugly warning which doesn't help enough.
     '(VAR1 VAL1)
     '(VAR2 VAL2 nil '(REQUEST) COMMENT)
     '(VAR3 VAL3)
     ...)

we write

    (autogenerated-custom-settings
      ;; Big warning, still, but less important.
      (setq VAR1 VAL1)
      (require 'REQUEST)
      (customize-set-variable VAR2 VAL2 COMMENT)
      (customize-set-variable VAR3 VAL3)
      ...)

where `autogenerated-custom-settings` is a macro which turns that call
back into the form expected by custom-set-variables.

The idea is basically to use a syntax which happens to look close to
what you'd write by hand if you weren't using Customize, so that users
who copy&paste snippets of code end up copying more or less valid code,
instead of copying "code" like

    '(toto 2)

and then be surprised that it doesn't do anything.

[ The difference between VAR1 and VAR3 is that VAR1 doesn't have
  a setter.  I guess in some cases we should emit `(setq-default VAR VAL)`
  also.  ]

One question, tho: could someone explain to me what the NOW is used
for, really?  I've read the docstrings, comments, and the code that
seems related to it, and I have some idea of what it supposedly does,
but I don't have a clear idea of a scenario where it's used.


        Stefan



reply via email to

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