Mercurial > emacs
comparison lisp/textmodes/nroff-mode.el @ 85858:0745c5662909
(nroff-mode): Set indent-line-function.
(nroff-indent-line-function): New function.
(nroff-count-text-lines): Use nroff-forward-text-line rather than
obsolete alias.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 01 Nov 2007 04:00:09 +0000 |
parents | e5a68f18fcb9 |
children | e8570ba362b2 |
comparison
equal
deleted
inserted
replaced
85857:84fe4e940d8d | 85858:0745c5662909 |
---|---|
130 ;; comment syntax added by mit-erl!gildea 18 Apr 86 | 130 ;; comment syntax added by mit-erl!gildea 18 Apr 86 |
131 (set (make-local-variable 'comment-start) "\\\" ") | 131 (set (make-local-variable 'comment-start) "\\\" ") |
132 (set (make-local-variable 'comment-start-skip) "\\\\[\"#][ \t]*") | 132 (set (make-local-variable 'comment-start-skip) "\\\\[\"#][ \t]*") |
133 (set (make-local-variable 'comment-column) 24) | 133 (set (make-local-variable 'comment-column) 24) |
134 (set (make-local-variable 'comment-indent-function) 'nroff-comment-indent) | 134 (set (make-local-variable 'comment-indent-function) 'nroff-comment-indent) |
135 (set (make-local-variable 'indent-line-function) 'nroff-indent-line-function) | |
135 (set (make-local-variable 'imenu-generic-expression) nroff-imenu-expression)) | 136 (set (make-local-variable 'imenu-generic-expression) nroff-imenu-expression)) |
136 | 137 |
137 (defun nroff-outline-level () | 138 (defun nroff-outline-level () |
138 (save-excursion | 139 (save-excursion |
139 (looking-at outline-regexp) | 140 (looking-at outline-regexp) |
161 (max comment-column | 162 (max comment-column |
162 (* 8 (/ (+ (current-column) | 163 (* 8 (/ (+ (current-column) |
163 9) 8)))))) ; add 9 to ensure at least two blanks | 164 9) 8)))))) ; add 9 to ensure at least two blanks |
164 (goto-char pt)))) | 165 (goto-char pt)))) |
165 | 166 |
167 ;; All this does is insert a "." at the start of comment-lines, | |
168 ;; for the sake of comment-dwim adding a new comment on an empty line. | |
169 ;; Hack! The right fix probably involves ;; comment-insert-comment-function, | |
170 ;; but comment-dwim does not call that for the empty line case. | |
171 ;; http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg01869.html | |
172 (defun nroff-indent-line-function () | |
173 "Function for `indent-line-function' in `nroff-mode'." | |
174 (save-excursion | |
175 (forward-line 0) | |
176 (when (looking-at "[ \t]*\\\\\"[ \t]*") ; \# does not need this | |
177 (delete-horizontal-space) | |
178 (insert ?.)))) | |
179 | |
166 (defun nroff-count-text-lines (start end &optional print) | 180 (defun nroff-count-text-lines (start end &optional print) |
167 "Count lines in region, except for nroff request lines. | 181 "Count lines in region, except for nroff request lines. |
168 All lines not starting with a period are counted up. | 182 All lines not starting with a period are counted up. |
169 Interactively, print result in echo area. | 183 Interactively, print result in echo area. |
170 Noninteractively, return number of non-request lines from START to END." | 184 Noninteractively, return number of non-request lines from START to END." |
173 (message "Region has %d text lines" (nroff-count-text-lines start end)) | 187 (message "Region has %d text lines" (nroff-count-text-lines start end)) |
174 (save-excursion | 188 (save-excursion |
175 (save-restriction | 189 (save-restriction |
176 (narrow-to-region start end) | 190 (narrow-to-region start end) |
177 (goto-char (point-min)) | 191 (goto-char (point-min)) |
178 (- (buffer-size) (forward-text-line (buffer-size))))))) | 192 (- (buffer-size) (nroff-forward-text-line (buffer-size))))))) |
179 | 193 |
180 (defun nroff-forward-text-line (&optional cnt) | 194 (defun nroff-forward-text-line (&optional cnt) |
181 "Go forward one nroff text line, skipping lines of nroff requests. | 195 "Go forward one nroff text line, skipping lines of nroff requests. |
182 An argument is a repeat count; if negative, move backward." | 196 An argument is a repeat count; if negative, move backward." |
183 (interactive "p") | 197 (interactive "p") |