annotate lisp/linum.el @ 96301:66839d3799fe

(terminal-composition-base-character-p): New funciton. (terminal-composition-function): Use terminal-composition-base-character-p. Include the base character in the composition. (auto-compose-chars): Don't check font-object for terminal display.
author Kenichi Handa <handa@m17n.org>
date Thu, 26 Jun 2008 04:16:09 +0000
parents ee5932bf781d
children 77e42c247dba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; linum.el --- display line numbers in the left margin
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
4
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5 ;; Author: Markus Triska <markus.triska@gmx.at>
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
6 ;; Maintainer: FSF
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
7 ;; Keywords: convenience
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92141
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92141
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92141
diff changeset
14 ;; (at your option) any later version.
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
15
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
20
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92141
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
24 ;;; Commentary:
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
26 ;; Display line numbers for the current buffer.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27 ;;
88075
77e6cba71081 Update comment.
Juanma Barranquero <lekktu@gmail.com>
parents: 88073
diff changeset
28 ;; Toggle display of line numbers with M-x linum-mode. To enable
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
29 ;; line numbering in all buffers, use M-x global-linum-mode.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
31 ;;; Code:
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
32
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
33 (defconst linum-version "0.9wx")
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
34
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
35 (defvar linum-overlays nil "Overlays used in this buffer.")
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
36 (defvar linum-available nil "Overlays available for reuse.")
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
37 (defvar linum-before-numbering-hook nil
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
38 "Functions run in each buffer before line numbering starts.")
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
39
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
40 (mapc #'make-variable-buffer-local '(linum-overlays linum-available))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
41
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
42 (defgroup linum nil
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
43 "Show line numbers in the left margin."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
44 :group 'convenience)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
45
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
46 ;;;###autoload
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
47 (defcustom linum-format 'dynamic
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
48 "Format used to display line numbers.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
49 Either a format string like \"%7d\", `dynamic' to adapt the width
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
50 as needed, or a function that is called with a line number as its
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
51 argument and should evaluate to a string to be shown on that line.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
52 See also `linum-before-numbering-hook'."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
53 :group 'linum
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
54 :type 'sexp)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
55
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
56 (defface linum
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
57 '((t :inherit shadow))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
58 "Face for displaying line numbers in the display margin."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
59 :group 'linum)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 (defcustom linum-eager t
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62 "Whether line numbers should be updated after each command.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
63 The conservative setting `nil' might miss some buffer changes,
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64 and you have to scroll or press \\[recenter-top-bottom] to update the numbers."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65 :group 'linum
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66 :type 'boolean)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 (defcustom linum-delay t
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69 "Delay updates to give Emacs a chance for other changes."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70 :group 'linum
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71 :type 'boolean)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 ;;;###autoload
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74 (define-minor-mode linum-mode
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 "Toggle display of line numbers in the left margin."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
76 :lighter "" ; for desktop.el
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
77 (if linum-mode
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
78 (progn
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
79 (if linum-eager
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80 (add-hook 'post-command-hook (if linum-delay
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81 'linum-schedule
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 'linum-update-current) nil t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 (add-hook 'after-change-functions 'linum-after-change nil t))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
84 (add-hook 'window-scroll-functions 'linum-after-scroll nil t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
85 ;; mistake in Emacs: window-size-change-functions cannot be local
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
86 (add-hook 'window-size-change-functions 'linum-after-size)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
87 (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
88 (add-hook 'window-configuration-change-hook
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
89 'linum-after-config nil t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
90 (linum-update-current))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
91 (remove-hook 'post-command-hook 'linum-update-current t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92 (remove-hook 'post-command-hook 'linum-schedule t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93 (remove-hook 'window-size-change-functions 'linum-after-size)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 (remove-hook 'window-scroll-functions 'linum-after-scroll t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
95 (remove-hook 'after-change-functions 'linum-after-change t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
96 (remove-hook 'window-configuration-change-hook 'linum-after-config t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
97 (remove-hook 'change-major-mode-hook 'linum-delete-overlays t)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
98 (linum-delete-overlays)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
99
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
100 ;;;###autoload
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
101 (define-globalized-minor-mode global-linum-mode linum-mode linum-on)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
102
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103 (defun linum-on ()
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
104 (unless (minibufferp)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
105 (linum-mode 1)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
106
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
107 (defun linum-delete-overlays ()
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
108 "Delete all overlays displaying line numbers for this buffer."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
109 (mapc #'delete-overlay linum-overlays)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 (setq linum-overlays nil)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
111 (dolist (w (get-buffer-window-list (current-buffer) nil t))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
112 (set-window-margins w 0)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
113
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
114 (defun linum-update-current ()
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
115 "Update line numbers for the current buffer."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
116 (linum-update (current-buffer)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
117
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
118 (defun linum-update (buffer)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
119 "Update line numbers for all windows displaying BUFFER."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
120 (with-current-buffer buffer
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
121 (when linum-mode
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
122 (setq linum-available linum-overlays)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
123 (setq linum-overlays nil)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
124 (save-excursion
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
125 (mapc #'linum-update-window
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
126 (get-buffer-window-list buffer nil 'visible)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
127 (mapc #'delete-overlay linum-available)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
128 (setq linum-available nil))))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
129
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
130 (defun linum-update-window (win)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
131 "Update line numbers for the portion visible in window WIN."
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
132 (goto-char (window-start win))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
133 (let ((line (line-number-at-pos))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
134 (limit (1+ (window-end win t)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
135 (fmt (cond ((stringp linum-format) linum-format)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
136 ((eq linum-format 'dynamic)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
137 (let ((w (length (number-to-string
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
138 (count-lines (point-min) (point-max))))))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
139 (concat "%" (number-to-string w) "d")))))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 (width 0)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141 visited
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 ov)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 (run-hooks 'linum-before-numbering-hook)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144 ;; Create an overlay (or reuse an existing one) for each
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145 ;; line visible in this window, if necessary.
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146 (while (and (not (eobp)) (< (point) limit))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
147 (setq visited nil)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
148 (dolist (o (overlays-in (point) (point)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
149 (when (eq (overlay-get o 'linum-line) line)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
150 (unless (memq o linum-overlays)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
151 (push o linum-overlays))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
152 (setq linum-available (delete o linum-available))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
153 (setq visited t)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
154 (let ((str (if fmt
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
155 (propertize (format fmt line) 'face 'linum)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
156 (funcall linum-format line))))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
157 (setq width (max width (length str)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
158 (unless visited
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
159 (if (null linum-available)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
160 (setq ov (make-overlay (point) (point)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
161 (setq ov (pop linum-available))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
162 (move-overlay ov (point) (point)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
163 (push ov linum-overlays)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
164 (setq str (propertize " " 'display `((margin left-margin) ,str)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
165 (overlay-put ov 'before-string str)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
166 (overlay-put ov 'linum-line line)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
167 (forward-line)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
168 (setq line (1+ line)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
169 (set-window-margins win width)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
170
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
171 (defun linum-after-change (beg end len)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
172 ;; update overlays on deletions, and after newlines are inserted
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
173 (when (or (= beg end)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
174 (= end (point-max))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
175 (string-match-p "\n" (buffer-substring-no-properties beg end)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
176 (linum-update-current)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
177
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
178 (defun linum-after-scroll (win start)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
179 (linum-update (window-buffer win)))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
180
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
181 (defun linum-after-size (frame)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
182 (linum-after-config))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
183
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
184 (defun linum-schedule ()
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
185 ;; schedule an update; the delay gives Emacs a chance for display changes
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
186 (run-with-idle-timer 0 nil #'linum-update-current))
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
187
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
188 (defun linum-after-config ()
92141
87d23b09ce4d (linum-after-config): Update all visible windows.
Juanma Barranquero <lekktu@gmail.com>
parents: 88090
diff changeset
189 (walk-windows (lambda (w) (linum-update (window-buffer w))) nil 'visible))
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
190
88090
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
191 (defun linum-unload-function ()
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
192 "Unload the Linum library."
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
193 (global-linum-mode -1)
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
194 ;; continue standard unloading
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
195 nil)
b796e645bb4e (linum-unload-function): New function.
Juanma Barranquero <lekktu@gmail.com>
parents: 88076
diff changeset
196
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
197 (provide 'linum)
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
198
88076
7caa67533b3a Add arch tagline
Miles Bader <miles@gnu.org>
parents: 88075
diff changeset
199 ;; arch-tag: dea45631-ed3c-4867-8b49-1c41c80aec6a
88073
c720c7381645 New file.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
200 ;;; linum.el ends here