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))".
This commit is contained in:
parent
abdf35fac6
commit
dedd19a2f5
2 changed files with 15 additions and 0 deletions
|
@ -4006,6 +4006,12 @@ Otherwise, return nil."
|
|||
(setq object (indirect-function object)))
|
||||
(and (subrp object) (eq (cdr (subr-arity object)) 'unevalled)))
|
||||
|
||||
(defun plistp (object)
|
||||
"Non-nil if and only if OBJECT is a valid plist."
|
||||
(and (listp object)
|
||||
(proper-list-p object)
|
||||
(zerop (mod (length object) 2))))
|
||||
|
||||
(defun macrop (object)
|
||||
"Non-nil if and only if OBJECT is a macro."
|
||||
(let ((def (indirect-function object)))
|
||||
|
|
|
@ -1081,5 +1081,14 @@ final or penultimate step during initialization."))
|
|||
(dolist (c (list ?a ?b ?α ?β))
|
||||
(should-not (char-uppercase-p c))))
|
||||
|
||||
(ert-deftest test-plistp ()
|
||||
(should (plistp nil))
|
||||
(should-not (plistp 1))
|
||||
(should (plistp '(1 2)))
|
||||
(should-not (plistp '(1 . 2)))
|
||||
(should (plistp '(1 2 3 4)))
|
||||
(should-not (plistp '(1 2 3)))
|
||||
(should-not (plistp '(1 2 3 . 4))))
|
||||
|
||||
(provide 'subr-tests)
|
||||
;;; subr-tests.el ends here
|
||||
|
|
Loading…
Add table
Reference in a new issue