From unknown Wed Jun 18 22:53:44 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#56685 <56685@debbugs.gnu.org> To: bug#56685 <56685@debbugs.gnu.org> Subject: Status: OBOE in string-truncate-left? Reply-To: bug#56685 <56685@debbugs.gnu.org> Date: Thu, 19 Jun 2025 05:53:44 +0000 retitle 56685 OBOE in string-truncate-left? reassign 56685 emacs submitter 56685 Stefan Kangas severity 56685 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 21 18:10:42 2022 Received: (at submit) by debbugs.gnu.org; 21 Jul 2022 22:10:42 +0000 Received: from localhost ([127.0.0.1]:39392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEeNW-0005Bs-6j for submit@debbugs.gnu.org; Thu, 21 Jul 2022 18:10:42 -0400 Received: from lists.gnu.org ([209.51.188.17]:34080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEeNU-0005Bk-9g for submit@debbugs.gnu.org; Thu, 21 Jul 2022 18:10:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEeNU-0007mt-5b for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 18:10:40 -0400 Received: from mail-pl1-f182.google.com ([209.85.214.182]:44736) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEeNS-0002bB-LO for bug-gnu-emacs@gnu.org; Thu, 21 Jul 2022 18:10:39 -0400 Received: by mail-pl1-f182.google.com with SMTP id q5so3050076plr.11 for ; Thu, 21 Jul 2022 15:10:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=eOF/Qe/brMpaQtx7/hrVtYslgvWFB24uU8vv55WCq5I=; b=e6xdcKLjBxLb6lYKtwz/0dvCaNKDcGpItizdz1OYB87WRFhzAJdwugLh28mdD2m5mV uxIpSBv4c687z14v2h/ZDnNI6uO8HU+wv3YdtMKIEZCbkYLQaE1c6jw5d8y6/gNW+QhE 9M4HH+oxxLfmJSOyffLT/BTaRmzhf+t8ClZKFWbDl5i5jYweXiNexUZKMlcYNoC+zwsY QBRo/jbzkBIx1NiwdNU04YSrVb+QAYGHYVQ1FzIZAb2LxTArOet9wLiHZAbsOVT9CvND +YBmXkYbteTgmwCYsqpMtnqa68qSZPa3MfZmMfhNurmKEoExZPRiNwMAXbZTCqkVKihX dKqQ== X-Gm-Message-State: AJIora/+cN9noObje/cKKTUuEb0r11PxhtUevGtOHMtWE2n7EHRnOHI0 kQX3RD426yaxaazBTsHT+6ZzCVoBqYeTZkoV7LvgQ39J X-Google-Smtp-Source: AGRyM1uDsRNajOFo84pDjKk44ZYO40ucNDG5fhHnBdJ+oE5BLV/7Sj60fAR2FdVlm+5Ju7goZocWMkvCod6IY2x6Lig= X-Received: by 2002:a17:903:244f:b0:16d:17d5:76bf with SMTP id l15-20020a170903244f00b0016d17d576bfmr382123pls.145.1658441437128; Thu, 21 Jul 2022 15:10:37 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 21 Jul 2022 17:10:36 -0500 From: Stefan Kangas MIME-Version: 1.0 Date: Thu, 21 Jul 2022 17:10:36 -0500 Message-ID: Subject: OBOE in string-truncate-left? To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=209.85.214.182; envelope-from=stefankangas@gmail.com; helo=mail-pl1-f182.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) Try evaluating: (length (string-truncate-left "longstring" 8)) => 9 But the docstring says "Truncate STRING to LENGTH". This seems like a bug. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 06:26:21 2022 Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 10:26:21 +0000 Received: from localhost ([127.0.0.1]:40192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEprQ-0004XH-S8 for submit@debbugs.gnu.org; Fri, 22 Jul 2022 06:26:21 -0400 Received: from mout.gmx.net ([212.227.15.15]:60101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEprO-0004X1-9z for 56685@debbugs.gnu.org; Fri, 22 Jul 2022 06:26:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658485572; bh=fCPs+auESTQfZzKm/1tghc7fSj1PhkgZSOU0bLoJakg=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=YuojvFUTL65CQOEDZNbrEuuWw3bSbv88pE1TF1XsfJ/3AbeFrtVhUg4Hy+eieK8bO Q0XLJWeAgfu3BvJAHvHiMmF5tzFnesudIn6oxqtiILXJWob8u8ukHhTFDNMrYUc9Ip hDwxiwVVSmWLT/jgk18KTX1kb4AgJwuVMm7quxoo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from strobelfs2 ([89.246.38.216]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MJVDW-1nuxWm0eqG-00Jqpb; Fri, 22 Jul 2022 12:26:12 +0200 From: Stephen Berman To: Stefan Kangas Subject: Re: bug#56685: OBOE in string-truncate-left? In-Reply-To: (Stefan Kangas's message of "Thu, 21 Jul 2022 17:10:36 -0500") References: Date: Fri, 22 Jul 2022 12:26:09 +0200 Message-ID: <87sfmtfnpa.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:Ej7KGQ7GC6lAt2zKqLpG45E8+ENNHi39hoGrYgBusPIgcPwfegw yvMSsl2/zkLAoM4Wr+M3XOAvEaOA4eSFG2oOMvFc634NQYnAwdD2ibVMf5ZqjhP5lqkCWsm YIdRjfP3ACRL0I9DvpaSwrnRXF/ykuDNd0ZrKRAAnM9NZkZrL/WoWjTbqW4HlpDC+sPXGzr ctvRfw1kmHr8Pap55SxjA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:YCz9UyXtKsA=:fBwxwHRS63Yqf5eWBEfZH/ oKtKFUUcckbuw+rOdws1YzFOEvdGKtAHx62+cTKFa9zBIIBH4YfDq1gFGehbguO099zojc5He sYvamkeDu7nxvU1wysKryqAR3UkAA1U26kKgQ+1AEr/gnI2mDOVfE4gQFy5iMzbHvqqyUEROy u/t6uuWjjoVMTjymENeRi7gAiy5oWBtwG3/1uygZ1LwyPMuRSdiC6DMVc79J4W8/rfvDxlXl1 uL8Dp7yX8JD5y8nhQysB0KkzkRwh1sDf4Vhccr1stcx8SpYZ5yYQmAwhkeewW3tbCLSquC0M3 R/vy48E/icd94B1MjO2kYW1UaQoJQI32/muxQn4HpKU5uf6xZ2hE/7Hu6lzYDEEzcw94ffhv1 mFc/0M2pA4Z2K2sgxuCaTpXVI+RX5eYoJazGrBC0CNhJOQgPKKPSqoMBnKXu1EnV4vjp4b+bc biduWCs6pW8YRU2LY5VhHTr/04UE4Zh64o1m53cLIWtmhSt4Dnuh2gCWxggrE3PBriOI7YQMT Mq4vpX6gI372KpovUtJunvn6gj1vvJ9uuf4ncvRNY6V47Jaddkyj1GHZ4DwCj0sJtOUCbvBdX T2+TxyEp/m3aUuoZPOmBpgwZDqfZKg0IuE87uVyPZFHDQmmbD3+oKPGNpU1+tQzA6lT5BRq2F qD8eXyKv9amELgTQ3rDCo9q8Ql3HswnP7Tt4QvOla5dumPxVoMQt9zYIPRVE2SFMsQHaZfC74 FFmCPOL99K7jsdvrRJ/n3DLIOeZjSZoKo49Co5lsPtKdS6tTLTKJKLWIYnFdSE/8KVKol7QNa yIIHVVwueWezoDh2Z8pvH7lZts6cBE3VAWsGFKCNNMxjzj4PJtW2jlq+CoHzSPmFf0jUpKrom dfCuopx4KIGbKQNegduu+5g6pTi+Zs92hbQxt00WAh5MFYAVlGam/qHZ+lmIWb4RsSTVhtraP FioQJQntto9hUaLFi0ZYkr9AyLG1Cb/rDYO6pJr+lcR8lN3jeLybNtz/ps9CyIwZCCIIn3KCq MRes/nrNuXCfZbMOog0Bmxrx6/GkKLdKBi7aIEP1RSEqpCIoHYTDBATMoB24SldVVwN868rOp xGJrJyT3f8dYYDScy9WgzxdOooIjbJgsf62uA58ju3bFQ36Eq3WaCLTBA== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 56685 Cc: 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain On Thu, 21 Jul 2022 17:10:36 -0500 Stefan Kangas wrote: > Try evaluating: > > (length (string-truncate-left "longstring" 8)) > => 9 > > But the docstring says "Truncate STRING to LENGTH". > This seems like a bug. Yes, and I also think it's counterintuitive that LENGTH includes the length of "...". Worse, if STRING is short enough, the resulting string (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" Note that with the last two examples, the result is longer than the original string, contradicting the meaning of truncation. I think LENGTH should mean just the numbers of characters in STRING after truncation (excluding "..."), and if the result with the prefix "..." is not shorter than the original string, there should be no truncation. The following patch does this. --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: string-truncate-left patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 5037ae47e8..6eefd5d141 100644 =2D-- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -107,12 +107,13 @@ 'string-reverse ;;;###autoload (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." (let ((strlen (length string))) - (if (<=3D strlen length) + (if (<=3D strlen (+ length 3)) string - (setq length (max 0 (- length 3))) - (concat "..." (substring string (max 0 (- strlen 1 length))))))) + (concat "..." (substring string (max 0 (- strlen length))))))) (defsubst string-blank-p (string) "Check whether STRING is either empty or only whitespace. --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D- Steve Berman --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 07:31:19 2022 Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 11:31:19 +0000 Received: from localhost ([127.0.0.1]:40295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEqsJ-0008S7-5o for submit@debbugs.gnu.org; Fri, 22 Jul 2022 07:31:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEqsF-0008Ro-7G for 56685@debbugs.gnu.org; Fri, 22 Jul 2022 07:31:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:59902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEqs9-00080t-U3; Fri, 22 Jul 2022 07:31:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=yKEX4NCNb1aiomuAjOkhxEzcNxe7S6zqq3Gsy/6KEyI=; b=DDk7dCqLB29J Bk6Dya5I26mtS5JXNugMIEcT5cL2Y1fZGNJASp7C4C7Cy8kVS5VmKVGnosOsZIS+z24KUIthVx+E/ 6r1sovtqqopPIUOyexbZPDux71NqNB7BXJNPCbWhLdaWhZvvpXLQMhip+6TCqbRuusVK5wgQiNTK8 HrWBMVeY1VNPaUUPwdqVfFRhRcDNTU8J2+7bPca+rQh1N9WkXnHA5BIwSOwa7v0HpxBFB9ZJCK57G BBUT8/W5Z64JLZ3mxBRZnB5Dj1nIRRvMOm9WHTAMN+6Kqq6gc4WPmWaFPvS16+Z46Yh9e4s1HJVvf 81pONJoVBitwoPBGfsu+KQ==; Received: from [87.69.77.57] (port=3772 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEqs8-0002HO-Kg; Fri, 22 Jul 2022 07:31:09 -0400 Date: Fri, 22 Jul 2022 14:31:03 +0300 Message-Id: <838roll6yw.fsf@gnu.org> From: Eli Zaretskii To: Stephen Berman In-Reply-To: <87sfmtfnpa.fsf@gmx.net> (message from Stephen Berman on Fri, 22 Jul 2022 12:26:09 +0200) Subject: Re: bug#56685: OBOE in string-truncate-left? References: <87sfmtfnpa.fsf@gmx.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56685 Cc: stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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 string > (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. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 08:35:16 2022 Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 12:35:16 +0000 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 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 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 From: Stephen Berman To: Eli Zaretskii Subject: Re: bug#56685: OBOE in string-truncate-left? In-Reply-To: <838roll6yw.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 22 Jul 2022 14:31:03 +0300") References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> Date: Fri, 22 Jul 2022 14:35:02 +0200 Message-ID: <87leslfhqh.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:3HLI50KBefijz1Cb+F1Fd/XPgLwk9FjO08m1MmwxXD+0s61udVc u+AZpKEzbhfVs8//4M+IYSF52xbFKwEhHoM9Xp78znIs9/ZJ5my1pbLrCpUcRVZ+hUcE9ST U1ceZVg5597YJjWsP1gvXTofZxVowXJ7D8ddk2rh8F/afdRP3VwsPqVqB3h2gC4zZPZ5COI psf2gVq8jME2VlDfIeP0A== X-Spam-Flag: NO 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 22aqrtZn94R69HDzVGdOAqIaisZJ83A22JoeAHGVhwsrVdT7BwYsDaxqbDIu4wAUieNX5BWO4 naDmjFV334oK9obU48WldXSN58lx3eW9HLEiew2cxagg7sYIjghvzYxHuL4U/azhVHtv4ocoE huN+YnVh4myU6FjtyVQmBmzgsvsLDEtroYilyQv4IqgNT8bqgvxuxpJPH4eebqjBCw4FgnRn8 OQsHmEJ4lAOM05iMfTw67+UURdo0GTHmpGqJ25ROOIgO3oYUfSKlgaVpH7lf+dpRJ/OzV7OKG gMdGKqck4oFlsMj85AVqaN3WbO0sDgrYg75gn7dQz/ktZGlW2DLZyBGERe19VCW9Zc93XPYcO CljmkfCW5zFsWo53TXTG+yB+ty6z8lGrp7F6aGaVZ2U8/KRWCpBk734SQ== Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 56685 Cc: stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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 From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 09:33:21 2022 Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 13:33:21 +0000 Received: from localhost ([127.0.0.1]:40436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEsmO-0003ak-PQ for submit@debbugs.gnu.org; Fri, 22 Jul 2022 09:33:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEsmL-0003aW-OR for 56685@debbugs.gnu.org; Fri, 22 Jul 2022 09:33:18 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:43648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEsmG-0007XM-5r; Fri, 22 Jul 2022 09:33:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=v8wqvM40+Gaq47KRLoba8Gux2HQ/KpU6YRMuIE0RpRE=; b=KR5SHunBIhmr +VKaVSqViGKwaqrqLoLSnZStJCkozkW6rGudr98mSDvGEsqxjxF+kQoujpc2WnZ6S8PDXRbjcQTGG SQNCypgbGvBf9xYdem4uNZt7VrE6AdRGrCTFE0q4pJzPbrdQfeKR8d98XVvPE2Fz6+kOJ68jyVtSe eXzLeV6TdpGzSKgtOQ4q1UFHQ4Y6cE1pgSkYu0dis8d6NiK59VvSz3NxZhkrWrnJ878JHOWz5ecrW w/rVSzASIXlnkfYQ6B2K5MZSnGOaQnAB02JFF/Wz3OkQtTFdnx758JVUDK1IbGXdF9OYk+wc0uY75 pibwiYzKSH8Y4+qi+g/yLA==; Received: from [87.69.77.57] (port=3293 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEsmF-0002VW-Kg; Fri, 22 Jul 2022 09:33:11 -0400 Date: Fri, 22 Jul 2022 16:33:07 +0300 Message-Id: <83zgh1jmr0.fsf@gnu.org> From: Eli Zaretskii To: Stephen Berman In-Reply-To: <87leslfhqh.fsf@gmx.net> (message from Stephen Berman on Fri, 22 Jul 2022 14:35:02 +0200) Subject: Re: bug#56685: OBOE in string-truncate-left? References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> <87leslfhqh.fsf@gmx.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56685 Cc: stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stephen Berman > Cc: stefan@marxist.se, 56685@debbugs.gnu.org > Date: Fri, 22 Jul 2022 14:35:02 +0200 > > 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? When STRING is part of a longer string. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 22 11:23:39 2022 Received: (at 56685) by debbugs.gnu.org; 22 Jul 2022 15:23:39 +0000 Received: from localhost ([127.0.0.1]:42202 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEuV9-0000xq-0F for submit@debbugs.gnu.org; Fri, 22 Jul 2022 11:23:39 -0400 Received: from mout.gmx.net ([212.227.15.19]:50819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oEuV4-0000xY-RY for 56685@debbugs.gnu.org; Fri, 22 Jul 2022 11:23:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658503408; bh=AiYGsOMAFmlta0Xdok6cPzqdtc+FjJ5rmjRtDLClW9s=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=ZiGRasbpVaK0Q8X9vTCZl37AnK1rb3X/aVR/ovy/EpF4QzMHOCm7k9/uZ9lIBGqa1 Mv4gBxMT16OqixXsRS0IuDbLrwqLKpDQLFixuBJYSxFRUnAMrlSDOiFH8cH6pYoROn EAZqwnPuYusMSS4W33MeHHBX/07rrwR5r4WEcEi4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from strobelfs2 ([89.246.38.216]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M1poA-1oCids11jc-002KiD; Fri, 22 Jul 2022 17:23:28 +0200 From: Stephen Berman To: Eli Zaretskii Subject: Re: bug#56685: OBOE in string-truncate-left? In-Reply-To: <83zgh1jmr0.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 22 Jul 2022 16:33:07 +0300") References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> <87leslfhqh.fsf@gmx.net> <83zgh1jmr0.fsf@gnu.org> Date: Fri, 22 Jul 2022 17:23:27 +0200 Message-ID: <87h739f9xs.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:Natv4tUIfHxSuxEYoQvS6VWt9nobBf6Vr4ECKi7ySaHz4hgXwQh x7SKJI2eEfYkx4bdi+Xxms/ohSrj/m1pWLTAJH/M1wLgFvZlkAk7R1BlU3HtNjD5QUmoa5a /9siYPLzqFworS26M+usPua1XCq/pSDbkQnHPcbck6WjOAjSzboBQHelbY2+OUizmNFqZFK JgFYCJC9LwaYHJ/agqmgg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:WbQA8W0jGuQ=:EHS8JVvbx7YOeNWhhMTFla Ya0zowNFsuX31xYY84C9RVpEeKfBWsK/Q2COcpBM0JuqHR3+IOiWFxX2lxgcfmTJvyad7iO3V cWx3NNpD49fQW2ogdO9goGY7pn6ggTdVARl6tUBSNo4wjBNIH+9gAfWkg+4FoLDgHhJ0CEokb DS2H1Wfmw4zc9QVl986Z2DllVFPdm/iSshiLi9UIwWB90ssIk3SNvD2mdcoT/EqCb6rri0vm2 AcSGMvij0QkDExOKeLSFAIK+HxljSkPWIpb4T2R/bUuV5WR6FIO3bSf1KoaIrAktYj+Ck/tgZ tt8V6h70N+0ju6N+ojTsdI7D9KGfOBQ9lXk5e2P7JE5KXK6h/OkL2bzHIIgyP+pOFOWLBhyN2 mbCOUFYFscdJSlRYJPpMaqhUNJrnKcqNwzHtGlIqe5wTFfWFzFen0G0n4NL/qyG2bxp9bP3xO yQEYzLwBnTu13Q925pupQgZvhIO68K2DBpJprhYVZgKWv06JZhZ+goO/yzuj7KHyddHiEayVD EdMEXN0Lb8p7pHTqMcUaw6TzthDr7XkSSye2a70RGZQJYgU4p8sCGHO80oDmgGSwGlzVWKNgR jGMpXsz3fIQOzd67zZooQRGmXyBQ2JDsboH+vqThu1ouAp96OprgqGbU9oqO369EYcq56yixq ostXShTJVxZxgfwC42iQAHaUx0kANpMWAvCisSaC778ez7BEw4eWr+FBCo7B2MOqNJpSZ638e 6i4/N7RU8lZ49e+0wXdjbQ/XAb6Rd4cSL2jkjNzj3NkVI2P7HuZA/7UXxx3zPDl4sdOSqKxr6 I4RnxSnfM+MVwqFLqvXiKwkMYMzwabR3xhcwJTWYEkGsBSv34q6leLn1Mb4jGsOnDKIwX+Xw3 xUZYgBSJgZKiWLXvQZAt4y15Ijf4JmG8GtblYnRrzDKhEvZobdxTdTjR15+h1GJVsgILE/N7l DtOKLQbzlNi5OLry42H4A6AVXZicq4fcs4e29oMbxPM6r3qHoiDvDU/fb/FHr2clkuD6Tl+hu AtMkptA7nKlXk6HP6a2bUCI8PI7mqXUmCwzQayUuM5A2EUhQ5gGR83EbXmhDzHsNxpLwRhIVz UD/qYB2Ejt4eD3z+vtTvD//rXGwdSnQXAnPXwtyATJR+dDUr4W+dM/Gpw== Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 56685 Cc: stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Fri, 22 Jul 2022 16:33:07 +0300 Eli Zaretskii wrote: >> From: Stephen Berman >> Cc: stefan@marxist.se, 56685@debbugs.gnu.org >> Date: Fri, 22 Jul 2022 14:35:02 +0200 >> >> 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? > > When STRING is part of a longer string. I don't see why that is relevant, and one of the few uses of string-truncate-left in the Emacs sources seems to confirm my doubt, namely, in gnus-shorten-url, which results in displaying e.g. "cvs.savannah.gnu.org...emacs.svg?view=3Dlog" instead of "https://cvs.savannah.gnu.org/viewvc/emacs/emacs/etc/images/icons/hicolor/= scalable/apps/emacs.svg?view=3Dlog". But if the too-long string is "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/", then with the current string-truncate-left gnus-shorten-url "shortens" it to "cvs.savannah.gnu.org...ewv/emacs/emacs/1/". AFAICS replacing the three characters "/vi" by "..." here just loses information. Can you show a specific case where such a length-preserving substitution is preferable? Steve Berman From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 23 02:58:53 2022 Received: (at 56685) by debbugs.gnu.org; 23 Jul 2022 06:58:53 +0000 Received: from localhost ([127.0.0.1]:43052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oF96B-0008T7-6Z for submit@debbugs.gnu.org; Sat, 23 Jul 2022 02:58:53 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oF965-0008Sk-QC for 56685@debbugs.gnu.org; Sat, 23 Jul 2022 02:58:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j1GhvUxSzaGjYivX8+8Cviq/ldzg+WVVzilOyjLFXhU=; b=foel4g/GpKxHddCdFSgnSD12xm LsbeHU0XVxPX+ZZVaeR2KLszU7cZR1NCPZyuNOVZsqryCaysnWkCNW1lqJGbi3s7OxjMEx8Pz5LsX X4ROxO9P9jjA52yGmi1QpqGzbx7uW0vg+BYd1fho2KAY1amyFlxyb7gjyKC0kQuGYAQU=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oF95w-0007yZ-2s; Sat, 23 Jul 2022 08:58:38 +0200 From: Lars Ingebrigtsen To: Stephen Berman Subject: Re: bug#56685: OBOE in string-truncate-left? In-Reply-To: <87h739f9xs.fsf@gmx.net> (Stephen Berman's message of "Fri, 22 Jul 2022 17:23:27 +0200") References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> <87leslfhqh.fsf@gmx.net> <83zgh1jmr0.fsf@gnu.org> <87h739f9xs.fsf@gmx.net> X-Now-Playing: Boris's _Documentary of Akuma no Uta_: =?utf-8?B?IueEoQ==?= =?utf-8?B?44GN5puy?= -Naki Kyoku-" Date: Sat, 23 Jul 2022 08:58:35 +0200 Message-ID: <87ilno5n8k.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Stephen Berman writes: > But if the too-long string is > "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/", then with the > current string-truncate-left gnus-shorten-url "shortens" it to > "cvs.savannah.gnu.org...ewv/emac [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56685 Cc: Eli Zaretskii , stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Stephen Berman writes: > But if the too-long string is > "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/", then with the > current string-truncate-left gnus-shorten-url "shortens" it to > "cvs.savannah.gnu.org...ewv/emacs/emacs/1/". AFAICS replacing the three > characters "/vi" by "..." here just loses information. What's the parameters when that happens? I get: (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/" 41) => "cvs.savannah.gnu.org/viewv/emacs/emacs/1/" (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/" 40) => "cvs.savannah.gnu.org...wv/emacs/emacs/1/" Anyway, I think the examples show that this function isn't very useful if LENGTH is very small -- it really does want to add "..." to signal that some shortening has happened, and that may make the string longer. But just returning "d" for (string-truncate-left "and" 1) isn't correct either. I've now fixed the originally reported off-by-one error when shortening, and documented the quirks of the function in Emacs 29. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 23 02:58:55 2022 Received: (at control) by debbugs.gnu.org; 23 Jul 2022 06:58:55 +0000 Received: from localhost ([127.0.0.1]:43054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oF96F-0008TV-BO for submit@debbugs.gnu.org; Sat, 23 Jul 2022 02:58:55 -0400 Received: from quimby.gnus.org ([95.216.78.240]:47364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oF96A-0008Ss-4p for control@debbugs.gnu.org; Sat, 23 Jul 2022 02:58:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PmDmGz+o+31ecIug012GgOX6l69IqKAdaI82vjM6pBs=; b=ebgpJvO7UXU/J1555xZ36eBQt+ cJ4Rv+jUGKEwMcsUy23IGdd63qvxfksr73n5sKGhlUY0ndSAGabWmmQ1p5vfWL2CbjruRzRjH0lX3 /YgrmOktXWXHgYbIIZW3R40AOMmYX7M5tZ5NDbLwo52FdN8WsbrbwKNCqQyf6yg5dZzI=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oF962-0007yj-7W for control@debbugs.gnu.org; Sat, 23 Jul 2022 08:58:44 +0200 Date: Sat, 23 Jul 2022 08:58:41 +0200 Message-Id: <87h7385n8e.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #56685 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 56685 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 56685 29.1 quit From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 23 04:52:08 2022 Received: (at 56685) by debbugs.gnu.org; 23 Jul 2022 08:52:08 +0000 Received: from localhost ([127.0.0.1]:43377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFArn-0001tw-V3 for submit@debbugs.gnu.org; Sat, 23 Jul 2022 04:52:08 -0400 Received: from mout.gmx.net ([212.227.15.19]:52125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFArl-0001t4-CT for 56685@debbugs.gnu.org; Sat, 23 Jul 2022 04:52:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658566319; bh=Yo474P6inFRFyO2jPf4hwFXaLfW3PJDxqBp71n8wBJw=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=BluvGKC0dXwKo18ZM5Du59GGvei1msheJBYBSZZpJwWf/0WbOJwtvT5Lvl9DB/Zys uc2hCHqJrB1qG78xsgU13qb+BoIoJnp8XdA8vYkN9P0TOkxCo038Gp+Hv8kK7s4TtQ oOYk4Y5gYUohLB/LkEr9CEV46zSazFftaoqu8WJ8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from strobelfs2 ([89.246.38.32]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mwwdl-1nGsHE1x87-00yOc5; Sat, 23 Jul 2022 10:51:59 +0200 From: Stephen Berman To: Lars Ingebrigtsen Subject: Re: bug#56685: OBOE in string-truncate-left? In-Reply-To: <87ilno5n8k.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 23 Jul 2022 08:58:35 +0200") References: <87sfmtfnpa.fsf@gmx.net> <838roll6yw.fsf@gnu.org> <87leslfhqh.fsf@gmx.net> <83zgh1jmr0.fsf@gnu.org> <87h739f9xs.fsf@gmx.net> <87ilno5n8k.fsf@gnus.org> Date: Sat, 23 Jul 2022 10:51:58 +0200 Message-ID: <87h738mcsx.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:JVxugHk9hsEJx9bHtgACMWUPXwVIlBcNcUYolKwG9+jOiaifFyD P0JiW/2HlJWxpTv7WQViGYriA2oxbBArCLuMPlvHDsGR9gNr2/+1IpApllnnmW19JTby7e8 OcGb5cWNn9wKRrqtlMXHUcSUnknrZ0i+8lYWFifCZHUuHGugCDHexqY4Wfq375CMCG7i7CD /t0UmenKJLubOv9TvaQ5w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:GabnsVBZ360=:gJsXeqLntr7qarwtNNl65x M90qwVXmRElL3FE8DXgVcgoMnlxPZEXCSSQq/4Qhey5GYiO56w5bf+twtaaVZademdpBH4rQT FZ0kmdONREDxgltFNQQfxLvH1txNNY+J+5BO2aWCK4eTdO3/SvtARdm/5EOppf/O580BDutkk Y4p/oQArjrq+fN6jxQqCnx36RBFbcSFiZMv8Evk7L2H2nQ/ZcuFbLX0vVDcBWlBh9GRWvYnfk h+QsiTOIRLMji1fq/jGhBREa0fsS+YgXSS6TuVrnO5WnImWoIXCw17/GOHhRdso0lgRCFl8qh 6Kon3UqJoe/g9xyDiG/rkymI7PyMeCN2YSv+DJRzjuETEZEchW6XPPpHBbKOERtJ82EhIk5f4 O89Z8wuDjnGvQgYAwruaaCozZA1PlY8KMZPxTQgr+KKj0nqqRhkYClOo00Hwa7Tkt0I7b9+dL +wk6X+Orq9NieHPDuKF8IH2nI9OeJyFQZGFK/Ag5x27ygkuGNQslkkBi4ZMR0MU/4lkOY5QNJ Rywn02R07+3WbgQ/Ea2IT/Q2qc4J0NtgbtPFI5ZxJOqTWAs/AhtZn+ZODEQLwV5XbdKIXSMVd 6NJqLIvwA5I1B0NLDsdKT7w+H2g8FVX2M5DksU0TzzyUxO7ScZTvEy74+BeYokmNNcQLq3ecb IgTSALDgEzTsqCWMJh8nPvV4eBstesLlZCpKlxXg45e/YqcVdYw2tTEwpv94QOhcJ9syqAS6A 2U7Goe/JUcDkfrSpgeMnV5Bqg55Pci9SSZPKuyt9CjiV6Ga6qkMstLSA1KTMFdKnSvVRBvsq+ Ic9Q3N8HBuNhcguP2qB1oNLvSF9n43DvYPOZyYlCGFP7IpYMxxH1yecuccBeTAfyOQsj/zl59 xPflKL1Jy3I2ijBO4lxH4s/x88sHbeO4WrFYQvAOKjCfdvlSoXUebEhGF/u31ZcQd1Hs+d8KJ 7RVlDTv3ieTiGBsMkxi7hn/xaS3BmZaqhqkRf20oIieIwoVqSMgA4MsV6oyVX56+SxAzYvSBT nFG+gVlrrIu+I0IH1B8bUXMqbkvBA+lUKCSpqxG+wyQTzWfLjT4/SzcXMAv13r/YAWMh2FhMy xoMvA376Z8gjfUmEVryKwwOOz05QYi19h2fRv4Wdq5lRKgk1inazoVdfQ== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 56685 Cc: Eli Zaretskii , stefan@marxist.se, 56685@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Sat, 23 Jul 2022 08:58:35 +0200 Lars Ingebrigtsen wrote: > Stephen Berman writes: > >> But if the too-long string is >> "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/", then with the >> current string-truncate-left gnus-shorten-url "shortens" it to >> "cvs.savannah.gnu.org...ewv/emacs/emacs/1/". AFAICS replacing the three >> characters "/vi" by "..." here just loses information. > > What's the parameters when that happens? I get: > > (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/" 41) > => "cvs.savannah.gnu.org/viewv/emacs/emacs/1/" > > (gnus-shorten-url "https://cvs.savannah.gnu.org/viewv/emacs/emacs/1/" 40) > => "cvs.savannah.gnu.org...wv/emacs/emacs/1/" Same here; in my example, I used 40 since that's what gnus-summary-browse-url (the caller of gnus-shorten-url) uses. > Anyway, I think the examples show that this function isn't very useful > if LENGTH is very small -- it really does want to add "..." to signal > that some shortening has happened, and that may make the string longer. > But just returning "d" for (string-truncate-left "and" 1) isn't correct > either. Yes. My main motivation for proposing to omit truncation (and prefixing with "...") of too-short lines was for using string-truncate-left in a loop over differently sized input strings, but of course that can be handled by suitable code in the loop. > I've now fixed the originally reported off-by-one error when shortening, > and documented the quirks of the function in Emacs 29. Thanks, the doc string makes sense to me now. Steve Berman From unknown Wed Jun 18 22:53:44 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 20 Aug 2022 11:24:11 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator