[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 49910adf87 3/6: Fix cl-generic bootstrap problems
From: |
Lars Ingebrigtsen |
Subject: |
master 49910adf87 3/6: Fix cl-generic bootstrap problems |
Date: |
Fri, 24 Jun 2022 05:05:00 -0400 (EDT) |
branch: master
commit 49910adf872a98d9c144d34478a53ecb3e01856f
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Fix cl-generic bootstrap problems
* lisp/sqlite-mode.el (require):
* lisp/net/eudc.el (require):
* lisp/arc-mode.el (require): Require subr-x, since these files
are using macros from there.
* lisp/emacs-lisp/subr-x.el (with-memoization): Move from here...
* lisp/subr.el (with-memoization): ... to here, as it's used from
the preloaded cl-generic.el file.
* lisp/emacs-lisp/cl-generic.el (cl--generic-compiler): Don't use
the autoloaded `byte-compile' function during bootstrap.
(cl--generic-get-dispatcher): Don't require subr-x, either.
cl-generic has been preloaded since 2015, and most usages of it (in
preloaded files) work fine. In particular, using `cl-defgeneric' is
unproblematic. However, `cl-defmethod' would end up pulling in the
byte compiler (at load time), which would make it impossible to use
`cl-defmethod' in pre-loaded files, and this change fixes that (but
possibly not in the most self-evidently correct way).
---
lisp/arc-mode.el | 1 +
lisp/emacs-lisp/cl-generic.el | 9 ++++-----
lisp/emacs-lisp/subr-x.el | 13 -------------
lisp/net/eudc.el | 1 +
lisp/sqlite-mode.el | 1 +
lisp/subr.el | 12 ++++++++++++
test/lisp/custom-tests.el | 1 +
test/lisp/emacs-lisp/cconv-tests.el | 1 +
8 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 1c5faa1152..c52f2a4432 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -101,6 +101,7 @@
;;; Code:
(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'subr-x))
;; -------------------------------------------------------------------------
;;; Section: Configuration.
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 200af057cd..6c5813959f 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -658,8 +658,10 @@ The set of acceptable TYPEs (also called \"specializers\")
is defined
;; compiled. Otherwise the byte-compiler and all the code on
;; which it depends needs to be usable before cl-generic is loaded,
;; which imposes a significant burden on the bootstrap.
- (if (consp (lambda (x) (+ x 1)))
- (lambda (exp) (eval exp t)) #'byte-compile))
+ (if (or (consp (lambda (x) (+ x 1)))
+ (not (featurep 'bytecomp)))
+ (lambda (exp) (eval exp t))
+ #'byte-compile))
(defun cl--generic-get-dispatcher (dispatch)
(with-memoization
@@ -708,9 +710,6 @@ The set of acceptable TYPEs (also called \"specializers\")
is defined
(funcall
cl--generic-compiler
`(lambda (generic dispatches-left methods)
- ;; FIXME: We should find a way to expand `with-memoize' once
- ;; and forall so we don't need `subr-x' when we get here.
- (eval-when-compile (require 'subr-x))
(let ((method-cache (make-hash-table :test #'eql)))
(lambda (,@fixedargs &rest args)
(let ,bindings
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 5c3dff62c8..b0de5d155a 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -290,19 +290,6 @@ as the new values of the bound variables in the recursive
invocation."
(cl-labels ((,name ,fargs . ,body)) #',name)
. ,aargs)))
-(defmacro with-memoization (place &rest code)
- "Return the value of CODE and stash it in PLACE.
-If PLACE's value is non-nil, then don't bother evaluating CODE
-and return the value found in PLACE instead."
- (declare (indent 1) (debug (gv-place body)))
- (gv-letplace (getter setter) place
- `(or ,getter
- ,(macroexp-let2 nil val (macroexp-progn code)
- `(progn
- ,(funcall setter val)
- ,val)))))
-
-
;;;###autoload
(defun string-pixel-width (string)
"Return the width of STRING in pixels."
diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el
index 808d2ca509..1d9dbbeb75 100644
--- a/lisp/net/eudc.el
+++ b/lisp/net/eudc.el
@@ -48,6 +48,7 @@
(require 'wid-edit)
(require 'cl-lib)
(require 'eudc-vars)
+(eval-when-compile (require 'subr-x))
;;{{{ Internal cooking
diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el
index 66e2e487d9..fb2ceab383 100644
--- a/lisp/sqlite-mode.el
+++ b/lisp/sqlite-mode.el
@@ -24,6 +24,7 @@
;;; Code:
(require 'cl-lib)
+(eval-when-compile (require 'subr-x))
(declare-function sqlite-execute "sqlite.c")
(declare-function sqlite-more-p "sqlite.c")
diff --git a/lisp/subr.el b/lisp/subr.el
index 04eec977bb..075bfb95b7 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6912,4 +6912,16 @@ CONDITION."
(push buf bufs)))
bufs))
+(defmacro with-memoization (place &rest code)
+ "Return the value of CODE and stash it in PLACE.
+If PLACE's value is non-nil, then don't bother evaluating CODE
+and return the value found in PLACE instead."
+ (declare (indent 1) (debug (gv-place body)))
+ (gv-letplace (getter setter) place
+ `(or ,getter
+ ,(macroexp-let2 nil val (macroexp-progn code)
+ `(progn
+ ,(funcall setter val)
+ ,val)))))
+
;;; subr.el ends here
diff --git a/test/lisp/custom-tests.el b/test/lisp/custom-tests.el
index 77bb337d6a..d1effaa72a 100644
--- a/test/lisp/custom-tests.el
+++ b/test/lisp/custom-tests.el
@@ -24,6 +24,7 @@
(require 'wid-edit)
(require 'cus-edit)
+(require 'bytecomp)
(ert-deftest custom-theme--load-path ()
"Test `custom-theme--load-path' behavior."
diff --git a/test/lisp/emacs-lisp/cconv-tests.el
b/test/lisp/emacs-lisp/cconv-tests.el
index 0668e44ba5..9904c6a969 100644
--- a/test/lisp/emacs-lisp/cconv-tests.el
+++ b/test/lisp/emacs-lisp/cconv-tests.el
@@ -24,6 +24,7 @@
(require 'ert)
(require 'cl-lib)
(require 'generator)
+(require 'bytecomp)
(ert-deftest cconv-tests-lambda-:documentation ()
"Docstring for lambda can be specified with :documentation."
- master updated (c148bfc229 -> e193ea3c34), Lars Ingebrigtsen, 2022/06/24
- master 2ff5cb4cb4 2/6: Make warning about require/autoload while bootstrapping not error out, Lars Ingebrigtsen, 2022/06/24
- master f2b7525e38 5/6: Preload seq, Lars Ingebrigtsen, 2022/06/24
- master bed9fd41ef 4/6: Allow read-multiple-choice to do long-form answers, Lars Ingebrigtsen, 2022/06/24
- master e193ea3c34 6/6: Allow `kill-buffer' query to save the buffer first, Lars Ingebrigtsen, 2022/06/24
- master bd1f20eea1 1/6: Make debug-early-backtrace more resilient, Lars Ingebrigtsen, 2022/06/24
- master 49910adf87 3/6: Fix cl-generic bootstrap problems,
Lars Ingebrigtsen <=