[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: |
Fri, 21 Apr 2017 18:03:43 +0700 |
On Fri, Apr 21, 2017 at 5:13 PM, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> M-: (scroll-up 1)
>
> Observed behavior: Point is on the same line and the line is at the
> top of window.
>
> Expected behavior: Point is on the same line and the line is second
> from the bottom of window. The next line, “and NEWS.1-17 for changes
> in older Emacs versions.”, is visible.
OK, here’s what I came up with, as a kludge.
(defun yk-scroll-up-line ()
(interactive)
(let ((last-line-start
(save-excursion
(goto-char (window-end))
(forward-line -1)
(point)))
(orig-point (point)))
;; If in the bottommost visible line, move to a safe place (line up).
(when (<= last-line-start orig-point)
(previous-line))
(scroll-up 1)
;; If we were in the topmost line,
;; the original point is now outside the view,
;; and the point is now on the new topmost line. Leave it there.
;; Otherwise, the original point is still visible. Restore it.
(when (pos-visible-in-window-p orig-point)
(goto-char orig-point))))