This is one of those things I’m weird with, but I really like seeing about as much text above as below my cursor when I read code in particular. I dislike it when the cursor is butting right up to the window edge. I feel… confined, for some reason.
To avoid this, I have been using centered-cursor-mode for Emacs for a while. The drawback? It’s slow. Very slow. It’s not the author’s fault – it’s part of how Emacs is architected. I’ve tried to troubleshoot some of the slowness, and I even had a customisation of it that switched to a much simpler algorithm for large files, since it became unbearably slow in those.
I had some other minor modes11 An Emacs mode is basically what other editors may call a plug-in. There are two types: major modes, which affect the editing environment of a particular type of file, and minor modes, which apply globally across multiple types of editing environments. enabled that were also slow, and the sum of it all was that I suffered from very large input latency. I didn’t want to disable the modes, though, because some of them felt to me like the very reason I was using Emacs in the first place.
I asked in #emacs on how I could troubleshoot this, and got some useful advice. But perhaps the most crucial piece of advice given to me was by the user bpalmer, who said,
Personally, I would suggest trying standard display for a while. As in, just disable centered cursor, try out for a few days letting Emacs do its own thing.
It was very hard to argue against this. After all, what’s the harm in trying?
So I disabled centered-cursor-mode22 along with a bunch of other non-critical minor modes that I suspected to be slow and looked at what standard Emacs configuration settings were available to help with retaining some margins between the cursor and window edges.
What did I find? You can achieve the key functionality of centered-cursor-mode using just standard Emacs settings:
(setq scroll-preserve-screen-position t scroll-conservatively 0 maximum-scroll-margin 0.5 scroll-margin 99999)
This is missing some of the aesthetic features of centered-cursor-mode (like smoother scrolling), but a) I don’t care too much about those anyway, and b) this is a million times more performant than centered-cursor-mode. I strongly recommend trying it out as an alternative.