[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50704: Feature request: Add ensure-list in cl-lib
From: |
Clément Pit-Claudel |
Subject: |
bug#50704: Feature request: Add ensure-list in cl-lib |
Date: |
Mon, 20 Sep 2021 15:43:30 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
Hi all,
There are 40+ instances of the following code pattern in Emacs' code base, and
many more in packages:
(if (listp x) x (list x))
It's easy to find single-line instances of it using the regexp [(]if [(]listp
.*[(]list .
This pattern is called "ensure-list" in CL:
(defun ensure-list (thing)
"Returns THING as a list.
If THING is already a list (as per listp) it is returned,
otherwise a one element list containing THING is returned."
(if (listp thing)
thing
(list thing)))
I would like to add a similar function in Emacs, since it comes up so often.
Is that an acceptable change?
If so:
- Which cl-*.el file should it go into, and where in that file?
- Should it be a defun or a define-inline?
- And once it is introduced, should the 40-some instances that could use it be
updated, or left as-is?
- Finally, where should it be documented?
Cheers,
Clément.
- bug#50704: Feature request: Add ensure-list in cl-lib,
Clément Pit-Claudel <=