2016-07-21 10 views
1

이맥스에서 줄 번호를 설정하려고합니다.
Linum은 잘 작동하지만 두 개의 버퍼를 열면 빈 줄 번호가 사라집니다. Manjaro Linux를 사용합니다. Emacs는 터미널에서 작동합니다. 이맥스 파일에서Emacs - 빈 줄의 줄 번호 없음

Here's screenshot.

코드 :

(add-hook 'find-file-hook (lambda() (linum-mode 1))) 

(unless window-system 
    (add-hook 'linum-before-numbering-hook 
    (lambda() 
     (setq-local linum-format-fmt 
      (let ((w (length (number-to-string 
       (count-lines (point-min) (point-max)))))) 
      (concat "%"(number-to-string w) "d")))))) 

(defun linum-format-func (line) 
    (concat 
    (propertize (format linum-format-fmt line) 'face 'linum) 
    (propertize " " 'face 'mode-line))) 

(unless window-system 
    (setq linum-format 'linum-format-func)) 

내가 그것을 어떻게 해결할 수 있습니까?

+0

참조 : http://stackoverflow.com/a/25082664/2112489 및 HTTP : //emacs.stackexchange을 당신은 "%3d " 대신 "%3d"처럼 서식을 만들고 " " 나중에 concatting하여이를 방지 할 수 있습니다 .com/a/4179/2287 아마도 그 중 하나가 적용됩니다. – lawlist

답변

4
  1. 이미 당신을위한 가변 크기의 포맷 일을해야 단지

    (global-linum-mode 1) 
    
  2. LINUM 모드로 위의 코드의 모든을 대체하여이 문제를 해결 할 수 있습니다. 왜 당신이 바퀴를 다시 발명하는지 모르겠다.

  3. 아마도 concat 두 개의 propertize -d 개 오브젝트를 문자열로 연결하려고합니다.

    (add-hook 'find-file-hook (lambda() (linum-mode 1))) 
    
    (unless window-system 
        (add-hook 'linum-before-numbering-hook 
        (lambda() 
         (setq-local linum-format-fmt 
          (let ((w (length (number-to-string 
           (count-lines (point-min) (point-max)))))) 
          (concat "%" (number-to-string w) "d ")))))) 
    
    (defun linum-format-func (line) 
        (propertize (format linum-format-fmt line) 'face 'linum)) 
    
    (unless window-system 
        (setq linum-format 'linum-format-func)) 
    
+0

위대한 작품입니다. 고맙습니다! –