aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compat-30.el43
-rw-r--r--compat-macs.el16
2 files changed, 32 insertions, 27 deletions
diff --git a/compat-30.el b/compat-30.el
index 4058ce4..72110f2 100644
--- a/compat-30.el
+++ b/compat-30.el
@@ -32,30 +32,29 @@
(compat-defun copy-tree (tree &optional vectors-and-records) ;; <compat-tests:copy-tree>
"Handle copying records when optional arg is non-nil."
+ :min-version "26.1" ;; recordp is only available on Emacs 26.1 and newer
:extended t
(declare (side-effect-free error-free))
- (if (fboundp 'recordp)
- (if (consp tree)
- (let (result)
- (while (consp tree)
- (let ((newcar (car tree)))
- (if (or (consp (car tree))
- (and vectors-and-records
- (or (vectorp (car tree)) (recordp (car tree)))))
- (setq newcar (compat--copy-tree (car tree) vectors-and-records)))
- (push newcar result))
- (setq tree (cdr tree)))
- (nconc (nreverse result)
- (if (and vectors-and-records (or (vectorp tree) (recordp tree)))
- (compat--copy-tree tree vectors-and-records)
- tree)))
- (if (and vectors-and-records (or (vectorp tree) (recordp tree)))
- (let ((i (length (setq tree (copy-sequence tree)))))
- (while (>= (setq i (1- i)) 0)
- (aset tree i (compat--copy-tree (aref tree i) vectors-and-records)))
- tree)
- tree))
- (copy-tree tree vectors-and-records)))
+ (if (consp tree)
+ (let (result)
+ (while (consp tree)
+ (let ((newcar (car tree)))
+ (if (or (consp (car tree))
+ (and vectors-and-records
+ (or (vectorp (car tree)) (recordp (car tree)))))
+ (setq newcar (compat--copy-tree (car tree) vectors-and-records)))
+ (push newcar result))
+ (setq tree (cdr tree)))
+ (nconc (nreverse result)
+ (if (and vectors-and-records (or (vectorp tree) (recordp tree)))
+ (compat--copy-tree tree vectors-and-records)
+ tree)))
+ (if (and vectors-and-records (or (vectorp tree) (recordp tree)))
+ (let ((i (length (setq tree (copy-sequence tree)))))
+ (while (>= (setq i (1- i)) 0)
+ (aset tree i (compat--copy-tree (aref tree i) vectors-and-records)))
+ tree)
+ tree)))
(provide 'compat-30)
;;; compat-30.el ends here
diff --git a/compat-macs.el b/compat-macs.el
index 6c6e220..5634790 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -74,8 +74,9 @@ a plist of predicates for arguments which are passed to FUN."
(declare (indent 2))
(compat-macs--assert compat-macs--version "No `compat-version' was declared")
(let* ((body (compat-macs--check-attributes
- attrs `(,@preds :feature symbolp)))
+ attrs `(,@preds :min-version stringp :feature symbolp)))
(feature (plist-get attrs :feature))
+ (min-version (plist-get attrs :min-version))
(attrs `(:body ,body ,@attrs))
args)
;; Require feature at compile time
@@ -83,7 +84,9 @@ a plist of predicates for arguments which are passed to FUN."
(compat-macs--assert (not (eq feature 'subr-x)) "Invalid feature subr-x")
(require feature))
;; The current Emacs must be older than the currently declared version.
- (when (version< emacs-version compat-macs--version)
+ (when (and (version< emacs-version compat-macs--version)
+ (or (not min-version)
+ (version<= min-version emacs-version)))
(while preds
(push (plist-get attrs (car preds)) args)
(setq preds (cddr preds)))
@@ -145,6 +148,9 @@ overriden. REST is an attribute plist followed by the definition
body. The attributes specify the conditions under which the
definition is generated.
+- :min-version :: Only compile the definition for Emacs versions
+ newer than the given version.
+
- :feature :: Wrap the definition with `with-eval-after-load' for
the given feature."
(declare (debug ([&rest keywordp sexp] def-body))
@@ -164,7 +170,7 @@ under which the definition is generated.
- :obsolete :: Mark the alias as obsolete if t.
-- :feature :: See `compat-guard'."
+- :feature and :min-version :: See `compat-guard'."
(declare (debug (name symbolp [&rest keywordp sexp])))
(compat-macs--guard attrs '(:obsolete booleanp)
(lambda (obsolete)
@@ -196,7 +202,7 @@ specify the conditions under which the definition is generated.
- :obsolete :: Mark the function as obsolete if t, can be a
string describing the obsoletion.
-- :feature :: See `compat-guard'."
+- :feature and :min-version :: See `compat-guard'."
(declare (debug (&define name (&rest symbolp)
stringp
[&rest keywordp sexp]
@@ -226,7 +232,7 @@ definition is generated.
- :obsolete :: Mark the variable as obsolete if t, can be a
string describing the obsoletion.
-- :feature :: See `compat-guard'."
+- :feature and :min-version :: See `compat-guard'."
(declare (debug (name form stringp [&rest keywordp sexp]))
(doc-string 3) (indent 2))
(compat-macs--guard