2013-10-23 46 views

回答

2

觀察:行號右側不需要空格(如問題所示),因爲可以使用條紋寬度來控制行號和身體之間的分隔。

(setq-default left-fringe-width 10) 
(setq-default right-fringe-width 0) 
(set-face-attribute 'fringe nil :background "black") 

選項#1:但是,這是不是沖洗右。

(setq linum-format "%d") 

選項#2:使用前導零 - 齊平權。

(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))) 
+0

你'亞麻-format'功能是無效的(完全是亞麻本身曾經是,頭腦;但它已經固定)。具體來說,您正在爲屏幕上的每一行重新生成格式 - 運行'(count-lines(point-min)(point-max))'。有關如何解決此問題的示例,請參閱http://stackoverflow.com/a/11496199/324105。 – phils

1

你可以提高@lawlists第二種方案,但不是使用0作爲空間置換,就可以使用一些異國情調的空白,如EN-空間這將是"\u2002"。由於我們不使用看起來像空間的比例字體,但whitespace不會混淆它。

我實際使用linum-relative-mode在這裏你可以方便地只是忠告linum-relative

(advice-add 'linum-relative :filter-return 
      (lambda (num) 
      (if (not (get-text-property 0 'invisible num)) 
       (propertize (replace-regexp-in-string " " "\u2002" num) 
          'face (get-text-property 0 'face num)))))