Function: ensure-proper-list
ensure-proper-list is a byte-compiled function defined in subr.el.gz.
Signature
(ensure-proper-list OBJECT)
Documentation
Return OBJECT as a list.
If OBJECT is already a proper list, return OBJECT itself. If it's not a proper list, return a one-element list containing OBJECT.
ensure-list is usually preferable because that function runs in
constant time, but this one has to traverse the whole of OBJECT.
Other relevant functions are documented in the list group.
Probably introduced at or before Emacs version 31.1.
Shortdoc
;; list
(ensure-proper-list "foo")
=> ("foo")
(ensure-proper-list '(1 2 3))
=> (1 2 3)
(ensure-proper-list '(1 . 2))
=> ((1 . 2))
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun ensure-proper-list (object)
"Return OBJECT as a list.
If OBJECT is already a proper list, return OBJECT itself. If it's not a
proper list, return a one-element list containing OBJECT.
`ensure-list' is usually preferable because that function runs in
constant time, but this one has to traverse the whole of OBJECT."
(declare (side-effect-free error-free))
(if (proper-list-p object)
object
(list object)))