From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#56685: OBOE in string-truncate-left? Date: Fri, 22 Jul 2022 14:35:02 +0200 Message-ID: <87leslfhqh.fsf@gmx.net> References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20554"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: stefan@marxist.se, 56685@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 22 14:38:34 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oErvO-0005Ae-94 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Jul 2022 14:38:34 +0200 Original-Received: from localhost ([::1]:56132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oErvN-0006RV-6i for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Jul 2022 08:38:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oErsw-00046V-CP for bug-gnu-emacs@gnu.org; Fri, 22 Jul 2022 08:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oErsw-00068a-3N for bug-gnu-emacs@gnu.org; Fri, 22 Jul 2022 08:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oErsv-0001v6-Pu for bug-gnu-emacs@gnu.org; Fri, 22 Jul 2022 08:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Jul 2022 12:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56685 X-GNU-PR-Package: emacs Original-Received: via spool by 56685-submit@debbugs.gnu.org id=B56685.16584933167316 (code B ref 56685); Fri, 22 Jul 2022 12:36:01 +0000 Original-Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 12:35:16 +0000 Original-Received: from localhost ([127.0.0.1]:40373 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oErsB-0001tw-Au for submit@debbugs.gnu.org; Fri, 22 Jul 2022 08:35:15 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:51837) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oErs6-0001tX-37 for 56685@debbugs.gnu.org; Fri, 22 Jul 2022 08:35:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658493303; bh=xmU5lwubtUg64hNe0krYclqXXz3rnjDDykvntYN60TI=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=QySjNBc6glpf9p9xq+zTM4G5golQxQXycInHGievSu0TIrCvMCAGasVZUyttT1JEM X8Xo/2eSe1XLN1d8o+w2jFxiZ6pLepLCntk3xH06mLxK4rOEHl1EG3rQ9ENXpY4XuR p9CDYOcMk/4IW1uYvsV9hJO3O+rap7rcAYFqBG28= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobelfs2 ([89.246.38.216]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6lpG-1o8naj2LFu-008N5M; Fri, 22 Jul 2022 14:35:03 +0200 In-Reply-To: <838roll6yw.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 22 Jul 2022 14:31:03 +0300") X-Provags-ID: V03:K1:3HLI50KBefijz1Cb+F1Fd/XPgLwk9FjO08m1MmwxXD+0s61udVc u+AZpKEzbhfVs8//4M+IYSF52xbFKwEhHoM9Xp78znIs9/ZJ5my1pbLrCpUcRVZ+hUcE9ST U1ceZVg5597YJjWsP1gvXTofZxVowXJ7D8ddk2rh8F/afdRP3VwsPqVqB3h2gC4zZPZ5COI psf2gVq8jME2VlDfIeP0A== X-UI-Out-Filterresults: notjunk:1;V03:K0:R945x/zaGTE=:bOYQuERS75bqFqDrhO2Gim 8yUYtrUDBQr7EePPeLQbraULT952zE4Ws6dGhhso/ZP6pZfjwa5oNqgGtMi1mbxz7pTZcPSyc R2Z02mld9G14CKlgrF2c7p5VhmYzLQtaKslH7n4W/RXb/DdiTEoy6mGqo9ixRN25BUeHMYPWJ x0iCxxwaqq1cMamJoII2NreFy+YRt+88HEBicdgy6GKujUHxuRWmuF+Q6h7YUxeQkjdAZVf93 TLyvMMFxPS3hrdJGe8hLSeTqO+XAB/89awiVwMwfSNf2Q3uMlot0zmuJyWS8aCMVXvz67GCTm /i5CLFFmn41XMzegxKRMaSLNzPbdeNHViHDlBgHvhoUBNWDpusJn4opst0Eis6plzarz4qwCo Hes35pbVE/QPNEqq8EUpMShOUKUdDhq5fEbR0TuZUPweMy7Po63vRooU+NgFfs6bnFMytSQX3 s+2Fbp707UOQPXMofQAB/cfGR6WOIF+/wpFIzXYD+BuaS5/BdwHPpaPT+K7p5I8sefVvos0pV kPDpQlE12TzRye7jiDgXZfGU44bOJ3YgpKGmiicbn2T1gVG/mb+tmRXChkORhwvp+kV3bfNYS oL0WqZm8ig4kwGAPcvYAMi9o6M4gyr+F4R5CfsI4iG0OHRYB9LbGhdxgDiB10DdXYdA2tGI1X NA56sna6NfT7WM+tlryyFXcqYwPovXLPNYBJ56EGggCsqzHs1PUtCi02I7iMGCKOaF031cJTr 22aqrtZn94R69HDzVGdOAqIaisZJ83A22JoeAHGVhwsrVdT7BwYsDaxqbDIu4wAUieNX5BWO X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:237617 Archived-At: On Fri, 22 Jul 2022 14:31:03 +0300 Eli Zaretskii wrote: >> Cc: 56685@debbugs.gnu.org >> From: Stephen Berman >> Date: Fri, 22 Jul 2022 12:26:09 +0200 >> >> Yes, and I also think it's counterintuitive that LENGTH includes the >> length of "...". Worse, if STRING is short enough, the resulting strin= g >> (with "...") can be longer than LENGTH: >> >> (string-truncate-left "band" 3) >> "...d" >> (string-truncate-left "band" 2) >> "...d" >> (string-truncate-left "band" 1) >> "...d" >> (string-truncate-left "and" 2) >> "...d" >> (string-truncate-left "and" 1) >> "...d" > > The above calls make no sense to me: since it is known up front that > the function will prepend "...", what else does the caller expect from > such calls? > >> Note that with the last two examples, the result is longer than the >> original string, contradicting the meaning of truncation. > > The function truncates STRING, not the result it returns. So I see no > contradiction here. And again, what would you do instead? Because > this: > >> (defun string-truncate-left (string length) >> - "Truncate STRING to LENGTH, replacing initial surplus with \"...\"." >> + "Return STRING's last LENGTH characters prefixed with \"...\". >> +If the resulting string with the prefix is not shorter than the >> +original length of STRING, return STRING unchanged." > > again makes no sense to me: you have forcibly prevented any Lisp > program from truncating STRING because you personally don't like the > result in these cases. But the fact that you don't like it doesn't > yet mean it isn't a valid use case. If your applications don't want > truncation in those case, it is easy to provide a trivial wrapper > around string-truncate-left. Currently, the result of applying string-truncate-left to STRING can be a string just as long as STRING but beginning with "..." instead of the first three letters of STRING. What is a valid use case for that? Steve Berman