[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 08a673a8eb: Revert "Simplify loading and compili
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 08a673a8eb: Revert "Simplify loading and compiling of Compat" |
Date: |
Mon, 11 Jul 2022 16:57:26 -0400 (EDT) |
branch: externals/compat
commit 08a673a8eb713374d18bae1b52e34fecd5b6733f
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Revert "Simplify loading and compiling of Compat"
This reverts commit 0c4af13dde7eb9980b636eae42954a9dfea31ba9.
---
compat-macs.el | 31 ++++++++++-------------
compat.el | 78 +++++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 76 insertions(+), 33 deletions(-)
diff --git a/compat-macs.el b/compat-macs.el
index a2de41da7b..85f31b8804 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -29,17 +29,6 @@
"Ignore all arguments."
nil)
-(defvar compat--inhibit-prefixed nil
- "Non-nil means that prefixed definitions are not loaded.
-A prefixed function is something like `compat-assoc', that is
-only made visible when the respective compatibility version file
-is loaded (in this case `compat-26').")
-
-(defmacro compat--inhibit-prefixed (&rest body)
- "Ignore BODY unless `compat--inhibit-prefixed' is true."
- `(unless (bound-and-true-p compat--inhibit-prefixed)
- ,@body))
-
(defvar compat--generate-function #'compat--generate-minimal
"Function used to generate compatibility code.
The function must take six arguments: NAME, DEF-FN, INSTALL-FN,
@@ -95,6 +84,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(cond (plist-get attr :cond))
(version ; If you edit this, also edit `compat--generate-verbose'.
(or (plist-get attr :version)
+ (bound-and-true-p compat--entwine-version)
(let* ((file (car (last current-load-list)))
(file (if (stringp file)
;; Some library, which requires compat-XY.el,
@@ -102,9 +92,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
;; been compiled yet.
file
;; compat-XY.el is being compiled.
- (or (bound-and-true-p byte-compile-current-file)
- ;; Fallback to the buffer being evaluated.
- (buffer-file-name)))))
+ (bound-and-true-p byte-compile-current-file))))
(if (and file
(string-match
"compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
@@ -119,7 +107,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(version< max-version emacs-version)))
'(compat--ignore))
((plist-get attr :prefix)
- '(compat--inhibit-prefixed))
+ '(progn))
((and version (version<= version emacs-version) (not cond))
'(compat--ignore))
(`(when (and ,(if cond cond t)
@@ -155,6 +143,13 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
`(eval-after-load ,feature `(funcall ',(lambda () ,body)))
body))))))
+(defun compat--generate-minimal-no-prefix (name def-fn install-fn check-fn
attr type)
+ "Generate a leaner compatibility definition.
+See `compat-generate-function' for details on the arguments NAME,
+DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
+ (unless (plist-get attr :prefix)
+ (compat--generate-minimal name def-fn install-fn check-fn attr type)))
+
(defun compat--generate-verbose (name def-fn install-fn check-fn attr type)
"Generate a more verbose compatibility definition, fit for testing.
See `compat-generate-function' for details on the arguments NAME,
@@ -165,11 +160,11 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(cond (plist-get attr :cond))
(version ; If you edit this, also edit `compat--generate-minimal'.
(or (plist-get attr :version)
+ (bound-and-true-p compat--entwine-version)
(let* ((file (car (last current-load-list)))
(file (if (stringp file)
file
- (or (bound-and-true-p byte-compile-current-file)
- (buffer-file-name)))))
+ (bound-and-true-p byte-compile-current-file))))
(if (and file
(string-match
"compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
@@ -198,7 +193,7 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(version< max-version emacs-version)))
'(compat--ignore))
((plist-get attr :prefix)
- '(compat--inhibit-prefixed))
+ '(progn))
((and version (version<= version emacs-version) (not cond))
'(compat--ignore))
(`(when (and ,(if cond cond t)
diff --git a/compat.el b/compat.el
index b8e5e93898..9484211879 100644
--- a/compat.el
+++ b/compat.el
@@ -41,21 +41,69 @@
(eval-when-compile (require 'compat-macs))
-;; We load all the components of Compat with a copied value of
-;; `features' list, that will prevent the list being modified, and all
-;; the files can be loaded again. This is done so that
-;; `compat--inhibit-prefixed' can take effect when loading `compat',
-;; and do nothing when loading each sub-feature manually.
-
-(defvar compat--inhibit-prefixed)
-(let* ((features (copy-sequence features))
- (compat--inhibit-prefixed t))
- (ignore features) ;for the byte compiler
- (load "compat-24")
- (load "compat-25")
- (load "compat-26")
- (load "compat-27")
- (load "compat-28"))
+;;;; Core functionality
+
+;; To accelerate the loading process, we insert the contents of
+;; compat-N.M.el directly into the compat.elc. Note that by default
+;; this will not include prefix functions. These have to be required
+;; separately, by explicitly requiring the feature that defines them.
+(eval-when-compile
+ (defvar compat--generate-function)
+ (defvar compat--entwine-version)
+ (defmacro compat-entwine (version)
+ (cond
+ ((or (not (eq compat--generate-function 'compat--generate-minimal))
+ (bound-and-true-p compat-testing))
+ `(load ,(format "compat-%d.el" version)))
+ ((let* ((compat--generate-function 'compat--generate-minimal-no-prefix)
+ (file (expand-file-name
+ (format "compat-%d.el" version)
+ (file-name-directory
+ (or
+ ;; Some third-party library, which requires
+ ;; compat.el, is being compiled, loaded or
+ ;; evaluated, and compat.el hasn't been compiled
+ ;; yet.
+ ;; cd compat && make clean && cd ../other && \
+ ;; make clean all
+ ;;
+ ;; Or compat.el is being evaluated.
+ ;; cd compat && make clean && emacs -Q -L . compat.el
+ ;; M-x eval-buffer
+ ;;
+ ;; (Like `macroexp-file-name' from Emacs 28.1.)
+ (let ((file (car (last current-load-list))))
+ (and (stringp file) file))
+ ;; compat.el is being compiled.
+ ;; cd compat && make clean all
+ (bound-and-true-p byte-compile-current-file)))))
+ (compat--entwine-version (number-to-string version))
+ defs)
+ (with-temp-buffer
+ (insert-file-contents file)
+ (emacs-lisp-mode)
+ (while (progn
+ (forward-comment 1)
+ (not (eobp)))
+ (let ((form (read (current-buffer))))
+ (cond
+ ((memq (car-safe form)
+ '(compat-defun
+ compat-defmacro
+ compat-advise
+ compat-defvar))
+ (push (macroexpand-all form) defs))
+ ((memq (car-safe form)
+ '(declare-function
+ defvar))
+ (push form defs))))))
+ (macroexp-progn (nreverse defs)))))))
+
+(compat-entwine 24)
+(compat-entwine 25)
+(compat-entwine 26)
+(compat-entwine 27)
+(compat-entwine 28)
(provide 'compat)
;;; compat.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/compat 08a673a8eb: Revert "Simplify loading and compiling of Compat",
ELPA Syncer <=