diff options
| author | Stefan Monnier | 2006-02-06 23:13:22 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-02-06 23:13:22 +0000 |
| commit | ea37fbb817c487fea0ca3691df0b9ae70e86d5be (patch) | |
| tree | 606ef0a6ea392f38f21c64f12b3cac6baa3a19f8 | |
| parent | a2c40109dee0a1e431fc52e405d5412bd74acf78 (diff) | |
| download | emacs-ea37fbb817c487fea0ca3691df0b9ae70e86d5be.tar.gz emacs-ea37fbb817c487fea0ca3691df0b9ae70e86d5be.zip | |
Clean up name space.
(nroff-mode-syntax-table): Remove spurious `1' in the syntax of \n.
(nroff-mode): Obey the global setting of nroff-electric-mode.
(nroff-electric-mode): Use define-minor-mode and derived-mode-p.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/textmodes/nroff-mode.el | 52 |
2 files changed, 31 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2822e1c1d1b..12aebc4a66b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2006-02-06 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2006-02-06 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * textmodes/nroff-mode.el: Clean up name space. | ||
| 4 | (nroff-mode-syntax-table): Remove spurious `1' in the syntax of \n. | ||
| 5 | (nroff-mode): Obey the global setting of nroff-electric-mode. | ||
| 6 | (nroff-electric-mode): Use define-minor-mode and derived-mode-p. | ||
| 7 | |||
| 3 | * calendar/calendar.el (calendar-increment-month): Typo in last change. | 8 | * calendar/calendar.el (calendar-increment-month): Typo in last change. |
| 4 | 9 | ||
| 5 | 2006-02-06 Thien-Thi Nguyen <ttn@gnu.org> | 10 | 2006-02-06 Thien-Thi Nguyen <ttn@gnu.org> |
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el index ababc041099..4a07b091e2a 100644 --- a/lisp/textmodes/nroff-mode.el +++ b/lisp/textmodes/nroff-mode.el | |||
| @@ -42,8 +42,9 @@ | |||
| 42 | :group 'wp | 42 | :group 'wp |
| 43 | :prefix "nroff-") | 43 | :prefix "nroff-") |
| 44 | 44 | ||
| 45 | |||
| 45 | (defcustom nroff-electric-mode nil | 46 | (defcustom nroff-electric-mode nil |
| 46 | "*Non-nil means automatically closing requests when you insert an open." | 47 | "Non-nil means automatically closing requests when you insert an open." |
| 47 | :group 'nroff | 48 | :group 'nroff |
| 48 | :type 'boolean) | 49 | :type 'boolean) |
| 49 | 50 | ||
| @@ -51,10 +52,10 @@ | |||
| 51 | (let ((map (make-sparse-keymap))) | 52 | (let ((map (make-sparse-keymap))) |
| 52 | (define-key map "\t" 'tab-to-tab-stop) | 53 | (define-key map "\t" 'tab-to-tab-stop) |
| 53 | (define-key map "\es" 'center-line) | 54 | (define-key map "\es" 'center-line) |
| 54 | (define-key map "\e?" 'count-text-lines) | 55 | (define-key map "\e?" 'nroff-count-text-lines) |
| 55 | (define-key map "\n" 'electric-nroff-newline) | 56 | (define-key map "\n" 'nroff-electric-newline) |
| 56 | (define-key map "\en" 'forward-text-line) | 57 | (define-key map "\en" 'nroff-forward-text-line) |
| 57 | (define-key map "\ep" 'backward-text-line) | 58 | (define-key map "\ep" 'nroff-backward-text-line) |
| 58 | map) | 59 | map) |
| 59 | "Major mode keymap for `nroff-mode'.") | 60 | "Major mode keymap for `nroff-mode'.") |
| 60 | 61 | ||
| @@ -66,7 +67,7 @@ | |||
| 66 | (modify-syntax-entry ?\" "\" 2" st) | 67 | (modify-syntax-entry ?\" "\" 2" st) |
| 67 | ;; Comments are delimited by \" and newline. | 68 | ;; Comments are delimited by \" and newline. |
| 68 | (modify-syntax-entry ?\\ "\\ 1" st) | 69 | (modify-syntax-entry ?\\ "\\ 1" st) |
| 69 | (modify-syntax-entry ?\n "> 1" st) | 70 | (modify-syntax-entry ?\n ">" st) |
| 70 | st) | 71 | st) |
| 71 | "Syntax table used while in `nroff-mode'.") | 72 | "Syntax table used while in `nroff-mode'.") |
| 72 | 73 | ||
| @@ -116,7 +117,6 @@ closing requests for requests that are used in matched pairs." | |||
| 116 | ;; near the end of large buffers due to searching to buffer's | 117 | ;; near the end of large buffers due to searching to buffer's |
| 117 | ;; beginning. | 118 | ;; beginning. |
| 118 | '(nroff-font-lock-keywords nil t nil backward-paragraph)) | 119 | '(nroff-font-lock-keywords nil t nil backward-paragraph)) |
| 119 | (set (make-local-variable 'nroff-electric-mode) nil) | ||
| 120 | (set (make-local-variable 'outline-regexp) "\\.H[ ]+[1-7]+ ") | 120 | (set (make-local-variable 'outline-regexp) "\\.H[ ]+[1-7]+ ") |
| 121 | (set (make-local-variable 'outline-level) 'nroff-outline-level) | 121 | (set (make-local-variable 'outline-level) 'nroff-outline-level) |
| 122 | ;; now define a bunch of variables for use by commands in this mode | 122 | ;; now define a bunch of variables for use by commands in this mode |
| @@ -138,8 +138,8 @@ closing requests for requests that are used in matched pairs." | |||
| 138 | (skip-chars-forward ".H ") | 138 | (skip-chars-forward ".H ") |
| 139 | (string-to-number (buffer-substring (point) (+ 1 (point)))))) | 139 | (string-to-number (buffer-substring (point) (+ 1 (point)))))) |
| 140 | 140 | ||
| 141 | ;;; Compute how much to indent a comment in nroff/troff source. | 141 | ;; Compute how much to indent a comment in nroff/troff source. |
| 142 | ;;; By mit-erl!gildea April 86 | 142 | ;; By mit-erl!gildea April 86 |
| 143 | (defun nroff-comment-indent () | 143 | (defun nroff-comment-indent () |
| 144 | "Compute indent for an nroff/troff comment. | 144 | "Compute indent for an nroff/troff comment. |
| 145 | Puts a full-stop before comments on a line by themselves." | 145 | Puts a full-stop before comments on a line by themselves." |
| @@ -161,21 +161,21 @@ Puts a full-stop before comments on a line by themselves." | |||
| 161 | 9) 8)))))) ; add 9 to ensure at least two blanks | 161 | 9) 8)))))) ; add 9 to ensure at least two blanks |
| 162 | (goto-char pt)))) | 162 | (goto-char pt)))) |
| 163 | 163 | ||
| 164 | (defun count-text-lines (start end &optional print) | 164 | (defun nroff-count-text-lines (start end &optional print) |
| 165 | "Count lines in region, except for nroff request lines. | 165 | "Count lines in region, except for nroff request lines. |
| 166 | All lines not starting with a period are counted up. | 166 | All lines not starting with a period are counted up. |
| 167 | Interactively, print result in echo area. | 167 | Interactively, print result in echo area. |
| 168 | Noninteractively, return number of non-request lines from START to END." | 168 | Noninteractively, return number of non-request lines from START to END." |
| 169 | (interactive "r\np") | 169 | (interactive "r\np") |
| 170 | (if print | 170 | (if print |
| 171 | (message "Region has %d text lines" (count-text-lines start end)) | 171 | (message "Region has %d text lines" (nroff-count-text-lines start end)) |
| 172 | (save-excursion | 172 | (save-excursion |
| 173 | (save-restriction | 173 | (save-restriction |
| 174 | (narrow-to-region start end) | 174 | (narrow-to-region start end) |
| 175 | (goto-char (point-min)) | 175 | (goto-char (point-min)) |
| 176 | (- (buffer-size) (forward-text-line (buffer-size))))))) | 176 | (- (buffer-size) (forward-text-line (buffer-size))))))) |
| 177 | 177 | ||
| 178 | (defun forward-text-line (&optional cnt) | 178 | (defun nroff-forward-text-line (&optional cnt) |
| 179 | "Go forward one nroff text line, skipping lines of nroff requests. | 179 | "Go forward one nroff text line, skipping lines of nroff requests. |
| 180 | An argument is a repeat count; if negative, move backward." | 180 | An argument is a repeat count; if negative, move backward." |
| 181 | (interactive "p") | 181 | (interactive "p") |
| @@ -193,11 +193,11 @@ An argument is a repeat count; if negative, move backward." | |||
| 193 | (setq cnt (+ cnt 1))) | 193 | (setq cnt (+ cnt 1))) |
| 194 | cnt) | 194 | cnt) |
| 195 | 195 | ||
| 196 | (defun backward-text-line (&optional cnt) | 196 | (defun nroff-backward-text-line (&optional cnt) |
| 197 | "Go backward one nroff text line, skipping lines of nroff requests. | 197 | "Go backward one nroff text line, skipping lines of nroff requests. |
| 198 | An argument is a repeat count; negative means move forward." | 198 | An argument is a repeat count; negative means move forward." |
| 199 | (interactive "p") | 199 | (interactive "p") |
| 200 | (forward-text-line (- cnt))) | 200 | (nroff-forward-text-line (- cnt))) |
| 201 | 201 | ||
| 202 | (defconst nroff-brace-table | 202 | (defconst nroff-brace-table |
| 203 | '((".(b" . ".)b") | 203 | '((".(b" . ".)b") |
| @@ -235,7 +235,7 @@ An argument is a repeat count; negative means move forward." | |||
| 235 | (".nf" . ".fi") | 235 | (".nf" . ".fi") |
| 236 | (".de" . ".."))) | 236 | (".de" . ".."))) |
| 237 | 237 | ||
| 238 | (defun electric-nroff-newline (arg) | 238 | (defun nroff-electric-newline (arg) |
| 239 | "Insert newline for nroff mode; special if electric-nroff mode. | 239 | "Insert newline for nroff mode; special if electric-nroff mode. |
| 240 | In `electric-nroff-mode', if ending a line containing an nroff opening request, | 240 | In `electric-nroff-mode', if ending a line containing an nroff opening request, |
| 241 | automatically inserts the matching closing request after point." | 241 | automatically inserts the matching closing request after point." |
| @@ -256,23 +256,23 @@ automatically inserts the matching closing request after point." | |||
| 256 | (if needs-nl (insert "\n"))) | 256 | (if needs-nl (insert "\n"))) |
| 257 | (forward-char 1)))) | 257 | (forward-char 1)))) |
| 258 | 258 | ||
| 259 | (defun electric-nroff-mode (&optional arg) | 259 | (define-minor-mode nroff-electric-mode |
| 260 | "Toggle `nroff-electric-newline' minor mode. | 260 | "Toggle `nroff-electric-newline' minor mode. |
| 261 | `nroff-electric-newline' forces Emacs to check for an nroff request at the | 261 | `nroff-electric-newline' forces Emacs to check for an nroff request at the |
| 262 | beginning of the line, and insert the matching closing request if necessary. | 262 | beginning of the line, and insert the matching closing request if necessary. |
| 263 | This command toggles that mode (off->on, on->off), with an argument, | 263 | This command toggles that mode (off->on, on->off), with an argument, |
| 264 | turns it on iff arg is positive, otherwise off." | 264 | turns it on iff arg is positive, otherwise off." |
| 265 | (interactive "P") | 265 | :lighter " Electric" |
| 266 | (or (eq major-mode 'nroff-mode) (error "Must be in nroff mode")) | 266 | (or (derived-mode-p 'nroff-mode) (error "Must be in nroff mode"))) |
| 267 | (or (assq 'nroff-electric-mode minor-mode-alist) | 267 | |
| 268 | (setq minor-mode-alist (append minor-mode-alist | 268 | ;; Old names that were not namespace clean. |
| 269 | (list '(nroff-electric-mode | 269 | (define-obsolete-function-alias 'count-text-lines 'nroff-count-text-lines "22.1") |
| 270 | " Electric"))))) | 270 | (define-obsolete-function-alias 'forward-text-line 'nroff-forward-text-line "22.1") |
| 271 | (setq nroff-electric-mode | 271 | (define-obsolete-function-alias 'backward-text-line 'nroff-backward-text-line "22.1") |
| 272 | (cond ((null arg) (null nroff-electric-mode)) | 272 | (define-obsolete-function-alias 'electric-nroff-newline 'nroff-electric-newline "22.1") |
| 273 | (t (> (prefix-numeric-value arg) 0))))) | 273 | (define-obsolete-function-alias 'electric-nroff-mode 'nroff-electric-mode "22.1") |
| 274 | 274 | ||
| 275 | (provide 'nroff-mode) | 275 | (provide 'nroff-mode) |
| 276 | 276 | ||
| 277 | ;;; arch-tag: 6e276340-6c65-4f65-b4e3-0ca431ddfb6c | 277 | ;; arch-tag: 6e276340-6c65-4f65-b4e3-0ca431ddfb6c |
| 278 | ;;; nroff-mode.el ends here | 278 | ;;; nroff-mode.el ends here |