]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/loadup.el: Add workaround for occasional "bootstrap" failure
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 16 May 2024 13:50:39 +0000 (09:50 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sat, 18 May 2024 18:51:05 +0000 (20:51 +0200)
(cherry picked from commit ee3ef57c24fe3435cd896e1f096aadff5f9372a0)

lisp/loadup.el

index 7c67df9fade78b1e56e4a1bb5009968559761e99..b8844ea042c5448f08b1cbdb9779029c53d6cc4c 100644 (file)
   (setq definition-prefixes new))
 
 (load "button")                  ;After loaddefs, because of define-minor-mode!
+
+(when (interpreted-function-p (symbol-function 'add-hook))
+  ;; `subr.el' is needed early and hence can't use macros like `setf'
+  ;; liberally.  Yet, it does use such macros in code that it knows will not
+  ;; be executed too early, such as `add-hook'.  Usually, by the time we
+  ;; run that code, either `subr.el' was already compiled to start with
+  ;; or on the contrary many files aren't compiled yet and have thus caused
+  ;; macro packages like `gv' to be loaded.  But not always.
+  ;; The specific error we're trying to work around, here, occurs when
+  ;; `cl-preloaded's `provide' ends up (because of an `eval-after-load')
+  ;; calling `add-hook' which burps with a "void-function setf" on
+  ;; (setf (get hook 'hook--depth-alist) depth-sym)'.
+  ;; FIXME: We should probably split `subr.el' into one that's loaded early
+  ;; where we refrain from using macros like `setf', and another loaded later
+  ;; where we can blissfully `require' packages like `gv'.
+  (require 'gv))
+
 (load "emacs-lisp/cl-preloaded")
 (load "emacs-lisp/oclosure")          ;Used by cl-generic
 (load "obarray")        ;abbrev.el is implemented in terms of obarrays.