aboutsummaryrefslogtreecommitdiff
path: root/compat-31.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2026-04-07 19:50:45 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2026-04-07 19:50:45 +0200
commita92ee96bb90cd829a53b997d02c85f0c7b006d94 (patch)
treee4d917a75afb80164c01b5cd3e872fae38ae9923 /compat-31.el
parentee0c0e7333f3014ae105d06a3b55b2897898ce0e (diff)
compat-31: New function ensure-proper-list
Diffstat (limited to 'compat-31.el')
-rw-r--r--compat-31.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/compat-31.el b/compat-31.el
index 4133bdb..0c1a228 100644
--- a/compat-31.el
+++ b/compat-31.el
@@ -29,6 +29,18 @@
;;;; Defined in subr.el
+(compat-defun ensure-proper-list (object) ;; <compat-tests:ensure-proper-list>
+ "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)))
+
(compat-defun set-local (variable value) ;; <compat-tests:set-local>
"Make VARIABLE buffer local and set it to VALUE."
(set (make-local-variable variable) value))