From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: master 87e422f: Beef up the Emacs string utility set a bit Date: Mon, 21 Dec 2020 15:20:56 -0500 Message-ID: References: <20201221175345.27592.89597@vcs0.savannah.gnu.org> <20201221175347.9F1B820B76@vcs0.savannah.gnu.org> <87eejjdn8e.fsf@gnus.org> <87a6u7dmnw.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1098"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 21 21:21:59 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krRgt-00009m-Aj for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Dec 2020 21:21:59 +0100 Original-Received: from localhost ([::1]:34154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1krRgs-0003hM-CL for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Dec 2020 15:21:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krRfy-0003DY-2P for emacs-devel@gnu.org; Mon, 21 Dec 2020 15:21:02 -0500 Original-Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:44579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1krRfv-00078P-JZ for emacs-devel@gnu.org; Mon, 21 Dec 2020 15:21:01 -0500 Original-Received: by mail-qk1-x729.google.com with SMTP id v126so5471942qkd.11 for ; Mon, 21 Dec 2020 12:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Tw95w4/NDV983WqmUtL3Vi+8Bl+Yt/GvR0smGmCqGV8=; b=fvm8XidIPMsHGRufmAOhLT1WBZYedO8YiN7ivSpmockQooawjfZuWe63vE8i8lwrRp EpIQiBiSl2ecET5PfnPGoNLLHNfEHuyyjTU1RIbIt+BJf82Sh+u4PUpQOHgugQQmz/In jGOurENf/ROqzhVvBS9yTSc6DQ9kuu2YSuDEsXvsY5hcbKmjSjDCvlI/iZ+32GL1SYZ6 gTPUfd3GmiZn5MxNuqqklVuBFOrZCviIWEg4GVOPL7H/aGES7qSHhBC8BqIlI4q1bEHr YbqXKNCByopOai1N7m01AMMtENdBa8nh61Dc+NiMJOmcdFLNQAZquoA3TqafXCaxQxCR s++w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Tw95w4/NDV983WqmUtL3Vi+8Bl+Yt/GvR0smGmCqGV8=; b=AHVbMKWpl0iU75TCRtKr1MkfiWyGW697SlB2x4Rmh+JRugg3sZnH81nFa7ib3CxYX+ quBIce5ehUqpbySHp0C0tIn5q0SrPR7vW2xVjd2M2D6uEUkGihyB+2wh+FeeCuuQ/18Y lAj4vDZN/LTk6maZuZsS/8eQn4RsksGvervNeVRxpc2Cs1vD7Lo1T6gZIFRc+iNZegTO ZJfZcYs18YVUa6L2x4/Gtl8Ydnacly1r3Io6dEiaGxghqw4U7ErZlWmx4tLWYucLCCjw /ykaXUja3tkxi3uqVMRMdWJIDhhTSvm/pZW0rZ/IdkIpfV4b8ZXWd3EP2bG1yo5ozZOU ncKQ== X-Gm-Message-State: AOAM531SCaWH0OOnlfEPc/2wnx7jcc2gSnu9jDarO9Oua+SfeOjEd0wX sRYeFy8uBoc60JVNDMG5uH+oLG6BH7s= X-Google-Smtp-Source: ABdhPJxz+2mr8MeI2KmTGPkndFigXNWwlojsoAuuw8+D8kpeAR41ABShDDNLdcS7nzA7HNfEYJ7Qbg== X-Received: by 2002:a37:9f8d:: with SMTP id i135mr18631126qke.439.1608582057907; Mon, 21 Dec 2020 12:20:57 -0800 (PST) Original-Received: from [192.168.1.3] (c-24-61-240-80.hsd1.ma.comcast.net. [24.61.240.80]) by smtp.googlemail.com with ESMTPSA id a203sm5065908qkb.31.2020.12.21.12.20.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Dec 2020 12:20:57 -0800 (PST) In-Reply-To: <87a6u7dmnw.fsf@gnus.org> Content-Language: en-GB Received-SPF: pass client-ip=2607:f8b0:4864:20::729; envelope-from=cpitclaudel@gmail.com; helo=mail-qk1-x729.google.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-1.233, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:261431 Archived-At: 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.