GNU bug report logs -
#76008
31.0.50; visual-wrap-prefix-mode miscalculates prefix width when scaling text
Previous Next
Reported by: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Date: Sun, 2 Feb 2025 12:04:02 UTC
Severity: normal
Tags: patch
Found in version 31.0.50
Done: Jim Porter <jporterbugs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 76008 in the body.
You can then email your comments to 76008 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
jporterbugs <at> gmail.com, bug-gnu-emacs <at> gnu.org
:
bug#76008
; Package
emacs
.
(Sun, 02 Feb 2025 12:04:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
jporterbugs <at> gmail.com, bug-gnu-emacs <at> gnu.org
.
(Sun, 02 Feb 2025 12:04:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Heya!
Steps to reproduce from emacs -Q:
C-x C-f repro.rst
C-x C-+ + [+…] ; until e.g. "+6"
- words
M-x visual-wrap-prefix-mode
Expectation: no visual change.
Observation: the "- " prefix is propertized with…
There are text properties here:
display (min-width ((6 . width)))
face rst-block
fontified t
wrap-prefix (space :align-to (6 . width))
… which makes the text look like this:
- words
I believe the cause lies in visual-wrap--content-prefix; empirically the
attached patch shows good results on this reproducer, but I landed on it
more by trial-and-error than by rational analysis, so it may be
incorrect or suboptimal (e.g. there may be better text-scale or
string-width APIs to use).
Thanks for your time (& for the love & care visual-wrap has been
receiving lately).
[Message part 2 (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
Configured using:
'configure --prefix=/home/peniblec/apps/.emacs.2025-01-18 --with-cairo
--with-native-compilation=no --with-sqlite3 --with-xinput2'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Added tag(s) patch.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 02 Feb 2025 13:51:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76008
; Package
emacs
.
(Mon, 03 Feb 2025 22:37:01 GMT)
Full text and
rfc822 format available.
Message #10 received at 76008 <at> debbugs.gnu.org (full text, mbox):
On 2/2/2025 4:03 AM, Kévin Le Gouguec wrote:
> I believe the cause lies in visual-wrap--content-prefix; empirically the
> attached patch shows good results on this reproducer, but I landed on it
> more by trial-and-error than by rational analysis, so it may be
> incorrect or suboptimal (e.g. there may be better text-scale or
> string-width APIs to use).
Thanks. I think the issue here is actually that the display spec for the
"average space" was wrong. It used a plain number for the width of the
specified space, which means "N times the normal character width for the
buffer", but we want "N times the normal character width for the
*current face*".
Could you try this patch?
----------------------------------------
diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
index 1691ba9c500..f2a186ce320 100644
--- a/lisp/visual-wrap.el
+++ b/lisp/visual-wrap.el
@@ -164,7 +164,7 @@ visual-wrap--content-prefix
;; units of the font's average-width) large enough to fit the
;; first-line prefix.
(let ((avg-space (propertize (buffer-substring position (1+ position))
- 'display '(space :width 1))))
+ 'display '(space :width (1 . width)))))
;; Remove any `min-width' display specs since we'll replace with
;; our own later in `visual-wrap--apply-to-line' (bug#73882).
(add-display-text-property 0 (length prefix) 'min-width nil prefix)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76008
; Package
emacs
.
(Tue, 04 Feb 2025 06:51:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 76008 <at> debbugs.gnu.org (full text, mbox):
Jim Porter <jporterbugs <at> gmail.com> writes:
> On 2/2/2025 4:03 AM, Kévin Le Gouguec wrote:
>> I believe the cause lies in visual-wrap--content-prefix; empirically the
>> attached patch shows good results on this reproducer, but I landed on it
>> more by trial-and-error than by rational analysis, so it may be
>> incorrect or suboptimal (e.g. there may be better text-scale or
>> string-width APIs to use).
>
> Thanks. I think the issue here is actually that the display spec for the "average space" was wrong. It used a plain number for the width of the specified space, which means "N times the normal character width for the buffer", but we want "N times the normal character width for the *current face*".
💡
> Could you try this patch?
It does fix the reproducer, thanks!
> ----------------------------------------
>
> diff --git a/lisp/visual-wrap.el b/lisp/visual-wrap.el
> index 1691ba9c500..f2a186ce320 100644
> --- a/lisp/visual-wrap.el
> +++ b/lisp/visual-wrap.el
> @@ -164,7 +164,7 @@ visual-wrap--content-prefix
> ;; units of the font's average-width) large enough to fit the
> ;; first-line prefix.
> (let ((avg-space (propertize (buffer-substring position (1+ position))
> - 'display '(space :width 1))))
> + 'display '(space :width (1 . width)))))
> ;; Remove any `min-width' display specs since we'll replace with
> ;; our own later in `visual-wrap--apply-to-line' (bug#73882).
> (add-display-text-property 0 (length prefix) 'min-width nil prefix)
Reply sent
to
Jim Porter <jporterbugs <at> gmail.com>
:
You have taken responsibility.
(Tue, 04 Feb 2025 17:31:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 04 Feb 2025 17:31:03 GMT)
Full text and
rfc822 format available.
Message #18 received at 76008-done <at> debbugs.gnu.org (full text, mbox):
On 2/3/2025 10:50 PM, Kévin Le Gouguec wrote:
> It does fix the reproducer, thanks!
Thanks for checking. Merged to the master branch (with an additional bit
of cleanup for shr.el) as 68424155774. Closing this now.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#76008
; Package
emacs
.
(Tue, 04 Feb 2025 18:44:01 GMT)
Full text and
rfc822 format available.
Message #21 received at 76008-done <at> debbugs.gnu.org (full text, mbox):
Jim Porter <jporterbugs <at> gmail.com> writes:
> On 2/3/2025 10:50 PM, Kévin Le Gouguec wrote:
>> It does fix the reproducer, thanks!
>
> Thanks for checking. Merged to the master branch (with an additional bit of cleanup for shr.el) as 68424155774. Closing this now.
Thank you for the quick fix!
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 05 Mar 2025 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 106 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.