From: "Basil L. Contovounesios" <basil@contovou.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Adam Porter <adam@alphapapa.net>, 69822@debbugs.gnu.org
Subject: bug#69822: [PATCH] format-spec pads when it should only truncate
Date: Sun, 17 Mar 2024 13:11:25 +0100 [thread overview]
Message-ID: <87frwpxdle.fsf@epfl.ch> (raw)
In-Reply-To: <868r2h5qch.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 17 Mar 2024 08:23:26 +0200")
[-- Attachment #1: Type: text/plain, Size: 958 bytes --]
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" <basil@contovou.net>
>> From: Adam Porter <adam@alphapapa.net>
>>
>> Hi Eli, Basil,
>>
>> On 3/16/24 05:22, Eli Zaretskii wrote:
>>
>> > I don't understand why you consider it a bug. According to the doc
>> > string (see below)...
>> >
>> > So I don't think I agree that there's a bug here to begin with. The
>> > doc string of format-spec says:
>> >
>> > The width and truncation modifiers behave like the corresponding ones
>> > in ‘format’ when applied to %s.
>>
>> Thanks, now I understand.
>>
>> Should I close the bug, or do you think the docstring should be changed
>> 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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Clarify-description-of-format-spec-truncation.patch --]
[-- Type: text/x-diff, Size: 2196 bytes --]
From a4ffad9891b607e432ce246773b1f2d75d3cdeeb Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <basil@contovou.net>
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:
%<flags><width><precision>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
[-- Attachment #3: Type: text/plain, Size: 248 bytes --]
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
next prev parent reply other threads:[~2024-03-17 12:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-16 2:28 bug#69822: [PATCH] format-spec pads when it should only truncate Adam Porter
2024-03-16 10:22 ` Eli Zaretskii
2024-03-17 4:12 ` Adam Porter
2024-03-17 6:23 ` Eli Zaretskii
2024-03-17 12:11 ` Basil L. Contovounesios [this message]
2024-03-18 1:16 ` Adam Porter
2024-03-21 9:52 ` Basil L. Contovounesios
2024-03-21 10:47 ` Adam Porter
2024-03-21 11:03 ` Basil L. Contovounesios
2024-03-23 13:59 ` Adam Porter
2024-03-16 10:35 ` Basil L. Contovounesios
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87frwpxdle.fsf@epfl.ch \
--to=basil@contovou.net \
--cc=69822@debbugs.gnu.org \
--cc=adam@alphapapa.net \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.