Closed kilianmh closed 1 year ago
to be clear, the inconsistency is for the functions we import and re-export from cl-change-case:
#:no-case
#:camel-case
#:dot-case
#:header-case
#:param-case
#:pascal-case
#:path-case
#:sentence-case
#:snake-case
#:swap-case
#:title-case
#:constant-case
STR's upcase, downcase, capitalize
call the built-in string-
, and fix their weird behavior to return the string "NIL"
with nil. Otherwise they keep CL's behavior.
So +1 for the fix.
Here is a simpler imprementation using cl:string
to coerce s
into a string
(defun no-case (s)
"Return the no-cased version of `s'.
Calls `cl-change-case:no-case' after coercing `s' into a string,
but returns nil if `s' is nil."
(when s
(cl-change-case:no-case (string s))))
Then the behavior (and look) of all casing functions would be (mostly) consistent:
string
, character
, symbol
, null
nil
when nil
inputIf you like it this way (also the docstring), I will create the PR accordingly.
+1 LGTM
The
cl-str
functionsupcase
,downcase
,capitalize
do behave different than the casing functions from cl-change-case. The functions fromcl-change-case
do NOT:nil
when givennil
as inputWe could fix it like this:
That way users can choose themselve
cl-change-case
which soon only accepts strings orcl-str
which also acceptsnil
and other symbols (like the inbuilt casing functions).