branch: externals/compat
commit 42710e3e678b9f4994976a5f872d9c4724005e28
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Remove compat--ignore
---
compat-macs.el | 27 +++++++++++++--------------
compat-tests.el | 36 +++++++++++++++++++-----------------
2 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/compat-macs.el b/compat-macs.el
index 63f71e0cec..ff02d1b567 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -22,10 +22,6 @@
;;; Code:
-(defmacro compat--ignore (&rest _)
- "Ignore all arguments."
- nil)
-
(defvar compat--current-version nil
"Default version to use when no explicit version was given.")
@@ -98,11 +94,11 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(version< emacs-version min-version))
(and max-version
(version< max-version emacs-version)))
- '(compat--ignore))
+ nil)
((plist-get attr :prefix)
'(progn))
((and version (version<= version emacs-version) (not cond))
- '(compat--ignore))
+ nil)
(`(when (and ,(if cond cond t)
,(funcall check-fn)))))))
(when (eq name realname)
@@ -113,7 +109,8 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(let* ((actual-name (intern (match-string 1 (symbol-name name))))
(body (funcall install-fn actual-name version)))
(when (and (version<= version emacs-version)
- (fboundp actual-name))
+ (fboundp actual-name)
+ check)
`(,@check
,(if feature
;; See https://nullprogram.com/blog/2018/02/22/:
@@ -122,13 +119,15 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
((plist-get attr :realname)
`(progn
,(funcall def-fn realname version)
- (,@check
- ,(let ((body (funcall install-fn realname version)))
- (if feature
- ;; See https://nullprogram.com/blog/2018/02/22/:
- `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
- body)))))
- ((let* ((body (if (eq type 'advice)
+ ,(and check
+ `(,@check
+ ,(let ((body (funcall install-fn realname version)))
+ (if feature
+ ;; See https://nullprogram.com/blog/2018/02/22/:
+ `(eval-after-load ,feature `(funcall ',(lambda ()
,body)))
+ body))))))
+ (check
+ (let* ((body (if (eq type 'advice)
`(,@check
,(funcall def-fn realname version)
,(funcall install-fn realname version))
diff --git a/compat-tests.el b/compat-tests.el
index 5a738f9c27..38cf21c49a 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -51,7 +51,19 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(error "Duplicate compatibility definition: %s (was %s,
now %s)"
',name (get ',name 'compat-def) ',realname))
(put ',name 'compat-def ',realname)
- ,(funcall install-fn realname version))))
+ ,(funcall install-fn realname version)))
+ (check (cond
+ ((or (and min-version
+ (version< emacs-version min-version))
+ (and max-version
+ (version< max-version emacs-version)))
+ nil)
+ ((plist-get attr :prefix)
+ '(progn))
+ ((and version (version<= version emacs-version) (not cond))
+ nil)
+ (`(when (and ,(if cond cond t)
+ ,(funcall check-fn)))))))
`(progn
(put ',realname 'compat-type ',type)
(put ',realname 'compat-version ,version)
@@ -59,22 +71,12 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(put ',realname 'compat-max-version ,max-version)
(put ',realname 'compat-doc ,(plist-get attr :note))
,(funcall def-fn realname version)
- (,@(cond
- ((or (and min-version
- (version< emacs-version min-version))
- (and max-version
- (version< max-version emacs-version)))
- '(compat--ignore))
- ((plist-get attr :prefix)
- '(progn))
- ((and version (version<= version emacs-version) (not cond))
- '(compat--ignore))
- (`(when (and ,(if cond cond t)
- ,(funcall check-fn)))))
- ,(if feature
- ;; See https://nullprogram.com/blog/2018/02/22/:
- `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
- body)))))
+ ,(and check
+ `(,@check
+ ,(if feature
+ ;; See https://nullprogram.com/blog/2018/02/22/:
+ `(eval-after-load ,feature `(funcall ',(lambda () ,body)))
+ body))))))
(setq compat--generate-function #'compat--generate-testable)