reddit / emacs

How to fix `line-prefix` causing the first tab to render "short"

your_sweetpea · 2022-07-08 19:42
I'm using `line-prefix` to give a little bit of space between the line numbers enabled by `display-line-numbers-mode` and my code, but it causes the unfortunate issue of the first tab being "shortened" by a space. This is because, when you enter a tab in emacs, the tab inserts space to the "tab stop" (not the tab stop set by `tab-stop-list`, but some kind of internal rendering value), and the space added by `line-prefix` doesn't move the internal tab stops, just adds a space at the beginning of the line, so it's the same as if you entered a space then a tab -- your indentation level is still only `tab-width` deep. I'm happy to just use spaces for indentation for my personal projects, but when collaborating with others I'll have to use tabs in some cases, so I'd like to find a solution to this problem. I've tried setting `line-prefix` to a tab, but even with `tab-width` 2, that's a bit too much. Alternatively, I'm happy with any other way to add a space between the `display-line-numbers` section and my code.
your_sweetpea · 2022-07-08 20:02
I'm doing some C code research and I'm pretty sure this is impossible without a patch, sadly. The tabification code is [specifically hardcoded to offset by the line number width](https://github.com/emacs-mirror/emacs/blob/3af9e84ff59811734dcbb5d55e04e1fdb7051e77/src/term.c#L1582-L1618) and nothing else changes that from my searches than the actual line number rendering.