Function: ensure-list

ensure-list is a byte-compiled function defined in subr.el.gz.

Signature

(ensure-list OBJECT)

Documentation

Return OBJECT as a list.

If OBJECT is already a list, return OBJECT itself. If it's not a list, return a one-element list containing OBJECT.

Other relevant functions are documented in the list group.

View in manual

Probably introduced at or before Emacs version 28.1.

Shortdoc

;; list
(ensure-list "foo")
    => ("foo")
  (ensure-list '(1 2 3))
    => (1 2 3)

Aliases

erc-list eglot--ensure-list

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defun ensure-list (object)
  "Return OBJECT as a list.
If OBJECT is already a list, return OBJECT itself.  If it's
not a list, return a one-element list containing OBJECT."
  (declare (side-effect-free error-free))
  (if (listp object)
      object
    (list object)))