From: Stefan Monnier Date: Thu, 22 Apr 2021 13:32:04 +0000 (-0400) Subject: Fix unload+reload of files using `custom-initialize-delay` (bug#47072) X-Git-Tag: emacs-28.0.90~2779 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2fb271ca35ff96540c0940b0ea5281bdaac953ec;p=emacs.git Fix unload+reload of files using `custom-initialize-delay` (bug#47072) * lisp/custom.el (custom-initialize-delay): Don't delay if `custom-delayed-init-variables` has already been processed. * lisp/startup.el (command-line): Mark `custom-delayed-init-variables` as processed. --- diff --git a/lisp/custom.el b/lisp/custom.el index 2c9eadbd479..614f8cf822d 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -117,9 +117,10 @@ For the standard setting, use `set-default'." (set-default symbol (eval exp))))))) (defvar custom-delayed-init-variables nil - "List of variables whose initialization is pending.") + "List of variables whose initialization is pending until startup. +Once this list has been processed, this var is set to a non-list value.") -(defun custom-initialize-delay (symbol _value) +(defun custom-initialize-delay (symbol value) "Delay initialization of SYMBOL to the next Emacs start. This is used in files that are preloaded (or for autoloaded variables), so that the initialization is done in the run-time @@ -133,7 +134,11 @@ the :set function." ;; This seemed to be at least as good as setting it to an arbitrary ;; value like nil (evaluating `value' is not an option because it ;; may have undesirable side-effects). - (push symbol custom-delayed-init-variables)) + (if (listp custom-delayed-init-variables) + (push symbol custom-delayed-init-variables) + ;; In case this is called after startup, there is no "later" to which to + ;; delay it, so initialize it "normally" (bug#47072). + (custom-initialize-reset symbol value))) (defun custom-declare-variable (symbol default doc &rest args) "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments. diff --git a/lisp/startup.el b/lisp/startup.el index 4d4c65e6c41..c1267274d92 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1175,7 +1175,7 @@ please check its value") ;; are dependencies between them. (nreverse custom-delayed-init-variables)) (mapc #'custom-reevaluate-setting custom-delayed-init-variables) - (setq custom-delayed-init-variables nil) + (setq custom-delayed-init-variables t) ;; Warn for invalid user name. (when init-file-user