From ecbd4b75677500d828719f2b64688619ef74fa28 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 20 May 2020 01:05:27 -0400 Subject: [PATCH] Fix setq! not triggering setters Because the setters were looked up at expansion/compile time (much, much too early), rather than at runtime. This should indirectly fix "No year zero" errors for org-journal users (#3173). --- core/core-lib.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/core-lib.el b/core/core-lib.el index a4680456e..380c3918e 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -272,14 +272,13 @@ See `if!' for details on this macro's purpose." (defmacro setq! (&rest settings) "A stripped-down `customize-set-variable' with the syntax of `setq'. -Use this instead of `setq' when you know a variable has a custom setter (a :set -property in its `defcustom' declaration). This trigger setters. `setq' does -not." +This can be used as a drop-in replacement for `setq'. Particularly when you know +a variable has a custom setter (a :set property in its `defcustom' declaration). +This triggers setters. `setq' does not." (macroexp-progn (cl-loop for (var val) on settings by 'cddr - collect (list (or (get var 'custom-set) #'set) - (list 'quote var) - val)))) + collect `(funcall (or (get ',var 'custom-set) #'set) + ',var ,val)))) (defmacro delq! (elt list &optional fetcher) "`delq' ELT from LIST in-place.