1 --- linum.el-rev474.svn000.tmp.el Fri May 08 11:30:24 2009
2 +++ linum.el Fri May 08 11:29:38 2009
4 - (let ((line (line-number-at-pos))
5 - (limit (window-end win t))
6 - (fmt (cond ((stringp linum-format) linum-format)
7 - ((eq linum-format 'dynamic)
8 - (let ((w (length (number-to-string
9 - (count-lines (point-min) (point-max))))))
10 - (concat "%" (number-to-string w) "d")))))
12 + (let* ((line (line-number-at-pos))
13 + (limit (window-end win t))
14 + ;; set empty-line-at-eob flag
15 + (empty-line-at-eob (or (equal ?\n (char-before (point-max)))
16 + (equal (point-min) (point-max))))
17 + ;; we will automatically number the line at eob if it's not empty
18 + ;; (so we'll say it's already done)
19 + (numbered-line-at-eob (not empty-line-at-eob))
20 + (fmt (cond ((stringp linum-format) linum-format)
21 + ((eq linum-format 'dynamic)
22 + (let* ((c (count-lines (point-min) (point-max)))
23 + (w (length (number-to-string
24 + (+ c (if empty-line-at-eob 1 0))))))
25 + (concat "%" (number-to-string w) "d")))))
28 - (while (and (not (eobp)) (<= (point) limit))
29 + ;; stop if point>limit, or if eobp and numbered-line-at-eob
30 + (while (and (not (and (eobp) numbered-line-at-eob)) (<= (point) limit))
32 + ;; before moving forward, if we're already at eob
34 + ;; then we've numbered the empty line
35 + (setq numbered-line-at-eob t))