diff options
| author | Chong Yidong | 2008-08-26 20:50:01 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-08-26 20:50:01 +0000 |
| commit | 21259ba133e14bb2861a86793d8b2355e24cb259 (patch) | |
| tree | 48790523cda898498e6be6623f0fbc10231fd297 | |
| parent | 4b4f3f827dd4498ce976343c60a7551cbcf41477 (diff) | |
| download | emacs-21259ba133e14bb2861a86793d8b2355e24cb259.tar.gz emacs-21259ba133e14bb2861a86793d8b2355e24cb259.zip | |
(linum): Inherit remaining face attributes from default face.
(linum-delay): Disable - it should no longer be necessary, and can
lead to longer delays.
(linum-update-window): Renumber if margin width has changed.
| -rw-r--r-- | lisp/linum.el | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/lisp/linum.el b/lisp/linum.el index 41fe2de1991..a88bb610d8c 100644 --- a/lisp/linum.el +++ b/lisp/linum.el | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (defconst linum-version "0.9wx") | 33 | (defconst linum-version "0.9wz") |
| 34 | 34 | ||
| 35 | (defvar linum-overlays nil "Overlays used in this buffer.") | 35 | (defvar linum-overlays nil "Overlays used in this buffer.") |
| 36 | (defvar linum-available nil "Overlays available for reuse.") | 36 | (defvar linum-available nil "Overlays available for reuse.") |
| @@ -54,7 +54,7 @@ See also `linum-before-numbering-hook'." | |||
| 54 | :type 'sexp) | 54 | :type 'sexp) |
| 55 | 55 | ||
| 56 | (defface linum | 56 | (defface linum |
| 57 | '((t :inherit shadow)) | 57 | '((t :inherit (shadow default))) |
| 58 | "Face for displaying line numbers in the display margin." | 58 | "Face for displaying line numbers in the display margin." |
| 59 | :group 'linum) | 59 | :group 'linum) |
| 60 | 60 | ||
| @@ -65,7 +65,7 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers." | |||
| 65 | :group 'linum | 65 | :group 'linum |
| 66 | :type 'boolean) | 66 | :type 'boolean) |
| 67 | 67 | ||
| 68 | (defcustom linum-delay t | 68 | (defcustom linum-delay nil |
| 69 | "Delay updates to give Emacs a chance for other changes." | 69 | "Delay updates to give Emacs a chance for other changes." |
| 70 | :group 'linum | 70 | :group 'linum |
| 71 | :type 'boolean) | 71 | :type 'boolean) |
| @@ -131,39 +131,38 @@ and you have to scroll or press \\[recenter-top-bottom] to update the numbers." | |||
| 131 | "Update line numbers for the portion visible in window WIN." | 131 | "Update line numbers for the portion visible in window WIN." |
| 132 | (goto-char (window-start win)) | 132 | (goto-char (window-start win)) |
| 133 | (let ((line (line-number-at-pos)) | 133 | (let ((line (line-number-at-pos)) |
| 134 | (limit (1+ (window-end win t))) | 134 | (limit (window-end win t)) |
| 135 | (fmt (cond ((stringp linum-format) linum-format) | 135 | (fmt (cond ((stringp linum-format) linum-format) |
| 136 | ((eq linum-format 'dynamic) | 136 | ((eq linum-format 'dynamic) |
| 137 | (let ((w (length (number-to-string | 137 | (let ((w (length (number-to-string |
| 138 | (count-lines (point-min) (point-max)))))) | 138 | (count-lines (point-min) (point-max)))))) |
| 139 | (concat "%" (number-to-string w) "d"))))) | 139 | (concat "%" (number-to-string w) "d"))))) |
| 140 | (width 0) | 140 | (width 0)) |
| 141 | visited | ||
| 142 | ov) | ||
| 143 | (run-hooks 'linum-before-numbering-hook) | 141 | (run-hooks 'linum-before-numbering-hook) |
| 144 | ;; Create an overlay (or reuse an existing one) for each | 142 | ;; Create an overlay (or reuse an existing one) for each |
| 145 | ;; line visible in this window, if necessary. | 143 | ;; line visible in this window, if necessary. |
| 146 | (while (and (not (eobp)) (< (point) limit)) | 144 | (while (and (not (eobp)) (<= (point) limit)) |
| 147 | (setq visited nil) | 145 | (let* ((str (if fmt |
| 148 | (dolist (o (overlays-in (point) (point))) | 146 | (propertize (format fmt line) 'face 'linum) |
| 149 | (when (eq (overlay-get o 'linum-line) line) | 147 | (funcall linum-format line))) |
| 150 | (unless (memq o linum-overlays) | 148 | (visited (catch 'visited |
| 151 | (push o linum-overlays)) | 149 | (dolist (o (overlays-in (point) (point))) |
| 152 | (setq linum-available (delete o linum-available)) | 150 | (when (string= (overlay-get o 'linum-str) str) |
| 153 | (setq visited t))) | 151 | (unless (memq o linum-overlays) |
| 154 | (let ((str (if fmt | 152 | (push o linum-overlays)) |
| 155 | (propertize (format fmt line) 'face 'linum) | 153 | (setq linum-available (delete o linum-available)) |
| 156 | (funcall linum-format line)))) | 154 | (throw 'visited t)))))) |
| 157 | (setq width (max width (length str))) | 155 | (setq width (max width (length str))) |
| 158 | (unless visited | 156 | (unless visited |
| 159 | (if (null linum-available) | 157 | (let (ov) |
| 160 | (setq ov (make-overlay (point) (point))) | 158 | (if (null linum-available) |
| 161 | (setq ov (pop linum-available)) | 159 | (setq ov (make-overlay (point) (point))) |
| 162 | (move-overlay ov (point) (point))) | 160 | (setq ov (pop linum-available)) |
| 163 | (push ov linum-overlays) | 161 | (move-overlay ov (point) (point))) |
| 164 | (setq str (propertize " " 'display `((margin left-margin) ,str))) | 162 | (push ov linum-overlays) |
| 165 | (overlay-put ov 'before-string str) | 163 | (overlay-put ov 'before-string |
| 166 | (overlay-put ov 'linum-line line))) | 164 | (propertize " " 'display `((margin left-margin) ,str))) |
| 165 | (overlay-put ov 'linum-str str)))) | ||
| 167 | (forward-line) | 166 | (forward-line) |
| 168 | (setq line (1+ line))) | 167 | (setq line (1+ line))) |
| 169 | (set-window-margins win width))) | 168 | (set-window-margins win width))) |