[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Imports / inclusion of s.el into Emacs

From: Philippe Vaucher
Subject: Re: Imports / inclusion of s.el into Emacs
Date: Sun, 3 May 2020 15:47:13 +0200

>> split-string aliased as string-split
>> downcase aliased as string-downcase
>> upcase aliased as string-upcase
>> format aliased as string-format
>> concat aliased as string-concat

>Don't do this.  Just learn these 5 names, or use apropos, as
> has been suggested.

Just curious, if these were to be introduced today, would you also name them that way? What possible genericity is there about downcase/upcase? Okay they work on strings and on chars, but it's pretty clear their topic is "characters" (string) no? 

> Check out http://www.lispworks.com/documentation/HyperSpec/Body/f_stg_up.htm and http://www.lispworks.com/documentation/HyperSpec/Body/c_string.htm

> Do you think this organization would be useful? What if it had a cool
> font and some cool logos? :-)  I ask because that put me off at first, it
> looked mouldy.)

Yes, that'd be very useful and it's more or less what we are asking to be able to do. Again curious, do you think they made a mistake when they named it `string-downcase` there and not `downcase`?

>> s-truncate (len s)
> truncate-string-to-width (I got there with apropos truncate.*string btw).

Okay then let's alias that to string-truncate.

>> s-left (len s)
>> s-right (len s)
> Add an "from-end" arg to subseq?

Why is there substring if there is subseq then?

>> s-repeat (num s)
> (cl-loop repeat num concat s)

What if I don't know cl (like I a significant number of package authors) ?

>> s-capitalize (s)
> capitalize,  also works for chars.

Alias it to string-capitalize :-)

>> s-reverse (s)
> reverse, also works for sequences

Ah, this one I didn't think worked on strings. Thought you have to split, reverse then join. I agree this can be left as a generic algorithm.

>> s-contains-p (needle s &optional ignore-case)
> string-match-p

That can work, tho the mental path of having to do a regexp match while regexp-quoting the string just to do a plain text search feels very inneficient.

>> s-blank-p (s)
> ugh. nil is a string?

"is the string blank?" is a concept in many languages, but I understand it can be surprising at first. The idea is that very often when validating user input you filter for nil, empy string or trimmed string.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]