From 50d1e07ab098c3c98259f435167cb1cb4bfeb3b5 Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Thu, 9 Sep 2021 11:40:50 +0000 Subject: [PATCH] Warn when defcustom is wrongly set. * src/eval.c (Fsetq): Display warning when a custom variable with a :set property is set with setq. --- src/eval.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 48104bd0f4..b72577e791 100644 --- a/src/eval.c +++ b/src/eval.c @@ -525,8 +525,16 @@ 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 ("initialization"), + CALLN (Fformat, + build_string + ("`%s' should be set with `customize-set-variable', not `setq'"), + sym)); Fset (sym, val); /* SYM is dynamically bound. */ + } } return val; -- 2.33.0