emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat 0de389aca6 19/84: Add string-equal-ignore-case f


From: ELPA Syncer
Subject: [elpa] externals/compat 0de389aca6 19/84: Add string-equal-ignore-case from Emacs 29
Date: Tue, 3 Jan 2023 08:57:32 -0500 (EST)

branch: externals/compat
commit 0de389aca6ce4429933bde15bc5e26f8b387889b
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Add string-equal-ignore-case from Emacs 29
---
 compat-29.el    |  7 +++++++
 compat-tests.el | 21 +++++++++++++++++++++
 compat.texi     |  9 +++++++++
 3 files changed, 37 insertions(+)

diff --git a/compat-29.el b/compat-29.el
index 8b14b23a43..af29d96446 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -100,6 +100,13 @@ If N is zero or negative, return nil.
 If N is greater or equal to the length of LIST, return LIST (or a copy)."
   (compat--ntake-elisp n (copy-sequence list)))      ;FIXME: only copy as much 
as necessary
 
+(compat-defun string-equal-ignore-case (string1 string2)
+  "Like `string-equal', but case-insensitive.
+Upper-case and lower-case letters are treated as equal.
+Unibyte strings are converted to multibyte for comparison."
+  (declare (pure t) (side-effect-free t))
+  (eq t (compare-strings string1 0 nil string2 0 nil t)))
+
 ;;;; Defined in subr.el
 
 (compat-defun function-alias-p (func &optional noerror)
diff --git a/compat-tests.el b/compat-tests.el
index 2a334b9b68..2b5c8ba817 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -2030,6 +2030,27 @@ being compared against."
 ;;   (ought t "~root")
 ;;   (ought t "~root/")
 ;;   (ought t "~root/file"))
+(compat-deftests string-equal-ignore-case
+  (ought t "" "")
+  (ought t "a" "a")
+  (ought t "a" "A")
+  (ought t "A" "a")
+  (ought nil "aA" "a")
+  (ought nil "a" "Aa")
+  (ought t "aA" "aA")
+  (ought t "Aa" "Aa")
+  (ought nil "aB" "aA")
+  (ought nil "Ba" "Aa")
+  (ought t "AAA BBB" "AAA BBB")
+  (ought t "aaa BBB" "AAA BBB")
+  (ought t "AAA bbb" "AAA BBB")
+  (ought t "AAA BBB" "aaa BBB")
+  (ought t "AAA BBB" "AAA bbb")
+  (ought t "AAA BBB" "aaa bbb")
+  (ought t "AAA BBB" "aaa bbb")
+  (ought t "AAA bbb" "aaa bbb")
+  (ought t "aaa BBB" "aaa bbb"))
+
 
 (provide 'compat-tests)
 ;;; compat-tests.el ends here
diff --git a/compat.texi b/compat.texi
index 80077f1bcb..e82badff2a 100644
--- a/compat.texi
+++ b/compat.texi
@@ -2379,6 +2379,15 @@ meaning as with @code{window-text-pixel-size}.
 @xref{Size of Displayed Text,,,elisp}.
 @end defun
 
+@c copied from lispref/strings.texi
+@defun string-equal-ignore-case string1 string2
+@code{string-equal-ignore-case} compares strings ignoring case
+differences, like @code{char-equal} when @code{case-fold-search} is
+@code{t}.
+
+@xref{Text Comparison,,,elisp}.
+@end defun
+
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]