From b74e9dfcf9c67455223b2a3be99692669b3b5205 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Fri, 10 Sep 2021 13:35:50 +0000 Subject: [PATCH] Warn when custom variable is wrongly set. * src/eval.c (Fsetq): Display warning when a custom variable with a :set property is set with setq. Warnings are displayed only for custom variables whose files have been loaded and that have a :set property. No warnings are displayed for custom variables whose files have merely been preloaded, for custom variables that do not have a :set property, and for non-custom variables. See bug#21695. --- src/eval.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 48104bd0f4..168a7749a0 100644 --- a/src/eval.c +++ b/src/eval.c @@ -525,8 +525,15 @@ DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0, : 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. */ + } } return val; -- 2.33.0