* bug#30746: window-text-pixel-width includes width of following propertized space
@ 2018-03-07 22:13 Clément Pit-Claudel
2018-03-08 13:33 ` Eli Zaretskii
2019-09-28 21:51 ` Stefan Kangas
0 siblings, 2 replies; 6+ messages in thread
From: Clément Pit-Claudel @ 2018-03-07 22:13 UTC (permalink / raw)
To: 30746
[-- Attachment #1.1: Type: text/plain, Size: 642 bytes --]
Hi all,
I'm trying to measure strings in an Emacs buffer. The current code is yielding surprising results:
(progn
(save-excursion
(insert #("s " 1 2 (display (space :width (50))))))
(window-text-pixel-size nil (point) (1+ (point))))
On my machine a single 's' is 8 pixels wide, but this snippet returns 58.
The following snippet, however, returns 8 as expected:
(progn
(save-excursion
(insert "s "))
(window-text-pixel-size nil (point) (1+ (point))))
It seems that adding a display property on the space changes the return value of window-text-pixel-size; is that expected?
Thanks,
Clément.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30746: window-text-pixel-width includes width of following propertized space
2018-03-07 22:13 bug#30746: window-text-pixel-width includes width of following propertized space Clément Pit-Claudel
@ 2018-03-08 13:33 ` Eli Zaretskii
2018-03-16 14:09 ` Clément Pit-Claudel
2019-09-28 21:51 ` Stefan Kangas
1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2018-03-08 13:33 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: 30746
> From: Clément Pit-Claudel <clement.pitclaudel@live.com>
> Date: Wed, 7 Mar 2018 17:13:32 -0500
>
> (progn
> (save-excursion
> (insert #("s " 1 2 (display (space :width (50))))))
> (window-text-pixel-size nil (point) (1+ (point))))
>
> On my machine a single 's' is 8 pixels wide, but this snippet returns 58.
>
> The following snippet, however, returns 8 as expected:
>
> (progn
> (save-excursion
> (insert "s "))
> (window-text-pixel-size nil (point) (1+ (point))))
>
> It seems that adding a display property on the space changes the return value of window-text-pixel-size; is that expected?
It's expected given the relatively naïve implementation, which didn't
expect such calamities. Hopefully now fixed on the master branch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30746: window-text-pixel-width includes width of following propertized space
2018-03-08 13:33 ` Eli Zaretskii
@ 2018-03-16 14:09 ` Clément Pit-Claudel
2018-03-16 16:13 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Clément Pit-Claudel @ 2018-03-16 14:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 30746
[-- Attachment #1.1: Type: text/plain, Size: 1063 bytes --]
On 2018-03-08 08:33, Eli Zaretskii wrote:
>> From: Clément Pit-Claudel <clement.pitclaudel@live.com>
>> Date: Wed, 7 Mar 2018 17:13:32 -0500
>>
>> (progn
>> (save-excursion
>> (insert #("s " 1 2 (display (space :width (50))))))
>> (window-text-pixel-size nil (point) (1+ (point))))
>>
>> On my machine a single 's' is 8 pixels wide, but this snippet returns 58.
>>
>> The following snippet, however, returns 8 as expected:
>>
>> (progn
>> (save-excursion
>> (insert "s "))
>> (window-text-pixel-size nil (point) (1+ (point))))
>>
>> It seems that adding a display property on the space changes the return value of window-text-pixel-size; is that expected?
>
> It's expected given the relatively naïve implementation, which didn't
> expect such calamities. Hopefully now fixed on the master branch.
Thanks a lot; the width is indeed fixed. However, the fix seems to have broken the height calculation: the first snippet above now returns (8 . 0), whereas the second one returns (8 . 16).
Cheers,
Clément.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30746: window-text-pixel-width includes width of following propertized space
2018-03-16 14:09 ` Clément Pit-Claudel
@ 2018-03-16 16:13 ` Eli Zaretskii
2018-03-16 20:49 ` Clément Pit-Claudel
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2018-03-16 16:13 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: 30746
> Cc: 30746@debbugs.gnu.org
> From: Clément Pit-Claudel <clement.pitclaudel@live.com>
> Date: Fri, 16 Mar 2018 10:09:40 -0400
>
> Thanks a lot; the width is indeed fixed. However, the fix seems to have broken the height calculation: the first snippet above now returns (8 . 0), whereas the second one returns (8 . 16).
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30746: window-text-pixel-width includes width of following propertized space
2018-03-16 16:13 ` Eli Zaretskii
@ 2018-03-16 20:49 ` Clément Pit-Claudel
0 siblings, 0 replies; 6+ messages in thread
From: Clément Pit-Claudel @ 2018-03-16 20:49 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 30746
[-- Attachment #1.1: Type: text/plain, Size: 424 bytes --]
On 2018-03-16 12:13, Eli Zaretskii wrote:
>> Cc: 30746@debbugs.gnu.org
>> From: Clément Pit-Claudel <clement.pitclaudel@live.com>
>> Date: Fri, 16 Mar 2018 10:09:40 -0400
>>
>> Thanks a lot; the width is indeed fixed. However, the fix seems to have broken the height calculation: the first snippet above now returns (8 . 0), whereas the second one returns (8 . 16).
>
> Fixed.
Works perfectly. Thanks a lot.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#30746: window-text-pixel-width includes width of following propertized space
2018-03-07 22:13 bug#30746: window-text-pixel-width includes width of following propertized space Clément Pit-Claudel
2018-03-08 13:33 ` Eli Zaretskii
@ 2019-09-28 21:51 ` Stefan Kangas
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Kangas @ 2019-09-28 21:51 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: 30746
fixed 30746 26.1
close 30746
quit
Clément Pit-Claudel <clement.pitclaudel@live.com> writes:
> On 2018-03-16 12:13, Eli Zaretskii wrote:
>>> Cc: 30746@debbugs.gnu.org
>>> From: Clément Pit-Claudel <clement.pitclaudel@live.com>
>>> Date: Fri, 16 Mar 2018 10:09:40 -0400
>>>
>>> Thanks a lot; the width is indeed fixed. However, the fix seems to have broken the height calculation: the first snippet above now returns (8 . 0), whereas the second one returns (8 . 16).
>>
>> Fixed.
>
> Works perfectly. Thanks a lot.
This was fixed by:
commit c4db7662bb4740f069e494cfe632c76a0d21d6d7
Author: Eli Zaretskii <eliz@gnu.org>
Date: Fri Mar 16 18:11:07 2018 +0200
Another followup to fixing 'window-text-pixel-width'
* src/xdisp.c (Fwindow_text_pixel_size): Adjust the return value
when we stop one buffer position short of TO. (Bug#30746)
And:
commit f1f12d8be3ddc5aa0a79658f5b339c78742321fa
Author: Eli Zaretskii <eliz@gnu.org>
Date: Thu Mar 8 15:32:23 2018 +0200
Fix 'window-text-pixel-size' when display properties are around
* src/xdisp.c (Fwindow_text_pixel_size): Correct the result when
there's a display property at the TO position, and the call to
move_it_to overshoots. (Bug#30746)
I'm therefore closing this bug report.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-09-28 21:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-07 22:13 bug#30746: window-text-pixel-width includes width of following propertized space Clément Pit-Claudel
2018-03-08 13:33 ` Eli Zaretskii
2018-03-16 14:09 ` Clément Pit-Claudel
2018-03-16 16:13 ` Eli Zaretskii
2018-03-16 20:49 ` Clément Pit-Claudel
2019-09-28 21:51 ` Stefan Kangas
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.