unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: 路客 <luke.yx.lee@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: `window-hscroll' does not report correct value when `text-scale-mode' is on
Date: Fri, 19 May 2017 09:10:23 +0800	[thread overview]
Message-ID: <CAA=xLRPiHWX2vH+A3KGn6Rg38oovfps+ypc=tz18a4dqF=sG8g@mail.gmail.com> (raw)
In-Reply-To: <83y3tu42vr.fsf@gnu.org>

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

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

Thanks!

Best regards,
Luke Lee

2017-05-18 23:10 GMT+08:00 Eli Zaretskii <eliz@gnu.org>:

> > From: 路客 <luke.yx.lee@gmail.com>
> > 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

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

  reply	other threads:[~2017-05-19  1:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` 路客 [this message]
2017-05-19  6:39     ` Eli Zaretskii
2017-05-23  3:37       ` 路客

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='CAA=xLRPiHWX2vH+A3KGn6Rg38oovfps+ypc=tz18a4dqF=sG8g@mail.gmail.com' \
    --to=luke.yx.lee@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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).