scroll-margin
is1
but Emacs still sometimes allows the cursor to stay at the 1st line of a window.
Follow these steps to reproduce it (or see the GIF below):
emacs -Q
In buffer
*scratch*
,C-x C-e
:(progn (custom-set-variables '(custom-enabled-themes '(modus-vivendi)) '(global-tab-line-mode t) '(scroll-margin 1) '(scroll-conservatively 101)) (info-emacs-manual) (end-of-buffer) (goto-line 500))
With the cursor now at the 2nd line from the top of the window, press
<up>
-arrow-key several times and pay attention to resulting cursor position.
This behavior is inconsistent with the documentation (and has caused me great trouble in practice):
C-h v scroll-margin
:
Its value is
1
Original value was0
Number of lines of margin at the top and bottom of a window.
The correct behavior is what next-line
does;
You can try the <down>
-arrow-key after step 3 described above:
Q:
Why doesn't the setting of scroll-margin
work here?
IOW, what causes previous-line
to move the cursor beyond the margin (which is inconsistent with next-line
's behavior when Emacs automatically scrolls up)?
Information that may be helpful in troubleshooting:
- If either
'(custom-enabled-themes '(modus-vivendi))
or'(global-tab-line-mode t)
is removed, the bug will disappear.
emacs-version: 28.2
system-configuration: x86_64-w64-mingw32
emacs-version: 30.0.50
system-configuration: x86_64-pc-linux-gnu
Question is Solved
I reported this as bug#63201 and it should be fixed now on the emacs-29 branch.
M-x report-emacs-bug
), and make clear what your question is. Is this the question: "If you remove either'(custom-enabled-themes '(modus-vivendi))
or'(global-tab-line-mode t)
, the bug will disappear. I don't know why."? IOW, is your question "Why?"? Or is this it? "how to get previous-line to do that stably?" – Drew Apr 03 '23 at 21:35'(custom-enabled-themes '(modus-vivendi))
or'(global-tab-line-mode t)
, the bug will disappear.” And in fact that my example is only one of the cases thatscroll-margin
doesn't work. I posted only one example here because it has already taken me much time to narrow such one example down. – shynur Apr 04 '23 at 21:41global-tab-line-mode
the bug of scrolling up goes away, but the bug of two lines of distance while scrolling down will be still there. Haven't you noticed yet the problem with two lines margin at the bottom? – Claudio Apr 04 '23 at 21:53