GNU bug report logs - #47712
27.1; Provide `string-display-width` function, which takes properties into account, `substring-width`

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Sun, 11 Apr 2021 21:17:02 UTC

Severity: normal

Found in version 27.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 47712 <at> debbugs.gnu.org
Subject: bug#47712: 27.1; Provide `string-display-width` function, which takes properties into account, `substring-width`
Date: Mon, 12 Apr 2021 10:45:45 +0200
On 4/12/21 4:26 AM, Eli Zaretskii wrote:
> We already have window-text-pixel-size; doesn't it fit the bill?  If
> not, why not?

`window-text-pixel-size` computes the size of a portion of the window, 
it does not take a string argument. The function `string-width` instead 
takes a string argument returning the number of columns needed to 
display this string. This function is needed to compute widths of 
strings which are not yet displayed.

`string-display-width` is a proposed function which takes properties 
into account as `window-text-pixel-size` does, but without going through 
the display system first. Instead it computes the `string-width` of a 
flattened string, where the invisible parts have been removed and the 
displayed parts have been replaced.

Orgmode uses its incarnation of `string-display-width`, 
`org-string-width`, for formatting its tables (see org-table.el). The 
width computation is performed before displaying the strings in the window.

`substring-width` is a proposed generalization of `string-width` which 
allows computation of the width of a substring, without requiring the 
allocation of a substring. `string-display-width` or 
`substring-display-width` can be implemented based on `string-width` or 
`substring-width`, with`substring-width` being advantageous since it 
does not require the substring allocation.





This bug report was last modified 4 years and 37 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.