1

我在我的 init.el(global-linum-mode 1)(global-whitespace-mode t)定义了 Aquamacs 2.4。行号是间歇性的,会跳过在空行之后显示行号。禁用空格可以解决问题。有什么方法可以显示每一行的行号并启用空格?

也许有一个替代 linum.el 的方法非常相似?

在以下示例中,美元符号是一个没有文本的空行。

1  First line.
2  Second line.
3  $
   Fourth line.
5  $
   Sixth Line.
7  Seventh line.
8  $
   Ninth line.
4

1 回答 1

0

解决方案#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.

于 2013-04-20T20:13:35.487 回答