aboutsummaryrefslogtreecommitdiff
path: root/compat-macs.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-05-22 11:55:25 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2023-05-24 11:07:59 +0200
commite2d66a88161e3c5df12469c40a63d896f16cea76 (patch)
tree537cc5d9274cdf97f12cfaa21aeea8ced6f9384b /compat-macs.el
parentab39edfb3b9339921df6ed4abdb848a446e32520 (diff)
compat-defun: Add :min-version argument
Use this argument for copy-tree, since there is no need to replace copy-tree on Emacs < 26.1. On Emacs < 26.1 records where based on records. Therefore copy-tree already supported them properly.
Diffstat (limited to 'compat-macs.el')
-rw-r--r--compat-macs.el16
1 files changed, 11 insertions, 5 deletions
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