reddit / emacs

TopSpace: Scroll down & recenter top lines in Emacs / get upper margins/padding.

teepee1 · 2022-03-08 12:02
[deleted] · 2022-03-08 12:02
[removed]
stayclassytally · 2022-03-08 12:25
Okay cool, but how?
teepee1 · 2022-03-08 12:27
The "upper margin" is created by drawing an [overlay](https://www.gnu.org/software/emacs/manual/html_node/elisp/Overlays.html) before window-start containing newline characters. As you scroll above the top line, more newline characters are added or removed accordingly.
stayclassytally · 2022-03-08 12:30
Sick, can you post a snippet ? Been wanting a way to center slide content
teepee1 · 2022-03-08 12:39
What would you like to see? I would say the main idea is captured in the GIF here. And in terms of usage, no new keybindings are required, you just keep using all your previous scrolling & recentering commands, except now you can also scroll above the top lines.
teepee1 · 2022-03-08 12:51
Here's the repo link: https://github.com/trevorpogue/topspace
FrozenOnPluto · 2022-03-08 15:26
Any risk of the pre- post- overlay newline text getting into saves, implicit backups, clipboards, etc? or are the overlays completely ignored by everything?
teepee1 · 2022-03-08 15:30
Nope no risk of that! The overlays alter the buffer appearance but are never a part of the underlying file
teepee1 · 2022-03-08 15:38
I used to manually append newline characters to the beginning of files to get this effect before I had the expertise to make this mode properly, but no need for than anymore :)
stayclassytally · 2022-03-08 19:39
I see you posted the repo link now. Thanks
teepee1 · 2022-03-08 20:08
Yeah I had previous comment with the link right off the bat, but then I noticed it didn't seem to be visible to other people for some reason
ZZhanChi · 2022-03-08 22:45
Wow! Adding upper margin to buffers was in my todo list for a long time, thanks for doing that for us!
radioactiveoctopi · 2022-09-22 09:24
Theme? Lol