aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-06-27 12:36:37 +0200
committerLars Ingebrigtsen2022-06-27 12:36:37 +0200
commitdedd19a2f5cbf16c8ac8a122b0c39ee4e178b9e8 (patch)
treee9bbab0f0aff4c41d8645dd65d36346e23b0eae9
parentabdf35fac66ca51419ec39056df0429790ec9db9 (diff)
downloademacs-dedd19a2f5cbf16c8ac8a122b0c39ee4e178b9e8.tar.gz
emacs-dedd19a2f5cbf16c8ac8a122b0c39ee4e178b9e8.zip
Add new type predicate plistp
* lisp/subr.el (plistp): New type predicate (bug#47427). This referred to in the error message from plist-put: "Debugger entered--Lisp error: (wrong-type-argument plistp (a b c))".
-rw-r--r--lisp/subr.el6
-rw-r--r--test/lisp/subr-tests.el9
2 files changed, 15 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index b05471f0c3e..69cff23cba8 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4006,6 +4006,12 @@ Otherwise, return nil."
4006 (setq object (indirect-function object))) 4006 (setq object (indirect-function object)))
4007 (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled))) 4007 (and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
4008 4008
4009(defun plistp (object)
4010 "Non-nil if and only if OBJECT is a valid plist."
4011 (and (listp object)
4012 (proper-list-p object)
4013 (zerop (mod (length object) 2))))
4014
4009(defun macrop (object) 4015(defun macrop (object)
4010 "Non-nil if and only if OBJECT is a macro." 4016 "Non-nil if and only if OBJECT is a macro."
4011 (let ((def (indirect-function object))) 4017 (let ((def (indirect-function object)))
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 45dd2d71603..ced2bc5c4e5 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1081,5 +1081,14 @@ final or penultimate step during initialization."))
1081 (dolist (c (list ?a ?b ?α ?β)) 1081 (dolist (c (list ?a ?b ?α ?β))
1082 (should-not (char-uppercase-p c)))) 1082 (should-not (char-uppercase-p c))))
1083 1083
1084(ert-deftest test-plistp ()
1085 (should (plistp nil))
1086 (should-not (plistp 1))
1087 (should (plistp '(1 2)))
1088 (should-not (plistp '(1 . 2)))
1089 (should (plistp '(1 2 3 4)))
1090 (should-not (plistp '(1 2 3)))
1091 (should-not (plistp '(1 2 3 . 4))))
1092
1084(provide 'subr-tests) 1093(provide 'subr-tests)
1085;;; subr-tests.el ends here 1094;;; subr-tests.el ends here