GNU bug report logs - #21695
25.0.50; Change most occurrences of `setq' in Emacs manual to `customize-set-variable'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Fri, 16 Oct 2015 21:51:01 UTC

Severity: wishlist

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #158 received at 21695 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: larsi <at> gnus.org, hmelman <at> gmail.com, 21695 <at> debbugs.gnu.org, rms <at> gnu.org
Subject: Re: bug#21695: 25.0.50;
 Change most occurrences of `setq' in Emacs manual to
 `customize-set-variable'? Really?
Date: Sun, 12 Sep 2021 11:57:50 +0300
> Date: Sun, 12 Sep 2021 08:23:01 +0000
> From: Gregory Heytings <gregory <at> heytings.org>
> Cc: 21695 <at> debbugs.gnu.org, hmelman <at> gmail.com, Richard Stallman <rms <at> gnu.org>
> 
> +--
> +** 'setq' displays a warning when 'customize-set-variable' should have been used.
> +Some custom variables need to be set with 'customize-set-variable', because
> +they were designed to be set through the Customization interface and have a
> +:set lambda form which does other things after they have been set.

I thought the conclusion was that most variables with :set can be
safely set by setq, isn't that so?  If so, these warnings will mostly
annoy.

> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -525,8 +525,15 @@ usage: (setq [SYM VAL]...)  */)
>  	   : Qnil);
>        if (!NILP (lex_binding))
>  	XSETCDR (lex_binding, val); /* SYM is lexically bound.  */
> -      else
> +      else {
> +	if (!NILP (Fget (sym, intern ("custom-set"))))
> +	  call2 (intern ("display-warning"), intern ("setq"),
> +		 CALLN (Fformat,
> +			build_string
> +			("`%s' should be set with `customize-set-variable'"),
> +			sym));
>  	Fset (sym, val);	/* SYM is dynamically bound.  */
> +      }

What will happen if setq is in the user's init file?  We generally
delay warnings until after the startup in those cases.

Also, warnings.el is not preloaded, so this call could barf in some
valid cases.  OTOH, setq is a primitive written in C, so ther should
be no need to call intern for it.

And finally, do we really want to slow down each setq by calling
intern and Fget?  setq is many times used inside tight loops.  I'm not
sure the resulting run-time penalty is justified.  Did you measure the
effect of this on performance?




This bug report was last modified 3 years and 302 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.