From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#69822: [PATCH] format-spec pads when it should only truncate Date: Sun, 17 Mar 2024 13:11:25 +0100 Message-ID: <87frwpxdle.fsf@epfl.ch> References: <86bk7e79y5.fsf@gnu.org> <868r2h5qch.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21911"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Adam Porter , 69822@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 17 13:12:54 2024 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 1rlpNm-0005Wa-CR for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Mar 2024 13:12:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rlpNK-0005yC-T3; Sun, 17 Mar 2024 08:12:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rlpNI-0005xn-Np for bug-gnu-emacs@gnu.org; Sun, 17 Mar 2024 08:12:24 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rlpNI-0000YO-FK for bug-gnu-emacs@gnu.org; Sun, 17 Mar 2024 08:12:24 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rlpNt-0005tf-Ti for bug-gnu-emacs@gnu.org; Sun, 17 Mar 2024 08:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Mar 2024 12:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69822 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69822-submit@debbugs.gnu.org id=B69822.171067753322584 (code B ref 69822); Sun, 17 Mar 2024 12:13:01 +0000 Original-Received: (at 69822) by debbugs.gnu.org; 17 Mar 2024 12:12:13 +0000 Original-Received: from localhost ([127.0.0.1]:57734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlpN6-0005sB-Vu for submit@debbugs.gnu.org; Sun, 17 Mar 2024 08:12:13 -0400 Original-Received: from mail-ed1-f43.google.com ([209.85.208.43]:40141) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlpN4-0005rw-H9 for 69822@debbugs.gnu.org; Sun, 17 Mar 2024 08:12:11 -0400 Original-Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-568b9188673so506079a12.0 for <69822@debbugs.gnu.org>; Sun, 17 Mar 2024 05:11:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710677487; x=1711282287; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bjI6Raer2XnRoBIsrPsrxWE9KbgtMbnpqEkijdVeffA=; b=a1cYhMg65DPrlP6HlOk4DgyfGsUtxDz7jDH3whmbC+cDD0hDULpaV/fRBY7R3lc/J7 MNxpSRl1tWnxnKOjVPa092KYQXTV5en7/HrmzKYVM0WuoCPXYcNDSjD01WB9bB44Fazf sTBL8lzom7SrOF3NPS1+chFQcsgye0lWInDLpWurPgKV21AaY9iNh0Ve3DmJcvAD4DHn osI7OlpfUMoV9H4Hxfrf/MRc0hUOlubJYg8n55kvbkF+fxUC2i/JPd/fkte7b9kFLKve D5JuvM6WdwwaLDlFwyYuEB7Gh1A+vYa3oIMSwB5QFeks3sOwXKE4iZPq5JN1xyuSPmkg xEEQ== X-Forwarded-Encrypted: i=1; AJvYcCWBxc8vColC9P3zxhPbFRT4X9B4BTG2gbhr7KAwu0LNjaLiVJ/0UiGVSX6qxxd0ZYhJxsYT8VnUpBJrw+5mVMxYcU0eyF4= X-Gm-Message-State: AOJu0YwrL8GCfhkh/ccN44VeP1rAEIM+zuO++fvYXaYEeU6D3kXCQX7A 42MdmNcPr+LqPJoOvnTIaj1h89CDOevl2YXnE5jlu6snRD/TX3co X-Google-Smtp-Source: AGHT+IHSJai/T0pQqImeQ+w8wcWcJtmM7+ql+oBUxhZLj4TIetwpwJogK7yq7FOQULY6987iyq1/tA== X-Received: by 2002:a17:907:78c6:b0:a46:6a59:44c4 with SMTP id kv6-20020a17090778c600b00a466a5944c4mr6700568ejc.3.1710677486756; Sun, 17 Mar 2024 05:11:26 -0700 (PDT) Original-Received: from localhost ([2a02:aa12:b101:f580:7e85:981f:c305:2cf1]) by smtp.gmail.com with ESMTPSA id lc17-20020a170906dff100b00a46bdffd002sm53744ejc.158.2024.03.17.05.11.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 05:11:26 -0700 (PDT) In-Reply-To: <868r2h5qch.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 17 Mar 2024 08:23:26 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281762 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii [2024-03-17 08:23 +0200] wrote: >> Date: Sat, 16 Mar 2024 23:12:16 -0500 >> Cc: 69822@debbugs.gnu.org, "Basil L. Contovounesios" >> From: Adam Porter >>=20 >> Hi Eli, Basil, >>=20 >> On 3/16/24 05:22, Eli Zaretskii wrote: >>=20 >> > I don't understand why you consider it a bug. According to the doc=20 >> > string (see below)... >> >=20 >> > So I don't think I agree that there's a bug here to begin with. The=20 >> > doc string of format-spec says: >> >=20 >> > The width and truncation modifiers behave like the corresponding ones >> > in =E2=80=98format=E2=80=99 when applied to %s. >>=20 >> Thanks, now I understand. >>=20 >> Should I close the bug, or do you think the docstring should be changed= =20 >> to help clarify this? > > If there's something in the doc string that is unclear, please tell > what that is, and let's by all means try to find ways to clarify that. How about this for now? --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Clarify-description-of-format-spec-truncation.patch >From a4ffad9891b607e432ce246773b1f2d75d3cdeeb Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 17 Mar 2024 13:04:32 +0100 Subject: [PATCH] Clarify description of format-spec truncation * doc/lispref/strings.texi (Custom Format Strings): Mention that precision specifier affects both '<' and '>' truncation (bug#69822). * lisp/format-spec.el (format-spec, format-spec--do-flags): Use same terminology as 'format', especially when referring to its behavior. --- doc/lispref/strings.texi | 2 +- lisp/format-spec.el | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index a364fef3aab..eca69002779 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -1369,7 +1369,7 @@ Custom Format Strings @item > This flag causes the substitution to be truncated on the right to the -given width, if specified. +given width and precision, if specified. @item ^ This flag converts the substituted text to upper case (@pxref{Case diff --git a/lisp/format-spec.el b/lisp/format-spec.el index cf34017b994..73f9fccd793 100644 --- a/lisp/format-spec.el +++ b/lisp/format-spec.el @@ -38,7 +38,7 @@ format-spec (?l . \"ls\"))) Each %-spec may contain optional flag, width, and precision -modifiers, as follows: +specifiers, as follows: %character @@ -51,7 +51,7 @@ format-spec * ^: Convert to upper case. * _: Convert to lower case. -The width and truncation modifiers behave like the corresponding +The width and precision specifiers behave like the corresponding ones in `format' when applied to %s. For example, \"%<010b\" means \"substitute into the output the @@ -145,7 +145,7 @@ format-spec--do-flags "Return STR formatted according to FLAGS, WIDTH, and TRUNC. FLAGS is a list of keywords as returned by `format-spec--parse-flags'. WIDTH and TRUNC are either nil or -string widths corresponding to `format-spec' modifiers." +string widths corresponding to `format-spec' specifiers." (let (diff str-width) ;; Truncate original string first, like `format' does. (when trunc -- 2.43.0 --=-=-= Content-Type: text/plain I don't know why I added 'and precision' to the description of '<' but not '>' in: Fix and extend format-spec (bug#41758) 0185d76e742 2020-06-18 12:46:21 +0100 https://git.sv.gnu.org/cgit/emacs.git/commit/?id=0185d76e742 Thanks, -- Basil --=-=-=--