2012-03-06 39 views
0

enter image description here上的Emacs

最後一行正如你可以在圖片中看到的,我可以把光標移動到最後一行(如果我使用RET在最後一行的最後一列),最後一行沒有按」 t出現在左側的行號列上。

它也沒有突出顯示,但只要我輸入它,就像我輸入「a」一樣,它將被突出顯示並出現在左側的行號列表中。

這是一個非常小的錯誤,但它有點讓我惱火 - 它確實不是一個大問題,但我真的很喜歡一種方法來解決它。

謝謝!

+0

http://www.emacswiki.org/emacs/LineNumbers#toc7 – 2012-03-06 16:22:08

+0

malenkiy_scot,好點,好像我只是一直評價他們,而不是真的選擇一個,我會在我的所有問題中做到這一點現在!謝謝! – 2012-03-06 16:35:38

回答

5

假設你使用Linum包爲您的行號(在左邊距),here's的補丁數量緩衝區的最後一行:

--- linum.el-rev474.svn000.tmp.el Fri May 08 11:30:24 2009 
+++ linum.el Fri May 08 11:29:38 2009 
@@ -135,8 +135,15 @@ 
- (let ((line (line-number-at-pos)) 
-  (limit (window-end win t)) 
-  (fmt (cond ((stringp linum-format) linum-format) 
-     ((eq linum-format 'dynamic) 
-     (let ((w (length (number-to-string 
-          (count-lines (point-min) (point-max)))))) 
-      (concat "%" (number-to-string w) "d"))))) 
-  (width 0)) 
+ (let* ((line (line-number-at-pos)) 
+   (limit (window-end win t)) 
+   ;; set empty-line-at-eob flag 
+   (empty-line-at-eob (or (equal ?\n (char-before (point-max))) 
+        (equal (point-min) (point-max)))) 
+   ;; we will automatically number the line at eob if it's not empty 
+   ;; (so we'll say it's already done) 
+   (numbered-line-at-eob (not empty-line-at-eob)) 
+   (fmt (cond ((stringp linum-format) linum-format) 
+     ((eq linum-format 'dynamic) 
+      (let* ((c (count-lines (point-min) (point-max))) 
+       (w (length (number-to-string 
+          (+ c (if empty-line-at-eob 1 0)))))) 
+      (concat "%" (number-to-string w) "d"))))) 
+   (width 0)) 
@@ -146 +153,2 @@ 
- (while (and (not (eobp)) (<= (point) limit)) 
+ ;; stop if point>limit, or if eobp and numbered-line-at-eob 
+ (while (and (not (and (eobp) numbered-line-at-eob)) (<= (point) limit)) 
@@ -165,0 +174,4 @@ 
+  ;; before moving forward, if we're already at eob 
+  (if (eobp) 
+   ;; then we've numbered the empty line 
+   (setq numbered-line-at-eob t)) 
+1

你能解釋一下如何應用這個補丁嗎? – Kanguros 2014-09-24 13:07:42

7

其實,這不是一個錯誤。這條線是空的,沒有任何東西。因此,直到內容上線纔算真正成爲「一條線」。文件中最後一個字符是99行的換行符。行100在功能上被視爲「它不存在」,直到其上有內容爲止。

+1

同意:如果OP將簡單地對屏幕截圖中顯示的文件運行'wc',他們會很快確信文件實際上只有99行,直到他們開始輸入超過第99行新行的字符以創建第100行。 – 2013-01-26 12:39:37

2

您可以編輯linum.el如果你真的想改變功能。 Here是做你想做的事的代碼。

不過你應該知道這不是一個錯誤。你想要的是主觀的;這是一個設計決定。