bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43469: Fwd: bug#43469: 28.0.50; window-text-pixel-size returns incor


From: Yuan Fu
Subject: bug#43469: Fwd: bug#43469: 28.0.50; window-text-pixel-size returns incorrect value when line-prefix is set
Date: Sat, 19 Sep 2020 14:33:37 -0400



Begin forwarded message:

From: Yuan Fu <casouri@gmail.com>
Subject: Re: bug#43469: 28.0.50; window-text-pixel-size returns incorrect value when line-prefix is set
Date: September 19, 2020 at 2:33:03 PM GMT-4
To: Eli Zaretskii <eliz@gnu.org>



On Sep 18, 2020, at 3:22 PM, Eli Zaretskii <eliz@gnu.org> wrote:

From: Yuan Fu <casouri@gmail.com>
Date: Fri, 18 Sep 2020 13:05:15 -0400
Cc: 43469@debbugs.gnu.org

(progn (insert "xxxxxxxxxxxxxx")
    (print (car (window-text-pixel-size
                 nil (line-beginning-position) (line-end-position))))
    (put-text-property (line-beginning-position) (line-end-position)
                       'line-prefix "   ")
    (print (car (window-text-pixel-size
                 nil (line-beginning-position) (line-end-position)))))

Prints first 98, then 119

Why do you think this is a bug?

I thought the pixel width shouldn’t include the line-prefix?

It should.  From the function's doc string:

This function exists to allow Lisp programs to adjust the dimensions
of WINDOW to the buffer text it needs to display.

When you want to know how wide a window you need for displaying some
text, you do want the line-prefix part accounted for.

I see. I managed to use (window-text-pixel-size nil (point) (point)) to calculate the prefix width and subtract it out. Thanks.

Yuan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]