[Top][All Lists]

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

Re: `window-hscroll' does not report correct value when `text-scale-mode

From: 路客
Subject: Re: `window-hscroll' does not report correct value when `text-scale-mode' is on
Date: Fri, 19 May 2017 09:10:23 +0800

You are right, convert it to pixel units won't fix it. Maybe
I should change my question to either of the following:

1. How should we fix `ruler-mode' to make it correct when
   `text-scale-mode' is ON?
2. When `text-scale-mode' is ON, how can I get the correct
    `window-hscroll' value respect to current text scaling?

My earlier `my-hscroll' try to calculate the scaled
`window-hscroll' but it's not always correct:

(defun my-hscroll ()
  (round (/ (window-hscroll)
            (or (and (boundp 'text-scale-mode-remapping)
                     (caddr text-scale-mode-remapping))
How should I use the `text-scale-mode-remapping' to do this?
Anyone who is expert in `text-scale-mode' please help. I will
later try to fix ruler-mode accordingly.


Best regards,
Luke Lee

2017-05-18 23:10 GMT+08:00 Eli Zaretskii <address@hidden>:
> From: 路客 <address@hidden>
> Date: Thu, 18 May 2017 15:38:47 +0800
> I found `window-hscroll' function does not report a correct value
> if `text-scale-mode' is on. A simple test is to enable `ruler-mode'
> and edit something like the following "text-ruler":
> .........1.........2.........3.........4.........5.........6...
> 123456789012345678901234567890123456789012345678901234567890...
> Now we add a next line with 500 characters and put the cursor at
> the end of it; then we use <shift-left_mouse> to decrease the font
> size *twice* (with text wrapping disabled and ruler-mode enabled
> to observe current `window-hscroll' value). We can now easily see
> the `window-hscroll' value is incorrect, by comparing against the
> above "text-ruler".

This is not a bug: window-hscroll reports its value in units of
canonical frame columns, so the value should indeed change when you
change the font size.

> Is there any way to get the "exact" hscroll value? Say, with pixel-wise
> measurement?

The value you get now is already exact, and is exactly equivalent to
the corresponding number of pixels.  If you really need that in pixel
units, simply multiply by the value returned by frame-char-width.

Best regards,
Luke Lee

reply via email to

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