[Top][All Lists]

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

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

From: 路客
Subject: `window-hscroll' does not report correct value when `text-scale-mode' is on
Date: Thu, 18 May 2017 15:38:47 +0800

Hi all,

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":


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
to observe current `window-hscroll' value). We can now easily
the `window-hscroll' value is incorrect, by comparing against the

above "text-ruler".

After some experiments I derived the following function that help a
bit but still not a complete answer:

(defun my-hscroll ()
  (round (/ (window-hscroll)
            (or (and (boundp 'text-scale-mode-remapping)
                     (caddr text-scale-mode-remapping))

`my-hscroll' function can report a value that is closer to the correct
hscroll value. But the error of `my-hscroll' becomes larger if we again
decrease the font size, or purposely edit a line with 2000 characters.

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

Thanks a lot.

Best regards,
Luke Lee

reply via email to

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