diff options
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-29.el | 7 | ||||
| -rw-r--r-- | compat-tests.el | 8 | ||||
| -rw-r--r-- | compat.texi | 5 |
4 files changed, 21 insertions, 0 deletions
@@ -10,6 +10,7 @@ - compat-29: Add ~compiled-function-p~. - compat-29: Add ~plist-get~ generalized variable. - compat-29: Add ~plistp~. +- compat-29: Add ~list-of-strings-p~. * Release of "Compat" Version 29.1.2.0 diff --git a/compat-29.el b/compat-29.el index 3c3dc51..e84c628 100644 --- a/compat-29.el +++ b/compat-29.el @@ -84,6 +84,13 @@ 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))) +(compat-defun list-of-strings-p (object) ;; <compat-tests:lists-of-strings-p> + "Return t if OBJECT is nil or a list of strings." + (declare (pure t) (side-effect-free t)) + (while (and (consp object) (stringp (car object))) + (setq object (cdr object))) + (null object)) + (compat-defun plistp (object) ;; <compat-tests:plistp> "Non-nil if and only if OBJECT is a valid plist." (let ((len (proper-list-p object))) diff --git a/compat-tests.el b/compat-tests.el index 0b928e1..a15f3f5 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -906,6 +906,14 @@ (should (string-prefix-p "compat" (symbol-name (gensym "compat")))) (should-equal gensym-counter (+ orig 3)))) +(ert-deftest list-of-strings-p () + (should-not (list-of-strings-p 1)) + (should (list-of-strings-p nil)) + (should (list-of-strings-p '("a" "b"))) + (should-not (list-of-strings-p ["a" "b"])) + (should-not (list-of-strings-p '("a" nil "b"))) + (should-not (list-of-strings-p '("a" "b" . "c")))) + (ert-deftest plistp () (should (plistp '(:a a :b b))) (should (plistp '(1 2 3 4))) diff --git a/compat.texi b/compat.texi index 211edde..6aec7f4 100644 --- a/compat.texi +++ b/compat.texi @@ -2013,6 +2013,11 @@ that there will be the need for changes, so use these functions with care. @c based on lisp/subr.el +@defun list-of-strings-p object +Return @code{t} if @var{object} is @code{nil} or a list of strings. +@end defun + +@c based on lisp/subr.el @defun plistp object Non-nil if and only if @var{object} is a valid plist. @end defun |
