]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove `string-slice' -- it's not very well defined
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 25 Dec 2020 04:16:46 +0000 (05:16 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 25 Dec 2020 04:16:46 +0000 (05:16 +0100)
* doc/lispref/strings.texi (Creating Strings): Ditto.

* lisp/emacs-lisp/subr-x.el (string-slice): Remove.

doc/lispref/strings.texi
etc/NEWS
lisp/emacs-lisp/shortdoc.el
lisp/emacs-lisp/subr-x.el
test/lisp/emacs-lisp/subr-x-tests.el

index ef848ac51076ffc280d675c21e703e1eb970ecc0..19b91471ed36951195038139b5de9e3ade0bce45 100644 (file)
@@ -381,17 +381,6 @@ The default value of @var{separators} for @code{split-string}.  Its
 usual value is @w{@code{"[ \f\t\n\r\v]+"}}.
 @end defvar
 
-@defun string-slice string regexp
-Split @var{string} into a list of strings on @var{regexp} boundaries.
-As opposed to @code{split-string}, the boundaries are included in the
-result set:
-
-@example
-(string-slice "  two words " " +")
-     @result{} ("  two" " words" " ")
-@end example
-@end defun
-
 @defun string-clean-whitespace string
 Clean up the whitespace in @var{string} by collapsing stretches of
 whitespace to a single space character, as well as removing all
index b155ff9d42e616461cdb2c8543e00179ea167e62..3a0102238ca6769cf003f8a56b82ed4fa958239e 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1467,7 +1467,7 @@ This can be set to nil to inhibit hiding passwords in .authinfo files.
 +++
 *** A number of new string manipulation functions have been added.
 'string-clean-whitespace', 'string-fill', 'string-limit',
-'string-lines', 'string-pad', 'string-chop-newline' and 'string-slice'.
+'string-lines', 'string-pad' and 'string-chop-newline'.
 
 +++
 *** New variable 'current-minibuffer-command'.
index 0067495fea04bca9c66a20dd4d62f7811dc4d9f4..618465513da7abc75466f0f6f9c0daf7d2ee43b2 100644 (file)
@@ -154,9 +154,6 @@ There can be any number of :example/:result elements."
    :eval (split-string "foo bar")
    :eval (split-string "|foo|bar|" "|")
    :eval (split-string "|foo|bar|" "|" t))
-  (string-slice
-   :eval (string-slice "foo-bar" "-")
-   :eval (string-slice "foo-bar--zot-" "-+"))
   (string-lines
    :eval (string-lines "foo\n\nbar")
    :eval (string-lines "foo\n\nbar" t))
index 7e17a3464e64eabbd5d5edb87ba19243245c6d8f..dc5840a0865e396d10c2257a545081cb3617171a 100644 (file)
@@ -310,19 +310,6 @@ than this function."
 If OMIT-NULLS, empty lines will be removed from the results."
   (split-string string "\n" omit-nulls))
 
-(defun string-slice (string regexp)
-  "Split STRING at REGEXP boundaries and return a list of slices.
-The boundaries that match REGEXP are included in the result.
-
-Also see `split-string'."
-  (if (zerop (length string))
-      (list "")
-    (let ((i (string-match-p regexp string 1)))
-      (if i
-          (cons (substring string 0 i)
-                (string-slice (substring string i) regexp))
-        (list string)))))
-
 (defun string-pad (string length &optional padding start)
   "Pad STRING to LENGTH using PADDING.
 If PADDING is nil, the space character is used.  If not nil, it
index 3fc5f1d3ed30835f3af1802aea54473319ce09db..2ae492ecf153222ffe5219c54d60a791dc2c4f26 100644 (file)
   (should (equal (string-lines "foo") '("foo")))
   (should (equal (string-lines "foo \nbar") '("foo " "bar"))))
 
-(ert-deftest subr-string-slice ()
-  (should (equal (string-slice "foo-bar" "-") '("foo" "-bar")))
-  (should (equal (string-slice "foo-bar-" "-") '("foo" "-bar" "-")))
-  (should (equal (string-slice "-foo-bar-" "-") '("-foo" "-bar" "-")))
-  (should (equal (string-slice "ooo" "lala") '("ooo")))
-  (should (equal (string-slice "foo bar" "\\b") '("foo" " " "bar" "")))
-  (should (equal (string-slice "foo bar" "\\b\\|a") '("foo" " " "b" "ar" ""))))
-
 (ert-deftest subr-string-pad ()
   (should (equal (string-pad "foo" 5) "foo  "))
   (should (equal (string-pad "foo" 5 ?-) "foo--"))