Add central screen scroll
Basically mimic the functionality of https://github.com/aspiers/smooth-scrolling/ , keeping the scroll always in the center of the screen
I wrote almost the same extension at #1035 for vi-mode.
It is called scrolloff in Vim world.
Oh interesting, can this be ported to be used outside of vi-mode?
Sure. I'm happy if Lem gets more convenience.
It looks like the current implementation of scrolloff is very computational intensive and should be revisited. I noticed some lags when using vi-mode, which I did not notice in emacs-mode. I did the following test, using cl-flamegraph and got the following result:
setting scrolloff to 0 and positioning the cursor on the last line of the screen. The screen should show at least 50 lines, so that no scrolling is done during the execution of foo. line-wrapping is on. foo is called using M-:.
(defun foo (path)
(flamegraph:save-flame-graph (path)
(dotimes (_ 50)
(dotimes (_ 50)
(lem:call-command (lem:find-command "vi-previous-line") nil))
(dotimes (_ 50)
(lem:call-command (lem:find-command "vi-next-line") nil)))))
The test basically moves the cursor up 50 lines and then down 50 times. This is repeated 50 times. The whole process is profiled in sbcl using sb-sprof (needs to added to lem.asd). The flame graph looks like this:
70% of the time is spent in adjust-window-scroll, which handles the vi-mode scrolloff option, even though no scrolling appears. Computing the window-cursor-y is very expensive when line-wrapping is on and is done after each and every command.