I am trying to apply a few rather specific customizations to Emacs' linum.el
, using the section from this EmacsWiki page on Line Numbers (entitled Linum: Separating line numbers from text) as a guide.
I implemented the edit to linum.el that adds a space to the right of the line number. What I am trying to figure out now is how to add an additional space to the left of the line number, so that the line numbers will look something like this:
| 1 |#include <stdio.h> (Vertical bars for visualization)
| 2 |int main()
Another customization I am trying to accomplish involves including the right space in coloring the background for the line numbers. When I set the background for the linum face, it doesn't color that new space on the right of the line number.
To illustrate, here is how the linum background covers currently:
(current) |1| #!/bin/bash -- vs. --> |1 |#!/bin/bash (ideal)
|2| echo "123" ---------> |2 |echo "123"
I did attempt to implement the former (space-on-left) by blindly tinkering with the line from the EmacsWiki that gives the right space, to no success. Unfortunately, since I am somewhat new to Emacs and Elisp, my skills aren't at the level yet where I can spot what I need to change easily on my own.
Links:
EmacsWiki: Line Numbers [Section - Linum: Separating line numbers from text]
If you really want to do it like you said, using spaces, and not as @lawlist suggested, find the line containing
(number-to-string w)
in functionlinum-update-window
and change it to:This number is the width of the box in which the line number is printed, right aligned. The original
w
is the number of digits in the last line number.