From 5039f79340c408f26f9fb606ce29e72afc2fb01d Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 14 Jan 2021 16:45:40 -0500 Subject: [PATCH] Fix marking "delayed-initialization" vars as dynamically scoped We used to mark those vars as dynbound in `custom-reevaluate-setting` which forced us to bind `current-load-list` around it to avoid having the vars be associated with the wrong file. Move this marking to `custom-initialize-delay` so we don't need this workaround. * lisp/custom.el (custom-initialize-delay): Mark the var as dynamic. (custom-reevaluate-setting): Don't use `defvar` here. * lisp/startup.el (command-line): Don't let-bind `current-load-list` around calls to `custom-reevaluate-setting`. --- lisp/custom.el | 11 ++++++----- lisp/startup.el | 16 +++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/lisp/custom.el b/lisp/custom.el index 0c82df9b45e..58ecd0439ad 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -136,6 +136,9 @@ to include all of it." ; see eg vc-sccs-search-project-dir ;; No longer true: ;; "See `send-mail-function' in sendmail.el for an example." + ;; Defvar it so as to mark it special, etc (bug#25770). + (internal--define-uninitialized-variable symbol) + ;; Until the var is actually initialized, it is kept unbound. ;; 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 @@ -780,8 +783,7 @@ Return non-nil if the `customized-value' property actually changed." Use the :set function to do so. This is useful for customizable options that are defined before their standard value can really be computed. E.g. dumped variables whose default depends on run-time information." - ;; If it has never been set at all, defvar it so as to mark it - ;; special, etc (bug#25770). This means we are initializing + ;; We are initializing ;; the variable, and normally any :set function would not apply. ;; For custom-initialize-delay, however, it is documented that "the ;; (delayed) initialization is performed with the :set function". @@ -789,11 +791,10 @@ E.g. dumped variables whose default depends on run-time information." ;; custom-initialize-delay but needs the :set function custom-set-minor-mode ;; to also run during initialization. So, long story short, we ;; always do the funcall step, even if symbol was not bound before. - (or (default-boundp symbol) - (eval `(defvar ,symbol nil))) ; reset below, so any value is fine (funcall (or (get symbol 'custom-set) #'set-default) symbol - (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value)))))) + (eval (car (or (get symbol 'saved-value) + (get symbol 'standard-value)))))) ;;; Custom Themes diff --git a/lisp/startup.el b/lisp/startup.el index cc14fb28140..0ad5c2f1796 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1167,12 +1167,11 @@ please check its value") ;; Re-evaluate predefined variables whose initial value depends on ;; the runtime context. - (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH - (setq custom-delayed-init-variables - ;; Initialize them in the same order they were loaded, in case there - ;; are dependencies between them. - (nreverse custom-delayed-init-variables)) - (mapc 'custom-reevaluate-setting custom-delayed-init-variables)) + (setq custom-delayed-init-variables + ;; Initialize them in the same order they were loaded, in case there + ;; are dependencies between them. + (nreverse custom-delayed-init-variables)) + (mapc #'custom-reevaluate-setting custom-delayed-init-variables) ;; Warn for invalid user name. (when init-file-user @@ -1315,9 +1314,8 @@ please check its value") ;; Re-evaluate again the predefined variables whose initial value ;; depends on the runtime context, in case some of them depend on ;; the window-system features. Example: blink-cursor-mode. - (let (current-load-list) ; c-r-s may call defvar, and hence LOADHIST_ATTACH - (mapc 'custom-reevaluate-setting custom-delayed-init-variables) - (setq custom-delayed-init-variables nil)) + (mapc #'custom-reevaluate-setting custom-delayed-init-variables) + (setq custom-delayed-init-variables nil) (normal-erase-is-backspace-setup-frame) -- 2.39.5