* Re: master 9480169 1/2: Change the string-limit parameter semantics
[not found] ` <20201222055936.BC7DD20B72@vcs0.savannah.gnu.org>
@ 2020-12-22 14:57 ` Stefan Monnier
2020-12-22 16:14 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2020-12-22 14:57 UTC (permalink / raw)
To: emacs-devel; +Cc: Lars Ingebrigtsen
> +@defun string-limit string length &optional end
> +If @var{string} is shorter than @var{length}, @var{string} is returned
> +as is. Otherwise, return a substring of @var{string} consisting of
> +the first @var{length} characters. If the optional @var{end}
> +parameter is given, return a string of the @var{length} last
> +characters instead.
> @end defun
In my experience it's very rare to need to limit a string to
a particular *length*. Instead you usually want to limit it to
a particular *width*. So I'd strongly recommend you mention
`truncate-string-to-width` as an alternative.
Stefan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-22 14:57 ` master 9480169 1/2: Change the string-limit parameter semantics Stefan Monnier
@ 2020-12-22 16:14 ` Eli Zaretskii
2020-12-23 6:54 ` Lars Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-22 16:14 UTC (permalink / raw)
To: Stefan Monnier; +Cc: larsi, emacs-devel
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Tue, 22 Dec 2020 09:57:26 -0500
> Cc: Lars Ingebrigtsen <larsi@gnus.org>
>
> In my experience it's very rare to need to limit a string to
> a particular *length*. Instead you usually want to limit it to
> a particular *width*.
More accurately, almost any code in Emacs that limits strings to some
length, actually ought to limit them to some width instead ;-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-22 16:14 ` Eli Zaretskii
@ 2020-12-23 6:54 ` Lars Ingebrigtsen
2020-12-23 15:31 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-23 6:54 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Stefan Monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> In my experience it's very rare to need to limit a string to
>> a particular *length*. Instead you usually want to limit it to
>> a particular *width*.
>
> More accurately, almost any code in Emacs that limits strings to some
> length, actually ought to limit them to some width instead ;-)
That's true (for limiting lengths for display purposes in Emacs). This
new function in for when you really want to limit by the number of
characters. I'll adjust the doc string to point to
`truncate-string-to-width'.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-23 6:54 ` Lars Ingebrigtsen
@ 2020-12-23 15:31 ` Eli Zaretskii
2020-12-23 22:25 ` Lars Ingebrigtsen
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-23 15:31 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: monnier, emacs-devel
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
> Date: Wed, 23 Dec 2020 07:54:32 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > More accurately, almost any code in Emacs that limits strings to some
> > length, actually ought to limit them to some width instead ;-)
>
> That's true (for limiting lengths for display purposes in Emacs).
Why else would you need to limit a string?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-23 15:31 ` Eli Zaretskii
@ 2020-12-23 22:25 ` Lars Ingebrigtsen
2020-12-23 22:37 ` Lars Ingebrigtsen
2020-12-24 3:30 ` Eli Zaretskii
0 siblings, 2 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-23 22:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
> Why else would you need to limit a string?
When talking to APIs with max-length fields; fixed-width data formats;
database columns; etc.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-23 22:25 ` Lars Ingebrigtsen
@ 2020-12-23 22:37 ` Lars Ingebrigtsen
2020-12-24 3:30 ` Eli Zaretskii
1 sibling, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-23 22:37 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: monnier, emacs-devel
Lars Ingebrigtsen <larsi@gnus.org> writes:
> When talking to APIs with max-length fields; fixed-width data formats;
> database columns; etc.
(Of course in some of those you really want a
`string-limit-to-octets-after-encoding-but-shortening-by-characters'
function (which is something I've missed (and implemented a couple of
times)), but it depends.)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-23 22:25 ` Lars Ingebrigtsen
2020-12-23 22:37 ` Lars Ingebrigtsen
@ 2020-12-24 3:30 ` Eli Zaretskii
2020-12-24 6:02 ` Lars Ingebrigtsen
1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-12-24 3:30 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: monnier, emacs-devel
> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
> Date: Wed, 23 Dec 2020 23:25:31 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Why else would you need to limit a string?
>
> When talking to APIs with max-length fields; fixed-width data formats;
> database columns; etc.
"Columns" as in on display?
Anyway, my point is that almost every string in Emacs eventually gets
displayed.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: master 9480169 1/2: Change the string-limit parameter semantics
2020-12-24 3:30 ` Eli Zaretskii
@ 2020-12-24 6:02 ` Lars Ingebrigtsen
0 siblings, 0 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2020-12-24 6:02 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: monnier, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> When talking to APIs with max-length fields; fixed-width data formats;
>> database columns; etc.
>
> "Columns" as in on display?
No, as data types -- varchar(100), etc.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-12-24 6:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20201222055934.22358.13749@vcs0.savannah.gnu.org>
[not found] ` <20201222055936.BC7DD20B72@vcs0.savannah.gnu.org>
2020-12-22 14:57 ` master 9480169 1/2: Change the string-limit parameter semantics Stefan Monnier
2020-12-22 16:14 ` Eli Zaretskii
2020-12-23 6:54 ` Lars Ingebrigtsen
2020-12-23 15:31 ` Eli Zaretskii
2020-12-23 22:25 ` Lars Ingebrigtsen
2020-12-23 22:37 ` Lars Ingebrigtsen
2020-12-24 3:30 ` Eli Zaretskii
2020-12-24 6:02 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).