2
## 50_setnu.dpatch by Peter S Galbraith <psg@debian.org>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: setnu defface and checkdoc cleanup.
8
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
12
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
13
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
16
-patch) patch $patch_opts -p1 < $0;;
17
-unpatch) patch $patch_opts -p1 -R < $0;;
19
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
26
diff -urNad /home/psg/emacs/emacs-goodies-el/emacs-goodies-el/elisp/emacs-goodies-el/setnu.el emacs-goodies-el/elisp/emacs-goodies-el/setnu.el
27
--- /home/psg/emacs/emacs-goodies-el/emacs-goodies-el/elisp/emacs-goodies-el/setnu.el 2003-10-15 20:54:31.000000000 -0400
28
+++ emacs-goodies-el/elisp/emacs-goodies-el/setnu.el 2003-10-14 21:37:45.000000000 -0400
30
-;;; vi-style line number mode for Emacs
31
-;;; (requires Emacs 19.29 or later, or XEmacs 19.14 or later)
32
-;;; Copyright (C) 1994, 1995, 1997 Kyle E. Jones
34
-;;; This program is free software; you can redistribute it and/or modify
35
-;;; it under the terms of the GNU General Public License as published by
36
-;;; the Free Software Foundation; either version 2, or (at your option)
37
-;;; any later version.
39
-;;; This program is distributed in the hope that it will be useful,
40
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
41
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42
-;;; GNU General Public License for more details.
44
-;;; A copy of the GNU General Public License can be obtained from this
45
-;;; program's author (send electronic mail to kyle@uunet.uu.net) or from
46
-;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
49
-;;; Send bug reports to kyle@wonderworks.com
50
+;;; setnu.el --- vi-style line number mode for Emacs
52
+;; (requires Emacs 19.29 or later, or XEmacs 19.14 or later)
53
+;; Copyright (C) 1994, 1995, 1997 Kyle E. Jones
55
+;; This program is free software; you can redistribute it and/or modify
56
+;; it under the terms of the GNU General Public License as published by
57
+;; the Free Software Foundation; either version 2, or (at your option)
58
+;; any later version.
60
+;; This program is distributed in the hope that it will be useful,
61
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
62
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63
+;; GNU General Public License for more details.
65
+;; A copy of the GNU General Public License can be obtained from this
66
+;; program's author (send electronic mail to kyle@uunet.uu.net) or from
67
+;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
72
+;; Send bug reports to kyle@wonderworks.com
74
;; M-x setnu-mode toggles the line number mode on and off.
76
-;; turn-on-setnu-mode is useful for adding to a major-mode hook
78
+;; turn-on-setnu-mode is useful for adding to a major-mode hook variable.
80
;; (add-hook 'text-mode-hook 'turn-on-setnu-mode)
81
-;; to automatically turn on line numbering when enterting text-mode."
82
+;; to automatically turn on line numbering when enterting text-mode."
86
+;; 2003-10-13 Peter S Galbraith <psg@debian.org>
87
+;; - made checkdoc changes (but it's still not happy).
88
+;; - created settnu defgroup and created defface setnu-line-number-face.
89
+;; - added atoload tags.
94
(defconst setnu-running-under-xemacs
96
(string-match "Lucid" emacs-version)))
98
(defconst setnu-mode-version "1.06"
99
- "Version number for this release of setnu-mode.")
100
+ "Version number for this release of `setnu-mode'.")
102
(defvar setnu-mode nil
103
- "Non-nil if setnu-mode is active in the current buffer.")
104
+ "Non-nil if `setnu-mode' is active in the current buffer.")
105
(make-variable-buffer-local 'setnu-mode)
107
(defvar setnu-start-extent nil
108
- "First extent of a chain of extents used by setnu-mode.
109
+ "First extent of a chain of extents used by `setnu-mode'.
110
Each line has its own extent. Each line extent has a
111
`setnu-next-extent' property that points to the next extent in
112
the chain, which is the extent for the next line in the buffer.
113
There is also a `setnu-prev-extent' that points at the previous
114
extent in the chain. To distinguish them from other extents the
115
-setnu-mode extents all have a non-nil `setnu' property.")
116
+`setnu-mode' extents all have a non-nil `setnu' property.")
117
(make-variable-buffer-local 'setnu-start-extent)
119
(defvar setnu-glyph-obarray (make-vector 401 0)
121
`format' will be called with this string and one other argument
122
which will be an integer, the line number.")
124
-(defvar setnu-line-number-face 'bold
125
- "*Face used to display the line numbers.
126
-Currently this works for XEmacs 19.12 and later versions only.")
127
+(defvar setnu-line-number-face 'setnu-line-number-face
128
+ "*Face used to display the line numbers.")
131
+ "vi-style line number mode for Emacs.")
133
+(defface setnu-line-number-face '((t (:bold t)))
134
+ "*Face used to display the line numbers."
138
(defun setnu-mode (&optional arg)
139
- "Toggle setnu-mode.
140
-With prefix argument, turn setnu-mode on if argument is positive.
141
-When setnu-mode is enabled, a line number will appear at the left
142
+ "Toggle `setnu-mode'.
143
+With prefix argument ARG, turn `setnu-mode' on if argument is positive.
144
+When `setnu-mode' is enabled, a line number will appear at the left
145
margin of each line."
147
(let ((oldmode (not (not setnu-mode)))
153
(defun turn-on-setnu-mode ()
154
- "Turn on setnu-mode.
155
-Useful for adding to a major-mode hook variable.
156
+ "Turn on `setnu-mode'.
157
+Useful for adding to a `major-mode' hook variable.
159
(add-hook 'text-mode-hook 'turn-on-setnu-mode)
160
-to automatically turn on line numbering when enterting text-mode."
161
+to automatically turn on line numbering when enterting `text-mode'."
164
;;; Internal functions
166
(put-text-property 0 (length g) 'face face g))))
168
(defun setnu-mode-off ()
169
- "Internal shutdown of setnu-mode.
170
-Deletes the extents associated with setnu-mode."
171
+ "Internal shutdown of `setnu-mode'.
172
+Deletes the extents associated with `setnu-mode'."
173
(if (and setnu-running-under-xemacs
174
(fboundp 'remove-specifier))
175
(remove-specifier left-margin-width (current-buffer)))
176
@@ -163,11 +181,13 @@
177
(setq setnu-start-extent nil))))
179
(defun setnu-mode-on ()
180
- "Internal startup of setnu-mode.
181
-Sets up the extents associated with setnu-mode."
182
+ "Internal startup of `setnu-mode'.
183
+Sets up the extents associated with `setnu-mode'."
184
(if (and setnu-running-under-xemacs
185
(fboundp 'set-specifier))
186
(set-specifier left-margin-width 6 (current-buffer)))
187
+ (add-hook 'before-change-functions 'setnu-before-change-function)
188
+ (add-hook 'after-change-functions 'setnu-after-change-function)
193
(store-match-data match-data))))
195
(defun setnu-before-change-function (start end)
196
- "Before change function for setnu-mode.
197
+ "Before change function for `setnu-mode'.
198
Notices when a delete is about to delete some lines and adjusts
199
-the line number extents accordingly."
200
+the line number extents accordingly (betwee START and END)."
201
(if (or (not setnu-mode) (= start end))
202
() ;; not in setnu-mode or this is an insertion
203
(let ((inhibit-quit t)
205
(store-match-data match-data)))))
207
(defun setnu-after-change-function (start end length)
208
- "After change function for setnu-mode.
209
+ "After change function for `setnu-mode'.
210
Notices when an insert has added some lines and adjusts
211
-the line number extents accordingly."
212
+the line number extents accordingly.
213
+Three arguments are passed to an `after-change-function': the positions of
214
+the START and END of the range of changed text,
215
+and the LENGTH in bytes of the pre-change text replaced by that range."
216
(if (or (not setnu-mode) (= start end))
217
() ; not in setnu-mode or this is a deletion
218
(let ((inhibit-quit t)
222
(defun setnu-make-setnu-extent (beg end)
223
- "Create an extent and set some properties that all setnu extents have."
224
+ "Create an extent and set some properties that all setnu extents have.
225
+Extent is between BEG and END."
226
(let ((e (setnu-make-extent beg end)))
227
(setnu-set-extent-property e 'setnu t)
228
;; (setnu-set-extent-property e 'begin-glyph-layout 'outside-margin)
229
@@ -389,11 +413,12 @@
233
- (t (error "can't find overlays-in, overlays-at, or map-extents!")))
234
+ (t (error "Can't find overlays-in, overlays-at, or map-extents!")))
236
(defun setnu-extent-at-create (pos buf)
237
- "Like `setnu-extent-at' except if an extent isn't found, then
238
-it is created based on where the extent failed to be found."
239
+ "Like `setnu-extent-at' for position POS in buffer BUF.
240
+If an extent isn't found, then it is created based on where the extent failed
242
(let ((e (setnu-extent-at pos buf)) ee beg numstr)
246
(setnu-set-extent-begin-glyph e (setnu-number-glyph numstr))
249
-(add-hook 'before-change-functions 'setnu-before-change-function)
250
-(add-hook 'after-change-functions 'setnu-after-change-function)
253
+;;; setnu.el ends here