[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 7737bb9d56 08/16: Run all checks at compile time
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 7737bb9d56 08/16: Run all checks at compile time |
Date: |
Wed, 4 Jan 2023 07:57:27 -0500 (EST) |
branch: externals/compat
commit 7737bb9d565c102caeb2bed0c672a98008dc8c9a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Run all checks at compile time
---
compat-macs.el | 44 +++++++++++++++++++++++---------------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/compat-macs.el b/compat-macs.el
index c06fc00d8f..78428425e2 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -29,13 +29,13 @@
(setq compat--current-version version)
nil)
-(defun compat--with-feature (feature body)
+(defun compat--with-feature (feature &rest body)
"Protect BODY with `eval-after-load' if FEATURE is non-nil."
(declare (indent 1))
(if feature
;; See https://nullprogram.com/blog/2018/02/22/:
- `(eval-after-load ',feature `(funcall ',(lambda () ,body)))
- body))
+ `(eval-after-load ',feature `(funcall ',(lambda () ,@body)))
+ (macroexp-progn body)))
(defun compat--generate (name def-fn install-fn check-fn attr)
"Function used to generate compatibility code.
@@ -79,18 +79,10 @@ ignored:
(cond (plist-get attr :cond))
(version (or (plist-get attr :version)
compat--current-version))
- (check (cond
- ((or (and min-version
- (version< emacs-version min-version))
- (and max-version
- (version< max-version emacs-version)))
- nil)
- ((plist-get attr :explicit)
- '(progn))
- ((and version (version<= version emacs-version) (not cond))
- nil)
- (`(when (and ,(if cond cond t)
- ,(funcall check-fn)))))))
+ (check))
+ (when (and (plist-get attr :realname)
+ (string= name (plist-get attr :realname)))
+ (error "%S: Name is equal to realname" name))
;; We always require subr-x for the check since many functions have been
;; moved around
(when (eq feature 'subr-x)
@@ -99,9 +91,19 @@ ignored:
(when feature
(unless (require feature nil t)
(setq feature nil)))
- (when (and (plist-get attr :realname)
- (string= name (plist-get attr :realname)))
- (error "%S: Name is equal to realname" name))
+ (setq check
+ (cond
+ ((or (and min-version
+ (version< emacs-version min-version))
+ (and max-version
+ (version< max-version emacs-version)))
+ nil)
+ ((plist-get attr :explicit)
+ t)
+ ((and version (version<= version emacs-version) (not cond))
+ nil)
+ ((and (if cond (eval cond t) t)
+ (funcall check-fn)))))
(cond
((and (plist-get attr :explicit)
(let ((actual-name (intern (substring (symbol-name name)
@@ -110,17 +112,17 @@ ignored:
(fboundp actual-name)
check)
(compat--with-feature feature
- `(,@check ,(funcall install-fn actual-name version)))))))
+ (funcall install-fn actual-name version))))))
((let ((realname (plist-get attr :realname)))
(when realname
`(progn
,(funcall def-fn realname version)
,(when check
(compat--with-feature feature
- `(,@check ,(funcall install-fn realname version))))))))
+ (funcall install-fn realname version)))))))
(check
(compat--with-feature feature
- `(,@check ,(funcall def-fn name version)))))))
+ (funcall def-fn name version))))))
(defun compat--define-function (type name arglist docstring rest)
"Generate compatibility code for a function NAME.
- [elpa] externals/compat updated (3ee973db10 -> 0bb4709d83), ELPA Syncer, 2023/01/04
- [elpa] externals/compat 601387077a 04/16: Always require subr-x at compile time, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 9ecaf46e15 09/16: Restore explicit versions of string-trim, ELPA Syncer, 2023/01/04
- [elpa] externals/compat dab2ec091d 01/16: Restore tests, ELPA Syncer, 2023/01/04
- [elpa] externals/compat de7346396a 05/16: Add compat-feature macro, ELPA Syncer, 2023/01/04
- [elpa] externals/compat d18955c1be 07/16: Remove comments, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 8ebf7984ce 06/16: Revert "Add compat-feature macro", ELPA Syncer, 2023/01/04
- [elpa] externals/compat 7737bb9d56 08/16: Run all checks at compile time,
ELPA Syncer <=
- [elpa] externals/compat 31810cd4d9 10/16: Add :feature, ELPA Syncer, 2023/01/04
- [elpa] externals/compat e8de246d40 14/16: Update manual, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 71f9648cdf 03/16: Specify features, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 7aa705b65e 02/16: Require features at compile time, ELPA Syncer, 2023/01/04
- [elpa] externals/compat ce86316661 11/16: Restore tests, ELPA Syncer, 2023/01/04
- [elpa] externals/compat f342b01a10 12/16: Update manual, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 77e3e92ebf 13/16: Restore tests, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 7569405bc8 15/16: Restore tests, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 0bb4709d83 16/16: Expand commentary, ELPA Syncer, 2023/01/04