[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 87e422f: Beef up the Emacs string utility set a bit
From: |
Clément Pit-Claudel |
Subject: |
Re: master 87e422f: Beef up the Emacs string utility set a bit |
Date: |
Mon, 21 Dec 2020 15:20:56 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 12/21/20 1:44 PM, Lars Ingebrigtsen wrote:
> I've been going through
>
> https://github.com/magnars/s.el
>
> to see whether there's anything there that seems both 1) useful and 2)
> Emacs doesn't have already, but there was less than I remembered,
> really. With the five functions I added, the rest are mostly just
> aliases for stuff we have in Emacs 28.
>
> Things I wasn't sure about:
>
> s-chomp (s)
>
> Is this really useful? Emacs is so un-line-oriented that I can't recall
> having removed newlines from a string ever...
Look for (replace-regexp-in-string "\n$" "" and variants, or string-trim-right.
One common use case is in conjunction with shell-command-to-string. Even if
it was in Emacs, though, I'm not sure I'd find it and use it instead of
string-trim-end.
> s-shared-start (s1 s2)
> s-shared-end (s1 s2)
It's useful for computing relative paths (as done by file-relative-name) and
for abbreviating entries in a list (finding the common prefix of many entries
and abbreviating them all that way). It's a trivial extension of
compare-strings, but discoverability isn't great. The implementation of
s-shared-start in s.el is inefficient, but my patch
(https://github.com/magnars/s.el/pull/134/files) was never merged.
An efficient implementation of s-shared-end would be nice, but I think it would
require generalizing compare-strings.
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Stefan Kangas, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Basil L. Contovounesios, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Clément Pit-Claudel, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Clément Pit-Claudel, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit,
Clément Pit-Claudel <=
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Clément Pit-Claudel, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Basil L. Contovounesios, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/21
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Mattias Engdegård, 2020/12/22
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Lars Ingebrigtsen, 2020/12/22
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Mattias Engdegård, 2020/12/22
- Re: master 87e422f: Beef up the Emacs string utility set a bit, Alfred M. Szmidt, 2020/12/22
Re: master 87e422f: Beef up the Emacs string utility set a bit, Stefan Monnier, 2020/12/21