Emacs: Centered, Stable Cursor View (publ. 2024-02-29)

There are two thing I don't like about how Emacs handles the cursor by default:

(1) The cursor moves all over the place vertically as you next-line, scroll up, and such like.

(2) As you move vertically, the placement of the cursor tends to move all over the place horizontally. This is because it is trying to maintain a goal cursor position but also has to stay within the limits of the number of characters in each line.

I wanted something more like a typewriter, where you always are looking at the same place to edit the text. I got basically what I wanted with a combination of global-centered-cursor-mode and a few tweaks. The centered-cursor-mode package is not available in Guix, unfortunately, but was easy to pull with straight:

This keeps the cursor centered vertical all the time, except for at the beginning and end of the buffer. I set a few variables:

The ccm-recenter-at-end-of-file allows cursor to center when you reach the end of the buffer as well, but still not at the beginning. Setting ccm-step-delay to zero removes animation that could slow down the visual experience. I'm not sure if ccm-step-size has any relevance here, with a ccm-step-delay of zero, but I happen to have it defined at the moment for reasons I don't remember.

I've got context-lines set to 1, just so I can see I've maintained continuity:

I also generally prefer word-wrapping to be on:

Honestly, I can't really remember why these are set:

This bit of "advice" elisp deals with the annoyance of the cursor jumping around left and right as I use previous-line and next-line:

I prefer to have visual-line-mode disabled since I want all my navigation and macros to be operating on real lines. However, this creates a problem — at least when using centered-cursor-mode with word-wrapping enabled — where scrolling potentially skips over reading some text if the real lines are longer than visual lines. This advice code turns visual-line-mode just long enough to do the scroll:

Something that would be interesting to try would be a mode where Emacs keeps the cursor horizontal centered as well, like a mechanical typewriter with a fixed strike location. The text would have to move left and right to accomodate. But I haven't heard of a package like this.

This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0 Deed

Proxied content from gemini://gem.librehacker.com/gemlog/starlog/20240228-0.gmi

Gemini request details:

Original URL
Status code
Proxied by

Be advised that no attempt was made to verify the remote SSL certificate.