2016-07-21 17 views
1

Ich versuche die Zeilennummerierung in Emacs einzurichten.
Linum funktioniert gut, aber wenn ich zwei Puffer öffne, verschwindet die Nummerierung für leere Zeilen. Ich benutze Manjaro Linux. Emacs arbeitet im Terminal.Emacs - Keine Zeilennummerierung für leere Zeilen

Here's screenshot.

-Code aus .emacs-Datei:

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

Wie kann ich es beheben?

+0

See: http://stackoverflow.com/a/25082664/2112489 und http: //emacs.stackexchange com/a/4179/2287 Vielleicht gilt einer von ihnen. – lawlist

Antwort

4
  1. Sie könnten in der Lage sein, dies zu beheben, indem mit nur

    (global-linum-mode 1) 
    
  2. linum-Modus all des obigen Codes ersetzt schon sollte das Variable-Size-Format, was zu tun für Sie. Ich weiß nicht, warum du das Rad neu erfindest.

  3. Vielleicht ist Ihr Problem, dass Sie versuchen, concat zwei propertize-d-Objekte zu string. Sie können dies wie "%3d ", indem Sie Ihre Formatierung vermeiden statt "%3d" und concatting " " später:

    (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

Das funktioniert super. Vielen Dank! –