Subject: bug#39458: 26.3; move-overlay affects the scroll-margin feature

From: "Geza, Herman" <[email-masked]>
Date: Thu, 6 Feb 2020 21:11:32 +0100

Hi,

I discovered a possible little bug. Put this into init.el:

----- snip ---------

(setq scroll-margin 10)
(setq scroll-conservatively 101)

(defun foo ()
   (move-overlay overlay 1 2)
)

(defun bar ()
   (setq overlay (make-overlay (point) (point)))
   (add-hook 'post-command-hook #'foo nil t)
)

(add-hook 'after-change-major-mode-hook 'bar)

----- snip ---------

Load a several-page large text file, and scroll down to the
bottom. Try to position the document in a way that the window has an empty
space at the bottom. Now, move the cursor upwards. Notice, that you can
move the cursor at the very top of the window, the scroll-margin value
is ignored. If you continue moving, the document will fill the whole
window, and now emacs will take scroll-margin value into consideration.

The overall effect is, when scrolling with some empty space at the
bottom, scrolling is non-continuous. When the space is filled, it
becomes continuous.

If you remove the move-overlay call from foo, everything is fine.

(I discovered this bug while using hl-line. You can see the same effect,
if you just set the two scroll variables as I set them, and enable 
hl-line-mode)

Emacs info:

In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.11)
  of 2019-09-22, modified by Debian built on x86-csail-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description:    Debian GNU/Linux bullseye/sid

Configured using:
  'configure --build x86_64-linux-gnu --prefix=/usr
  --sharedstatedir=/var/lib --libexecdir=/usr/lib
  --localstatedir=/var/lib --infodir=/usr/share/info
  --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
  --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.3/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --build
  x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
  --libexecdir=/usr/lib --localstatedir=/var/lib
  --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
  --with-pop=yes
  --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/26.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.3/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --with-x=yes
  --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
  -fdebug-prefix-map=/build/emacs-n8pPyG/emacs-26.3+1=. 
-fstack-protector-strong
  -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
  -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LIBSYSTEMD LCMS2

Important settings:
   value of $LC_ALL: C.UTF-8
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix

Load-path shadows:
/usr/share/emacs/site-lisp/llvm/tablegen-mode hides 
/usr/share/emacs/site-lisp/llvm-9/tablegen-mode
/usr/share/emacs/site-lisp/llvm/llvm-mode hides 
/usr/share/emacs/site-lisp/llvm-9/llvm-mode
/usr/share/emacs/site-lisp/llvm/emacs hides 
/usr/share/emacs/site-lisp/llvm-9/emacs
/usr/share/emacs/site-lisp/rst hides 
/usr/share/emacs/26.3/lisp/textmodes/rst