[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 3b3b1fe6f6 1/2: Add string-split
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 3b3b1fe6f6 1/2: Add string-split |
Date: |
Thu, 5 Jan 2023 05:57:27 -0500 (EST) |
branch: externals/compat
commit 3b3b1fe6f616b9b71fe69fb0da3bda55098009e7
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add string-split
---
compat-25.el | 15 ++-------------
compat-28.el | 16 ++--------------
compat-29.el | 2 ++
compat-macs.el | 12 ++++++++++++
compat-tests.el | 4 ++++
compat.texi | 7 +++++++
6 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/compat-25.el b/compat-25.el
index 323f714beb..afc82b64c8 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -57,13 +57,7 @@ usage: (bool-vector &rest OBJECTS)"
;;;; Defined in editfns.c
-(compat-defun format-message (string &rest objects) ;; <OK>
- "Format a string out of a format-string and arguments.
-The first argument is a format control string.
-The other arguments are substituted into it to make the result, a string.
-
-This implementation is equivalent to `format'."
- (apply #'format string objects))
+(compat-defalias format-message format) ;; <OK>
;;;; Defined in fileio.c
@@ -249,12 +243,7 @@ threading."
;;;; Defined in byte-run.el
-(compat-defun function-put (func prop value) ;; <OK>
- "Set FUNCTION's property PROP to VALUE.
-The namespace for PROP is shared with symbols.
-So far, FUNCTION can only be a symbol, not a lambda expression."
- :version "24.4"
- (put func prop value))
+(compat-defalias function-put put) ;; <OK>
;;;; Defined in files.el
diff --git a/compat-28.el b/compat-28.el
index e3aa0ab10b..45ad7ae167 100644
--- a/compat-28.el
+++ b/compat-28.el
@@ -108,17 +108,7 @@ inserted before contatenating."
;;;; Defined in alloc.c
-(compat-defun garbage-collect-maybe (_factor) ;; <OK>
- "Call ‘garbage-collect’ if enough allocation happened.
-FACTOR determines what \"enough\" means here: If FACTOR is a
-positive number N, it means to run GC if more than 1/Nth of the
-allocations needed to trigger automatic allocation took place.
-Therefore, as N gets higher, this is more likely to perform a GC.
-Returns non-nil if GC happened, and nil otherwise.
-
-NOTE: For releases of Emacs before version 28, this function will do nothing."
- ;; Do nothing
- nil)
+(compat-defalias garbage-collect-maybe ignore) ;; <OK>
;;;; Defined in filelock.c
@@ -425,9 +415,7 @@ not a list, return a one-element list containing OBJECT."
object
(list object)))
-(compat-defun subr-primitive-p (object) ;; <OK>
- "Return t if OBJECT is a built-in primitive function."
- (subrp object))
+(compat-defalias subr-primitive-p subrp) ;; <OK>
;;;; Defined in subr-x.el
diff --git a/compat-29.el b/compat-29.el
index e2d821c444..e8fc511aa9 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -234,6 +234,8 @@ binding KEY to DEF is added at the front of KEYMAP."
;;;; Defined in subr.el
+(compat-defalias string-split split-string) ;; <OK>
+
(compat-defun function-alias-p (func &optional noerror) ;; <UNTESTED>
"Return nil if FUNC is not a function alias.
If FUNC is a function alias, return the function alias chain.
diff --git a/compat-macs.el b/compat-macs.el
index c40f473aa8..7d6c097c3c 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -238,6 +238,18 @@ attribute, is greater than the current Emacs version."
(declare (debug compat-defun) (doc-string 3) (indent 2)) ;; <UNTESTED>
(compat--define-function 'macro name arglist docstring rest))
+(defmacro compat-defalias (name def)
+ "Declare compatibility alias NAME with DEF."
+ (compat--generate
+ name
+ (lambda (realname version)
+ `(defalias ',realname ',def))
+ (lambda (realname _version)
+ `(defalias ',name ',realname))
+ (lambda ()
+ `(not (fboundp ',name)))
+ nil))
+
(defmacro compat-defvar (name initval docstring &rest attr)
"Declare compatibility variable NAME with initial value INITVAL.
The obligatory documentation string DOCSTRING must be given.
diff --git a/compat-tests.el b/compat-tests.el
index 55a59fb5fa..e0e4298c56 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -773,6 +773,10 @@
(should-equal '[1 2 3] (compat-call sort '[1 2 3] #'<))
(should-equal '[1 2 3] (compat-call sort '[3 2 1] #'<)))
+(ert-deftest string-split ()
+ (should-equal '("a" "b" "c") (split-string "a b c"))
+ (should-equal '("a" "b" "c") (string-split "a b c")))
+
(ert-deftest string-equal-ignore-case ()
(should (string-equal-ignore-case "abc" "abc"))
(should (string-equal-ignore-case "abc" "ABC"))
diff --git a/compat.texi b/compat.texi
index 62ece9ce39..631ba8f80a 100644
--- a/compat.texi
+++ b/compat.texi
@@ -2201,6 +2201,13 @@ differences, like @code{char-equal} when
@code{case-fold-search} is
@xref{Text Comparison,,,elisp}.
@end defun
+@defun string-split STRING &optional SEPARATORS OMIT-NULLS TRIM
+@code{string-split} is an alias for the function @code{split-string}.
+The name follows the convention of other string functions.
+
+@xref{Creating Strings,,,elisp}.
+@end defun
+
@c copied from lispref/buffers.texi
@defun buffer-match-p condition buffer-or-name &optional arg
This function checks if a buffer designated by @code{buffer-or-name}