all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* `window-hscroll' does not report correct value when `text-scale-mode' is on
@ 2017-05-18  7:38 路客
  2017-05-18 15:10 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: 路客 @ 2017-05-18  7:38 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1310 bytes --]

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

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

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))
                1))))

`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
measurement?

Thanks a lot.

-- 
Best regards,
Luke Lee

[-- Attachment #2: Type: text/html, Size: 3172 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-23  3:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-18  7:38 `window-hscroll' does not report correct value when `text-scale-mode' is on 路客
2017-05-18 15:10 ` Eli Zaretskii
2017-05-19  1:10   ` 路客
2017-05-19  6:39     ` Eli Zaretskii
2017-05-23  3:37       ` 路客

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.