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

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

Re: Scrolling jumpy when line-spacing > 0


From: Yuri Khan
Subject: Re: Scrolling jumpy when line-spacing > 0
Date: Sat, 22 Apr 2017 00:58:08 +0700

On Fri, Apr 21, 2017 at 9:40 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> (Why do people report bugs here, rather than with report-emacs-bug?)

To check if that is indeed a bug worth reporting, or if it is already
known, or even already fixed?

> On the master branch, when you click on the bottom line of
> the window, which is only partially visible in the above scenario,
> Emacs scrolls the window half-window up. To be able to put point on
> the bottom line, you will need to set window-resize-pixelwise non-nil,
> and drag the mode line down pixel by pixel until Emacs lets you put
> point there.

Which point is that? When the whole additional spacing is visible?

As a user, I’d expect that additional spacing does not count toward
whether the line is considered visible.

> Once this happens, "M-: (scroll-up 1) RET" produces the
> effect you expected.

Thank you.

> Doesn't pos-visible-in-window-p allow you to compute this more
> elegantly, without moving point at all?

I was in the middle of a $DAYJOB task, and reached for the quickest fix.

But no, not really. On the contrary, I am compelled to add more
kludges^W idiosyncratic code.

There are two special cases. One when the point is initially in the
bottommost visible line whose additional spacing is outside view; in
this case, (scroll-up 1) would cause the jump. This can indeed be
detected with (pos-visible-in-window-p) returning nil.

The other special case is when the point is in the topmost visible
line. In this case, (scroll-up 1) is forced to move the point into
view. The point is moved to the beginning of the new topmost visible
line, even if it was in the middle of the line initially. Here I want
behavior equivalent to (next-line) followed by (scroll-up), i.e. to
keep column position.

I see no practical way to detect this condition without moving point.
The easiest that comes to mind is to check if the position one visual
line up from point is outside view.

Factoring out all relevant special case detection, I end up with this:

(defun yk-scroll--in-bottommost-line ()
  (not (pos-visible-in-window-p)))
(defun yk-scroll--in-topmost-line ()
  (save-excursion
    (let ((line-move-visual t))
      (previous-line))
    (not (pos-visible-in-window-p))))
(defun yk-scroll-up ()
  (interactive)
  (cond
   ((yk-scroll--in-bottommost-line)
    (save-excursion
      (previous-line)
      (scroll-up 1)))
   ((yk-scroll--in-topmost-line)
    (let ((line-move-visual t))
      (next-line))
    (scroll-up 1))
   (t (scroll-up 1))))
(defun yk-scroll-down ()
  (interactive)
  (cond
   ((yk-scroll--in-bottommost-line)
    (previous-line)
    (scroll-down 1))
   (t (scroll-down 1))))



reply via email to

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