解决方案#1——来自http://www.emacswiki.org/LineNumbers(引用Michael Hoffman)——出于不同的原因发布在那里,但也解决了我的问题:
(eval-after-load 'linum
'(progn
(defface linum-leading-zero
`((t :inherit 'linum
:foreground ,(face-attribute 'linum :background nil t)))
"Face for displaying leading zeroes for line numbers in display margin."
:group 'linum)
(defun linum-format-func (line)
(let ((w (length
(number-to-string (count-lines (point-min) (point-max))))))
(concat
(propertize (make-string (- w (length (number-to-string line))) ?0)
'face 'linum-leading-zero)
(propertize (number-to-string line) 'face 'linum))))
(setq linum-format 'linum-format-func)))
解决方案#2:
(setq linum-format "%d")
仅供参考#A:
对于想知道如何解决各种空白颜色(和/或突出显示当前行)侵入为行号保留的左侧边距的相关问题的任何人,设置该区域的背景颜色可以解决问题。行号的前景和/或背景可以由用户定义。上面的解决方案一也可以通过在第 5 行的单词之后添加颜色定义来修改foreground
- 例如,:foreground "red", ...
以下代码段是一个单独的行,可以在解决方案一中提到的整个解决方法之前或之后,并使用任何颜色进行修改用户希望:
(custom-set-faces '(linum ((t (:foreground "red" :background "white" :height 120 :family "Courier")))) )
仅供参考#B:我修改了第一个解决方案的第13行以消除0
并用一个普通的旧空格替换它,因为我不习惯看到前导零并且只是在寻找解决这个线程中描述的初始问题的解决方案。解决方案 2 似乎是左冲洗,解决方案 1 是冲洗右。只是个人喜好问题。毫无疑问,linum-format
除了定义在linum.el
.