[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat a62393b8bb 2/2: compat-macs: Simplification, re
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat a62393b8bb 2/2: compat-macs: Simplification, remove :min-version and :max-version |
Date: |
Sun, 15 Jan 2023 01:57:27 -0500 (EST) |
branch: externals/compat
commit a62393b8bbf629380535e42c380564fdcef9228b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
compat-macs: Simplification, remove :min-version and :max-version
---
compat-28.el | 8 ++++----
compat-macs.el | 48 +++++++++---------------------------------------
2 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/compat-28.el b/compat-28.el
index e97028c286..6237ce04aa 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -156,7 +156,7 @@ If COUNT is non-nil and a natural number, the function will
(compat-defun json-serialize (object &rest args) ;; <UNTESTED>
"Handle top-level JSON values (RFC 8259)."
:explicit t
- :min-version "27"
+ :cond (= 27 emacs-major-version)
(if (or (listp object) (vectorp object))
(apply #'json-serialize object args)
(substring (json-serialize (list object)) 1 -1)))
@@ -165,7 +165,7 @@ If COUNT is non-nil and a natural number, the function will
(compat-defun json-insert (object &rest args) ;; <UNTESTED>
"Handle top-level JSON values (RFC 8259)."
:explicit t
- :min-version "27"
+ :cond (= 27 emacs-major-version)
(if (or (listp object) (vectorp object))
(apply #'json-insert object args)
(insert (apply #'compat--json-serialize object args))))
@@ -174,7 +174,7 @@ If COUNT is non-nil and a natural number, the function will
(compat-defun json-parse-string (string &rest args) ;; <UNTESTED>
"Handle top-level JSON values (RFC 8259)."
:explicit t
- :min-version "27"
+ :cond (= 27 emacs-major-version)
(if (string-match-p "\\`[[:space:]]*[[{]" string)
(apply #'json-parse-string string args)
;; Wrap the string in an array, and extract the value back using
@@ -186,7 +186,7 @@ If COUNT is non-nil and a natural number, the function will
(compat-defun json-parse-buffer (&rest args) ;; <UNTESTED>
"Handle top-level JSON values (RFC 8259)."
:explicit t
- :min-version "27"
+ :cond (= 27 emacs-major-version)
(if (looking-at-p "[[:space:]]*[[{]")
(apply #'json-parse-buffer args)
(catch 'escape
diff --git a/compat-macs.el b/compat-macs.el
index 1b44ece115..82de765a0e 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -61,32 +61,15 @@ If this is not documented on yourself system, you can check
\
(setq attrs (cddr attrs)))
attrs)
-(defun compat--condition-satisfied (attrs)
- "Check that version constraints specified by ATTRS are satisfied."
- (let ((min-version (plist-get attrs :min-version))
- (max-version (plist-get attrs :max-version))
- (cond (plist-get attrs :cond)))
- ;; Min/max version bounds must be satisfied.
- (and
- ;; Min/max version bounds must be satisfied.
- (or (not min-version) (version<= min-version emacs-version))
- (or (not max-version) (version< emacs-version max-version))
- ;; If a condition is specified, no version check is performed.
- (if cond
- (eval cond t)
- ;; The current Emacs must be older than the current declared Compat
- ;; version, see `compat-declare-version'.
- (version< emacs-version compat--version)))))
-
(defun compat--guarded-definition (attrs args fun)
"Guard compatibility definition generation.
The version constraints specified by ATTRS are checked.
ARGS is a list of keywords which are looked up and passed to FUN."
(declare (indent 2))
- (let* ((body (compat--check-attributes
- attrs `(,@args :min-version :max-version :cond :feature)))
+ (let* ((body (compat--check-attributes attrs `(,@args :cond :feature)))
(feature (plist-get attrs :feature))
- (attrs `(:body ,body ,@attrs)))
+ (attrs `(:body ,body ,@attrs))
+ (cond (plist-get attrs :cond)))
;; Require feature at compile time
(when feature
(when (eq feature 'subr-x)
@@ -94,7 +77,12 @@ ARGS is a list of keywords which are looked up and passed to
FUN."
;; If the feature does not exist, treat it as nil. The function will
then
;; be defined on the toplevel and not in a `with-eval-after-load' block.
(setq feature (require feature nil t)))
- (when (compat--condition-satisfied attrs)
+ (when (if cond
+ ;; If a condition is specified, no version check is performed.
+ (eval cond t)
+ ;; The current Emacs must be older than the current declared Compat
+ ;; version, see `compat-declare-version'.
+ (version< emacs-version compat--version))
(setq body (apply fun (mapcar (lambda (x) (plist-get attrs x)) args)))
(when body
(if feature
@@ -140,12 +128,6 @@ under which the definition is generated.
- :obsolete :: Mark the alias as obsolete.
-- :min-version :: Install the definition if the Emacs version is
- greater or equal than the given version.
-
-- :max-version :: Install the definition if the Emacs version is
- smaller than the given version.
-
- :feature :: Wrap the definition with `with-eval-after-load'.
- :cond :: Install the definition if :cond evaluates to non-nil."
@@ -174,12 +156,6 @@ defined.
- :explicit :: Make the definition available such that it can be
called explicitly via `compat-call'.
-- :min-version :: Install the definition if the Emacs version is
- greater or equal than the given version.
-
-- :max-version :: Install the definition if the Emacs version is
- smaller than the given version.
-
- :feature :: Wrap the definition with `with-eval-after-load'.
- :cond :: Install the definition if :cond evaluates to non-nil."
@@ -210,12 +186,6 @@ definition is generated.
`permanent'. For other non-nil values make the variable
buffer-local.
-- :min-version :: Install the definition if the Emacs version is
- greater or equal than the given version.
-
-- :max-version :: Install the definition if the Emacs version is
- smaller than the given version.
-
- :feature :: Wrap the definition with `with-eval-after-load'.
- :cond :: Install the definition if :cond evaluates to non-nil."