[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat ae2404e13d: Explicitly define versions instead o
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat ae2404e13d: Explicitly define versions instead of inferring them from file names |
Date: |
Wed, 10 Aug 2022 04:57:24 -0400 (EDT) |
branch: externals/compat
commit ae2404e13dc58f71f66be5895631011b3a6b2240
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Explicitly define versions instead of inferring them from file names
This is a further simplification that avoids difficult edge cases.
Among other things this also satisfied Flymake, that copies and
renames files to a temporary directory, breaking the version inference
process.
---
compat-24.el | 33 ++-------------------------------
compat-25.el | 2 ++
compat-26.el | 2 ++
compat-27.el | 2 ++
compat-28.el | 2 ++
compat-macs.el | 31 ++++++++++++-------------------
compat-tests.el | 17 +++--------------
7 files changed, 25 insertions(+), 64 deletions(-)
diff --git a/compat-24.el b/compat-24.el
index f208ae7bd8..8e0fd93e92 100644
--- a/compat-24.el
+++ b/compat-24.el
@@ -39,11 +39,12 @@
(eval-when-compile (require 'compat-macs))
+(compat-declare-version "24.4")
+
;;;; Defined in data.c
(compat-defun = (number-or-marker &rest numbers-or-markers)
"Handle multiple arguments."
- :version "24.4"
:prefix t
(catch 'fail
(while numbers-or-markers
@@ -54,7 +55,6 @@
(compat-defun < (number-or-marker &rest numbers-or-markers)
"Handle multiple arguments."
- :version "24.4"
:prefix t
(catch 'fail
(while numbers-or-markers
@@ -65,7 +65,6 @@
(compat-defun > (number-or-marker &rest numbers-or-markers)
"Handle multiple arguments."
- :version "24.4"
:prefix t
(catch 'fail
(while numbers-or-markers
@@ -76,7 +75,6 @@
(compat-defun <= (number-or-marker &rest numbers-or-markers)
"Handle multiple arguments."
- :version "24.4"
:prefix t
(catch 'fail
(while numbers-or-markers
@@ -87,7 +85,6 @@
(compat-defun >= (number-or-marker &rest numbers-or-markers)
"Handle multiple arguments."
- :version "24.4"
:prefix t
(catch 'fail
(while numbers-or-markers
@@ -100,7 +97,6 @@
If optional third argument C is given, store result into C.
A, B, and C must be bool vectors of the same length.
Return the destination vector if it changed or nil otherwise."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (bool-vector-p b)
@@ -124,7 +120,6 @@ Return the destination vector if it changed or nil
otherwise."
If optional third argument C is given, store result into C.
A, B, and C must be bool vectors of the same length.
Return the destination vector if it changed or nil otherwise."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (bool-vector-p b)
@@ -148,7 +143,6 @@ Return the destination vector if it changed or nil
otherwise."
If optional third argument C is given, store result into C.
A, B, and C must be bool vectors of the same length.
Return the destination vector if it changed or nil otherwise."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (bool-vector-p b)
@@ -172,7 +166,6 @@ Return the destination vector if it changed or nil
otherwise."
If optional third argument C is given, store result into C.
A, B, and C must be bool vectors of the same length.
Return the destination vector if it changed or nil otherwise."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (bool-vector-p b)
@@ -196,7 +189,6 @@ Return the destination vector if it changed or nil
otherwise."
If optional second argument B is given, store result into B.
A and B must be bool vectors of the same length.
Return the destination vector."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (or (null b) (bool-vector-p b))
@@ -211,7 +203,6 @@ Return the destination vector."
(compat-defun bool-vector-subsetp (a b)
"Return t if every t value in A is also t in B, nil otherwise.
A and B must be bool vectors of the same length."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(unless (bool-vector-p b)
@@ -227,7 +218,6 @@ A and B must be bool vectors of the same length."
(compat-defun bool-vector-count-consecutive (a b i)
"Count how many consecutive elements in A equal B starting at I.
A is a bool vector, B is t or nil, and I is an index into A."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(setq b (and b t)) ;normalise to nil or t
@@ -242,7 +232,6 @@ A is a bool vector, B is t or nil, and I is an index into
A."
"Count how many elements in A are t.
A is a bool vector. To count A's nil elements, subtract the
return value from A's length."
- :version "24.4"
(unless (bool-vector-p a)
(signal 'wrong-type-argument (list 'bool-vector-p a)))
(let ((n 0))
@@ -259,7 +248,6 @@ return value from A's length."
FILE is normally a feature name, but it can also be a file name,
in case that file does not provide any feature. See `eval-after-load'
for more details about the different forms of FILE and their semantics."
- :version "24.4"
(declare (indent 1) (debug (form def-body)))
;; See https://nullprogram.com/blog/2018/02/22/ on how
;; `eval-after-load' is used to preserve compatibility with 24.3.
@@ -267,7 +255,6 @@ for more details about the different forms of FILE and
their semantics."
(compat-defun special-form-p (object)
"Non-nil if and only if OBJECT is a special form."
- :version "24.4"
(if (and (symbolp object) (fboundp object))
(setq object (condition-case nil
(indirect-function object)
@@ -276,7 +263,6 @@ for more details about the different forms of FILE and
their semantics."
(compat-defun macrop (object)
"Non-nil if and only if OBJECT is a macro."
- :version "24.4"
(let ((def (condition-case nil
(indirect-function object)
(void-function nil))))
@@ -288,7 +274,6 @@ for more details about the different forms of FILE and
their semantics."
"Return non-nil if SUFFIX is a suffix of STRING.
If IGNORE-CASE is non-nil, the comparison is done without paying
attention to case differences."
- :version "24.4"
(let ((start-pos (- (length string) (length suffix))))
(and (>= start-pos 0)
(eq t (compare-strings suffix nil nil
@@ -298,7 +283,6 @@ attention to case differences."
"Extend `split-string' by a TRIM argument.
The remaining arguments STRING, SEPARATORS and OMIT-NULLS are
handled just as with `split-string'."
- :version "24.4"
:prefix t
(let* ((token (split-string string separators omit-nulls))
(trimmed (if trim
@@ -317,7 +301,6 @@ handled just as with `split-string'."
"Destructively remove `equal' consecutive duplicates from LIST.
First and last elements are considered consecutive if CIRCULAR is
non-nil."
- :version "24.4"
(let ((tail list) last)
(while (cdr tail)
(if (equal (car tail) (cadr tail))
@@ -337,7 +320,6 @@ MESSAGE is a string that will be output to the echo area if
such an error
is signaled without being caught by a `condition-case'.
PARENT is either a signal or a list of signals from which it inherits.
Defaults to `error'."
- :version "24.4"
(unless parent (setq parent 'error))
(let ((conditions
(if (consp parent)
@@ -364,7 +346,6 @@ only need to call FUN once. This can be useful when FUN
performs a
relatively slow operation, such as calling an external process.
When IGNORE-CASE is non-nil, FUN is expected to be case-insensitive."
- :version "24.4"
(let* (last-arg last-result
(new-fun
(lambda (arg)
@@ -378,7 +359,6 @@ When IGNORE-CASE is non-nil, FUN is expected to be
case-insensitive."
;;* UNTESTED
(compat-defun completion-table-merge (&rest tables)
"Create a completion table that collects completions from all TABLES."
- :version "24.4"
(lambda (string pred action)
(cond
((null action)
@@ -406,7 +386,6 @@ When IGNORE-CASE is non-nil, FUN is expected to be
case-insensitive."
;;* UNTESTED
(compat-advise require (feature &rest args)
"Allow for Emacs 24.x to require the inexistent FEATURE subr-x."
- :version "24.4"
;; As the compatibility advise around `require` is more a hack than
;; of of actual value, the highlighting is suppressed.
:no-highlight t
@@ -419,7 +398,6 @@ When IGNORE-CASE is non-nil, FUN is expected to be
case-insensitive."
(compat-defun hash-table-keys (hash-table)
"Return a list of keys in HASH-TABLE."
- :version "24.4"
(let (values)
(maphash
(lambda (k _v) (push k values))
@@ -428,7 +406,6 @@ When IGNORE-CASE is non-nil, FUN is expected to be
case-insensitive."
(compat-defun hash-table-values (hash-table)
"Return a list of values in HASH-TABLE."
- :version "24.4"
(let (values)
(maphash
(lambda (_k v) (push v values))
@@ -437,33 +414,28 @@ When IGNORE-CASE is non-nil, FUN is expected to be
case-insensitive."
(compat-defun string-empty-p (string)
"Check whether STRING is empty."
- :version "24.4"
(string= string ""))
(compat-defun string-join (strings &optional separator)
"Join all STRINGS using SEPARATOR.
Optional argument SEPARATOR must be a string, a vector, or a list of
characters; nil stands for the empty string."
- :version "24.4"
(mapconcat #'identity strings separator))
(compat-defun string-blank-p (string)
"Check whether STRING is either empty or only whitespace.
The following characters count as whitespace here: space, tab, newline and
carriage return."
- :version "24.4"
(string-match-p "\\`[ \t\n\r]*\\'" string))
(compat-defun string-remove-prefix (prefix string)
"Remove PREFIX from STRING if present."
- :version "24.4"
(if (string-prefix-p prefix string)
(substring string (length prefix))
string))
(compat-defun string-remove-suffix (suffix string)
"Remove SUFFIX from STRING if present."
- :version "24.4"
(if (string-suffix-p suffix string)
(substring string 0 (- (length string) (length suffix)))
string))
@@ -496,7 +468,6 @@ The optional argument SPEC-TYPE determines which spec to
set:
and `face-override-spec' specs;
Any other value means not to set any spec, but to run the
function for defining FACE and recalculating its attributes."
- :version "24.4"
(if (get face 'face-alias)
(setq face (get face 'face-alias)))
;; Save SPEC to the relevant symbol property.
diff --git a/compat-25.el b/compat-25.el
index eb9d0a8b8f..60f365ba68 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -34,6 +34,8 @@
(eval-when-compile (require 'compat-macs))
+(compat-declare-version "25.1")
+
;;;; Defined in alloc.c
(compat-defun bool-vector (&rest objects)
diff --git a/compat-26.el b/compat-26.el
index 76087b8066..f712d24e76 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -40,6 +40,8 @@
(eval-when-compile (require 'compat-macs))
(declare-function compat-func-arity "compat" (func))
+(compat-declare-version "26.1")
+
;;;; Defined in eval.c
(compat-defun func-arity (func)
diff --git a/compat-27.el b/compat-27.el
index a5eb72e36a..fdc81c93c8 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -41,6 +41,8 @@
(eval-when-compile (require 'compat-macs))
+(compat-declare-version "27.1")
+
;;;; Defined in fns.c
(compat-defun proper-list-p (object)
diff --git a/compat-28.el b/compat-28.el
index 1b1d6de3d5..1cb3879acb 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -41,6 +41,8 @@
(eval-when-compile (require 'compat-macs))
+(compat-declare-version "28.1")
+
;;;; Defined in fns.c
;;* INCOMPLETE FEATURE: Should handle multibyte regular expressions
diff --git a/compat-macs.el b/compat-macs.el
index f661fd1158..fa0f6ea74a 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -40,6 +40,16 @@ is loaded (in this case `compat-26').")
`(unless (bound-and-true-p compat--inhibit-prefixed)
,@body))
+(defvar compat-current-version nil
+ "Default version to use when no explicit version was given.")
+
+(defmacro compat-declare-version (version)
+ "Set the Emacs version that is currently being handled to VERSION."
+ ;; FIXME: Avoid setting the version for any definition that might
+ ;; follow, but try to restrict it to the current file/buffer.
+ (setq compat-current-version version)
+ nil)
+
(defvar compat--generate-function #'compat--generate-default
"Function used to generate compatibility code.
The function must take six arguments: NAME, DEF-FN, INSTALL-FN,
@@ -93,25 +103,8 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(max-version (plist-get attr :max-version))
(feature (plist-get attr :feature))
(cond (plist-get attr :cond))
- (version
- ;; If you edit this, also edit `compat--generate-testable' in
- ;; `compat-tests.el'.
- (or (plist-get attr :version)
- (let* ((file (car (last current-load-list)))
- (file (if (stringp file)
- ;; Some library, which requires compat-XY.el,
- ;; is being compiled and compat-XY.el has not
- ;; been compiled yet.
- file
- ;; compat-XY.el is being compiled.
- (or (bound-and-true-p byte-compile-current-file)
- ;; Fallback to the buffer being evaluated.
- (buffer-file-name)))))
- (if (and file
- (string-match
- "compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
- (concat (match-string 1 file) ".1")
- (error "BUG: No version number could be extracted")))))
+ (version (or (plist-get attr :version)
+ compat-current-version))
(realname (or (plist-get attr :realname)
(intern (format "compat--%S" name))))
(check (cond
diff --git a/compat-tests.el b/compat-tests.el
index bd38c3d8c9..b2940cfbd8 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -36,6 +36,7 @@
(require 'compat-macs)
+(defvar compat-current-version)
(defun compat--generate-testable (name def-fn install-fn check-fn attr type)
"Generate a more verbose compatibility definition, fit for testing.
See `compat-generate-function' for details on the arguments NAME,
@@ -44,20 +45,8 @@ DEF-FN, INSTALL-FN, CHECK-FN, ATTR and TYPE."
(max-version (plist-get attr :max-version))
(feature (plist-get attr :feature))
(cond (plist-get attr :cond))
- (version
- ;; If you edit this, also edit `compat--generate-default' in
- ;; compat-macs.el.
- (or (plist-get attr :version)
- (let* ((file (car (last current-load-list)))
- (file (if (stringp file)
- file
- (or (bound-and-true-p byte-compile-current-file)
- (buffer-file-name)))))
- (if (and file
- (string-match
- "compat-\\([[:digit:]]+\\)\\.\\(?:elc?\\)\\'" file))
- (concat (match-string 1 file) ".1")
- (error "BUG: No version number could be extracted")))))
+ (version (or (plist-get attr :version)
+ compat-current-version))
(realname (or (plist-get attr :realname)
(intern (format "compat--%S" name))))
(body `(progn
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/compat ae2404e13d: Explicitly define versions instead of inferring them from file names,
ELPA Syncer <=