unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>, 76008@debbugs.gnu.org
Subject: bug#76008: 31.0.50; visual-wrap-prefix-mode miscalculates prefix width when scaling text
Date: Mon, 3 Feb 2025 14:36:23 -0800	[thread overview]
Message-ID: <a3fd2eeb-8deb-578d-d78e-22b8c1ecb80b@gmail.com> (raw)
In-Reply-To: <877c681rln.fsf@gmail.com>

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)






  reply	other threads:[~2025-02-03 22:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-02 12:03 bug#76008: 31.0.50; visual-wrap-prefix-mode miscalculates prefix width when scaling text Kévin Le Gouguec
2025-02-03 22:36 ` Jim Porter [this message]
2025-02-04  6:50   ` Kévin Le Gouguec
2025-02-04 17:30     ` Jim Porter
2025-02-04 18:43       ` Kévin Le Gouguec

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a3fd2eeb-8deb-578d-d78e-22b8c1ecb80b@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=76008@debbugs.gnu.org \
    --cc=kevin.legouguec@gmail.com \
    /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 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).