Mercurial > emacs
annotate lisp/progmodes/cc-cmds.el @ 26706:705ff8a9d6dd
Derived from acorn.h by deletions.
author | Dave Love <fx@gnu.org> |
---|---|
date | Sat, 04 Dec 1999 19:46:10 +0000 |
parents | 2986e6d0e927 |
children | 03befb219d03 |
rev | line source |
---|---|
24282 | 1 ;;; cc-cmds.el --- user level commands for CC Mode |
18720 | 2 |
24282 | 3 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Softare Foundation, Inc. |
18720 | 4 |
24282 | 5 ;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm |
6 ;; 1992-1997 Barry A. Warsaw | |
18720 | 7 ;; 1987 Dave Detlefs and Stewart Clamen |
8 ;; 1985 Richard M. Stallman | |
24282 | 9 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 10 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
11 ;; Version: See cc-mode.el |
18720 | 12 ;; Keywords: c languages oop |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 ;; Boston, MA 02111-1307, USA. | |
30 | |
18843
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
31 |
18720 | 32 |
24282 | 33 (eval-when-compile |
34 (require 'cc-defs)) | |
35 | |
18720 | 36 (defun c-calculate-state (arg prevstate) |
37 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If | |
38 ;; arg is nil or zero, toggle the state. If arg is negative, turn | |
39 ;; the state off, and if arg is positive, turn the state on | |
40 (if (or (not arg) | |
41 (zerop (setq arg (prefix-numeric-value arg)))) | |
42 (not prevstate) | |
43 (> arg 0))) | |
44 | |
45 ;; Auto-newline and hungry-delete | |
46 (defun c-toggle-auto-state (arg) | |
47 "Toggle auto-newline feature. | |
48 Optional numeric ARG, if supplied turns on auto-newline when positive, | |
49 turns it off when negative, and just toggles it when zero. | |
50 | |
51 When the auto-newline feature is enabled (as evidenced by the `/a' or | |
52 `/ah' on the modeline after the mode name) newlines are automatically | |
53 inserted after special characters such as brace, comma, semi-colon, | |
54 and colon." | |
55 (interactive "P") | |
56 (setq c-auto-newline (c-calculate-state arg c-auto-newline)) | |
57 (c-update-modeline) | |
58 (c-keep-region-active)) | |
59 | |
60 (defun c-toggle-hungry-state (arg) | |
61 "Toggle hungry-delete-key feature. | |
62 Optional numeric ARG, if supplied turns on hungry-delete when positive, | |
63 turns it off when negative, and just toggles it when zero. | |
64 | |
65 When the hungry-delete-key feature is enabled (as evidenced by the | |
66 `/h' or `/ah' on the modeline after the mode name) the delete key | |
67 gobbles all preceding whitespace in one fell swoop." | |
68 (interactive "P") | |
69 (setq c-hungry-delete-key (c-calculate-state arg c-hungry-delete-key)) | |
70 (c-update-modeline) | |
71 (c-keep-region-active)) | |
72 | |
73 (defun c-toggle-auto-hungry-state (arg) | |
74 "Toggle auto-newline and hungry-delete-key features. | |
75 Optional numeric ARG, if supplied turns on auto-newline and | |
76 hungry-delete when positive, turns them off when negative, and just | |
77 toggles them when zero. | |
78 | |
79 See `c-toggle-auto-state' and `c-toggle-hungry-state' for details." | |
80 (interactive "P") | |
81 (setq c-auto-newline (c-calculate-state arg c-auto-newline)) | |
82 (setq c-hungry-delete-key (c-calculate-state arg c-hungry-delete-key)) | |
83 (c-update-modeline) | |
84 (c-keep-region-active)) | |
85 | |
86 | |
87 ;; Electric keys | |
88 | |
89 ;; Note: In XEmacs 20.3 the Delete and BackSpace keysyms have been | |
90 ;; separated and "\177" is no longer an alias for both keys. Also, | |
91 ;; the variable delete-key-deletes-forward controls in which direction | |
92 ;; the Delete keysym deletes characters. The functions | |
93 ;; c-electric-delete and c-electric-backspace attempt to deal with | |
94 ;; this new functionality. For Emacs 19 and XEmacs 19 backwards | |
95 ;; compatibility, the old behavior has moved to c-electric-backspace | |
96 ;; and c-backspace-function. | |
97 | |
98 (defun c-electric-backspace (arg) | |
99 "Deletes preceding character or whitespace. | |
100 If `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or | |
101 \"/ah\" string on the mode line, then all preceding whitespace is | |
102 consumed. If however an ARG is supplied, or `c-hungry-delete-key' is | |
103 nil, or point is inside a literal then the function in the variable | |
104 `c-backspace-function' is called. | |
105 | |
106 See also \\[c-electric-delete]." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
107 (interactive "*P") |
18720 | 108 (if (or (not c-hungry-delete-key) |
109 arg | |
110 (c-in-literal)) | |
111 (funcall c-backspace-function (prefix-numeric-value arg)) | |
112 (let ((here (point))) | |
113 (skip-chars-backward " \t\n") | |
114 (if (/= (point) here) | |
115 (delete-region (point) here) | |
116 (funcall c-backspace-function 1) | |
117 )))) | |
118 | |
119 (defun c-electric-delete (arg) | |
120 "Deletes preceding or following character or whitespace. | |
121 | |
122 The behavior of this function depends on the variable | |
123 `delete-key-deletes-forward'. If this variable is nil (or does not | |
124 exist, as in older Emacsen), then this function behaves identical to | |
125 \\[c-electric-backspace]. | |
126 | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
127 If `delete-key-deletes-forward' is non-nil and is supported in your |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
128 Emacs, then deletion occurs in the forward direction. So if |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
129 `c-hungry-delete-key' is non-nil, as evidenced by the \"/h\" or |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
130 \"/ah\" string on the mode line, then all following whitespace is |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
131 consumed. If however an ARG is supplied, or `c-hungry-delete-key' is |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
132 nil, or point is inside a literal then the function in the variable |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
133 `c-delete-function' is called." |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
134 (interactive "*P") |
24282 | 135 (if (or (and (fboundp 'delete-forward-p) ;XEmacs 21 |
136 (delete-forward-p)) | |
137 (and (boundp 'delete-key-deletes-forward) ;XEmacs 20 | |
138 delete-key-deletes-forward)) | |
18720 | 139 (if (or (not c-hungry-delete-key) |
140 arg | |
141 (c-in-literal)) | |
142 (funcall c-delete-function (prefix-numeric-value arg)) | |
143 (let ((here (point))) | |
144 (skip-chars-forward " \t\n") | |
145 (if (/= (point) here) | |
146 (delete-region (point) here) | |
147 (funcall c-delete-function 1)))) | |
148 ;; act just like c-electric-backspace | |
149 (c-electric-backspace arg))) | |
150 | |
151 (defun c-electric-pound (arg) | |
152 "Electric pound (`#') insertion. | |
153 Inserts a `#' character specially depending on the variable | |
154 `c-electric-pound-behavior'. If a numeric ARG is supplied, or if | |
155 point is inside a literal, nothing special happens." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
156 (interactive "*P") |
24282 | 157 (if (or arg |
158 (not (memq 'alignleft c-electric-pound-behavior)) | |
159 (save-excursion (skip-chars-backward " \t") (not (bolp))) | |
160 (c-in-literal)) | |
18720 | 161 ;; do nothing special |
162 (self-insert-command (prefix-numeric-value arg)) | |
163 ;; place the pound character at the left edge | |
164 (let ((pos (- (point-max) (point))) | |
165 (bolp (bolp))) | |
166 (beginning-of-line) | |
167 (delete-horizontal-space) | |
168 (insert-char last-command-char 1) | |
169 (and (not bolp) | |
170 (goto-char (- (point-max) pos))) | |
171 ))) | |
172 | |
173 (defun c-electric-brace (arg) | |
174 "Insert a brace. | |
175 | |
176 If the auto-newline feature is turned on, as evidenced by the \"/a\" | |
177 or \"/ah\" string on the mode line, newlines are inserted before and | |
178 after braces based on the value of `c-hanging-braces-alist'. | |
179 | |
180 Also, the line is re-indented unless a numeric ARG is supplied, there | |
181 are non-whitespace characters present on the line after the brace, or | |
24282 | 182 the brace is inserted inside a literal. |
183 | |
184 This function does various newline cleanups based on the value of | |
185 `c-cleanup-list'." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
186 (interactive "*P") |
18720 | 187 (let* ((c-state-cache (c-parse-state)) |
188 (safepos (c-safe-position (point) c-state-cache)) | |
189 (literal (c-in-literal safepos))) | |
190 ;; if we're in a literal, or we're not at the end of the line, or | |
191 ;; a numeric arg is provided, or auto-newlining is turned off, | |
192 ;; then just insert the character. | |
24282 | 193 (if (or literal |
194 arg | |
18720 | 195 (not (looking-at "[ \t]*$"))) |
196 (self-insert-command (prefix-numeric-value arg)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
197 (let* ((syms |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
198 ;; This is the list of brace syntactic symbols that can |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
199 ;; hang. If any new ones are added to c-offsets-alist, |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
200 ;; they should be added here as well. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
201 '(class-open class-close defun-open defun-close |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
202 inline-open inline-close |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
203 brace-list-open brace-list-close |
24282 | 204 brace-list-intro brace-entry-open |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
205 block-open block-close |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
206 substatement-open statement-case-open |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
207 extern-lang-open extern-lang-close |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
208 namespace-open namespace-close |
24282 | 209 inexpr-class-open inexpr-class-close |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
210 )) |
18720 | 211 ;; we want to inhibit blinking the paren since this will |
212 ;; be most disruptive. we'll blink it ourselves later on | |
213 (old-blink-paren blink-paren-function) | |
214 blink-paren-function | |
215 (insertion-point (point)) | |
216 delete-temp-newline | |
19306
974544be1a17
(c-electric-brace): Make preserve-p nil at BOB.
Richard M. Stallman <rms@gnu.org>
parents:
19297
diff
changeset
|
217 (preserve-p (and (not (bobp)) |
974544be1a17
(c-electric-brace): Make preserve-p nil at BOB.
Richard M. Stallman <rms@gnu.org>
parents:
19297
diff
changeset
|
218 (eq ?\ (char-syntax (char-before))))) |
18720 | 219 ;; shut this up too |
220 (c-echo-syntactic-information-p nil) | |
221 (syntax (progn | |
222 ;; only insert a newline if there is | |
223 ;; non-whitespace behind us | |
224 (if (save-excursion | |
225 (skip-chars-backward " \t") | |
226 (not (bolp))) | |
227 (progn (newline) | |
228 (setq delete-temp-newline t))) | |
229 (self-insert-command (prefix-numeric-value arg)) | |
230 ;; state cache doesn't change | |
231 (c-guess-basic-syntax))) | |
232 (newlines (and | |
233 c-auto-newline | |
24282 | 234 (or (c-lookup-lists |
235 syms | |
236 ;; Substitute inexpr-class and class-open | |
237 ;; or class-close with inexpr-class-open | |
238 ;; or inexpr-class-close. | |
239 (if (assq 'inexpr-class syntax) | |
240 (cond ((assq 'class-open syntax) | |
241 '((inexpr-class-open))) | |
242 ((assq 'class-close syntax) | |
243 '((inexpr-class-close))) | |
244 (t syntax)) | |
245 syntax) | |
246 c-hanging-braces-alist) | |
18720 | 247 '(ignore before after))))) |
24282 | 248 ;; Do not try to insert newlines around a special (Pike-style) |
249 ;; brace list. | |
250 (if (and c-special-brace-lists | |
251 (c-intersect-lists '(brace-list-open brace-list-close | |
252 brace-list-intro brace-entry-open) | |
253 syntax) | |
254 (save-excursion | |
255 (c-safe (if (= (char-before) ?{) | |
256 (forward-char -1) | |
257 (c-forward-sexp -1)) | |
258 (c-looking-at-special-brace-list)))) | |
259 (setq newlines nil)) | |
18720 | 260 ;; If syntax is a function symbol, then call it using the |
261 ;; defined semantics. | |
262 (if (and (not (consp (cdr newlines))) | |
263 (functionp (cdr newlines))) | |
264 (let ((c-syntactic-context syntax)) | |
265 (setq newlines | |
266 (funcall (cdr newlines) (car newlines) insertion-point)))) | |
267 ;; does a newline go before the open brace? | |
268 (if (memq 'before newlines) | |
269 ;; we leave the newline we've put in there before, | |
270 ;; but we need to re-indent the line above | |
271 (let ((pos (- (point-max) (point))) | |
24282 | 272 (here (point))) |
18720 | 273 (forward-line -1) |
24282 | 274 (let ((c-state-cache (c-whack-state (point) c-state-cache))) |
275 ;; we may need to update the cache. this should | |
276 ;; still be faster than recalculating the state | |
277 ;; in many cases | |
278 (save-excursion | |
279 (save-restriction | |
280 (narrow-to-region here (point)) | |
281 (if (and (c-safe (progn (backward-up-list -1) t)) | |
282 (memq (char-before) '(?\) ?})) | |
283 (progn (widen) | |
284 (c-safe (progn (c-forward-sexp -1) | |
285 t)))) | |
286 (setq c-state-cache | |
287 (c-hack-state (point) 'open c-state-cache))))) | |
288 (c-indent-line)) | |
289 (setq c-state-cache (c-adjust-state (c-point 'bol) here | |
290 (- (point) (c-point 'bol)) | |
291 c-state-cache)) | |
18720 | 292 (goto-char (- (point-max) pos)) |
293 ;; if the buffer has changed due to the indentation, we | |
294 ;; need to recalculate syntax for the current line, but | |
295 ;; we won't need to update the state cache. | |
296 (if (/= (point) here) | |
297 (setq syntax (c-guess-basic-syntax)))) | |
298 ;; must remove the newline we just stuck in (if we really did it) | |
299 (and delete-temp-newline | |
300 (save-excursion | |
301 ;; if there is whitespace before point, then preserve | |
302 ;; at least one space. | |
303 (delete-indentation) | |
304 (just-one-space) | |
305 (if (not preserve-p) | |
306 (delete-char -1)))) | |
307 ;; since we're hanging the brace, we need to recalculate | |
308 ;; syntax. Update the state to accurately reflect the | |
309 ;; beginning of the line. We punt if we cross any open or | |
310 ;; closed parens because its just too hard to modify the | |
311 ;; known state. This limitation will be fixed in v5. | |
312 (save-excursion | |
313 (let ((bol (c-point 'bol))) | |
314 (if (zerop (car (parse-partial-sexp bol (1- (point))))) | |
315 (setq c-state-cache (c-whack-state bol c-state-cache) | |
316 syntax (c-guess-basic-syntax)) | |
317 ;; gotta punt. this requires some horrible kludgery | |
318 (beginning-of-line) | |
319 (makunbound 'c-state-cache) | |
320 (setq c-state-cache (c-parse-state) | |
321 syntax nil)))) | |
322 ) | |
323 ;; now adjust the line's indentation. don't update the state | |
324 ;; cache since c-guess-basic-syntax isn't called when the | |
325 ;; syntax is passed to c-indent-line | |
24282 | 326 (let* ((here (point))) |
327 (c-indent-line syntax) | |
18720 | 328 (setq c-state-cache (c-adjust-state (c-point 'bol) here |
24282 | 329 (- (c-point 'boi) (c-point 'bol)) |
330 c-state-cache))) | |
18720 | 331 ;; Do all appropriate clean ups |
332 (let ((here (point)) | |
333 (pos (- (point-max) (point))) | |
334 mbeg mend) | |
335 ;; clean up empty defun braces | |
336 (if (and c-auto-newline | |
337 (memq 'empty-defun-braces c-cleanup-list) | |
338 (eq last-command-char ?\}) | |
339 (c-intersect-lists '(defun-close class-close inline-close) | |
340 syntax) | |
341 (progn | |
342 (forward-char -1) | |
343 (skip-chars-backward " \t\n") | |
344 (eq (char-before) ?\{)) | |
345 ;; make sure matching open brace isn't in a comment | |
346 (not (c-in-literal))) | |
347 (delete-region (point) (1- here))) | |
348 ;; clean up brace-else-brace | |
349 (if (and c-auto-newline | |
350 (memq 'brace-else-brace c-cleanup-list) | |
351 (eq last-command-char ?\{) | |
352 (re-search-backward "}[ \t\n]*else[ \t\n]*{" nil t) | |
353 (progn | |
354 (setq mbeg (match-beginning 0) | |
355 mend (match-end 0)) | |
356 (= mend here)) | |
357 (not (c-in-literal))) | |
358 (progn | |
359 (delete-region mbeg mend) | |
360 (insert "} else {"))) | |
361 (goto-char (- (point-max) pos)) | |
362 ) | |
363 ;; does a newline go after the brace? | |
364 (if (memq 'after newlines) | |
365 (progn | |
366 (newline) | |
367 ;; update on c-state-cache | |
368 (let* ((bufpos (- (point) 2)) | |
369 (which (if (eq (char-after bufpos) ?{) 'open 'close)) | |
370 (c-state-cache (c-hack-state bufpos which c-state-cache))) | |
371 (c-indent-line)))) | |
372 ;; blink the paren | |
373 (and (eq last-command-char ?\}) | |
374 old-blink-paren | |
375 (save-excursion | |
376 (c-backward-syntactic-ws safepos) | |
377 (funcall old-blink-paren))) | |
378 )))) | |
24282 | 379 |
18720 | 380 (defun c-electric-slash (arg) |
381 "Insert a slash character. | |
19297
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
382 |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
383 Indent the line as a comment, if: |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
384 |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
385 1. The slash is second of a `//' line oriented comment introducing |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
386 token and we are on a comment-only-line, or |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
387 |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
388 2. The slash is part of a `*/' token that closes a block oriented |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
389 comment. |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
390 |
18720 | 391 If numeric ARG is supplied or point is inside a literal, indentation |
392 is inhibited." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
393 (interactive "*P") |
19297
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
394 (let* ((ch (char-before)) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
395 (indentp (and (not arg) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
396 (eq last-command-char ?/) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
397 (or (and (eq ch ?/) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
398 (not (c-in-literal))) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
399 (and (eq ch ?*) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
400 (c-in-literal))) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
401 )) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
402 ;; shut this up |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
403 (c-echo-syntactic-information-p nil)) |
18720 | 404 (self-insert-command (prefix-numeric-value arg)) |
405 (if indentp | |
406 (c-indent-line)))) | |
407 | |
408 (defun c-electric-star (arg) | |
409 "Insert a star character. | |
410 If the star is the second character of a C style comment introducing | |
411 construct, and we are on a comment-only-line, indent line as comment. | |
412 If numeric ARG is supplied or point is inside a literal, indentation | |
413 is inhibited." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
414 (interactive "*P") |
18720 | 415 (self-insert-command (prefix-numeric-value arg)) |
416 ;; if we are in a literal, or if arg is given do not re-indent the | |
417 ;; current line, unless this star introduces a comment-only line. | |
418 (if (and (not arg) | |
419 (memq (c-in-literal) '(c)) | |
420 (eq (char-before) ?*) | |
421 (save-excursion | |
422 (forward-char -1) | |
423 (skip-chars-backward "*") | |
424 (if (eq (char-before) ?/) | |
425 (forward-char -1)) | |
426 (skip-chars-backward " \t") | |
427 (bolp))) | |
428 ;; shut this up | |
429 (let (c-echo-syntactic-information-p) | |
430 (c-indent-line)) | |
431 )) | |
432 | |
433 (defun c-electric-semi&comma (arg) | |
434 "Insert a comma or semicolon. | |
435 When the auto-newline feature is turned on, as evidenced by the \"/a\" | |
436 or \"/ah\" string on the mode line, a newline might be inserted. See | |
437 the variable `c-hanging-semi&comma-criteria' for how newline insertion | |
438 is determined. | |
439 | |
440 When semicolon is inserted, the line is re-indented unless a numeric | |
441 arg is supplied, point is inside a literal, or there are | |
24282 | 442 non-whitespace characters on the line following the semicolon. |
443 | |
444 Based on the value of `c-cleanup-list', this function cleans up commas | |
445 following brace lists and semicolons following defuns." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
446 (interactive "*P") |
18720 | 447 (let* ((lim (c-most-enclosing-brace (c-parse-state))) |
448 (literal (c-in-literal lim)) | |
449 (here (point)) | |
450 ;; shut this up | |
451 (c-echo-syntactic-information-p nil)) | |
452 (if (or literal | |
453 arg | |
454 (not (looking-at "[ \t]*$"))) | |
455 (self-insert-command (prefix-numeric-value arg)) | |
456 ;; do some special stuff with the character | |
457 (self-insert-command (prefix-numeric-value arg)) | |
24282 | 458 ;; do all cleanups and newline insertions if c-auto-newline is |
459 ;; turned on | |
460 (if (not c-auto-newline) | |
461 (c-indent-line) | |
18720 | 462 ;; clean ups |
463 (let ((pos (- (point-max) (point)))) | |
464 (if (and (or (and | |
465 (eq last-command-char ?,) | |
466 (memq 'list-close-comma c-cleanup-list)) | |
467 (and | |
468 (eq last-command-char ?\;) | |
469 (memq 'defun-close-semi c-cleanup-list))) | |
470 (progn | |
471 (forward-char -1) | |
472 (skip-chars-backward " \t\n") | |
473 (eq (char-before) ?})) | |
474 ;; make sure matching open brace isn't in a comment | |
475 (not (c-in-literal lim))) | |
476 (delete-region (point) here)) | |
477 (goto-char (- (point-max) pos))) | |
478 ;; re-indent line | |
479 (c-indent-line) | |
480 ;; check to see if a newline should be added | |
481 (let ((criteria c-hanging-semi&comma-criteria) | |
482 answer add-newline-p) | |
483 (while criteria | |
484 (setq answer (funcall (car criteria))) | |
485 ;; only nil value means continue checking | |
486 (if (not answer) | |
487 (setq criteria (cdr criteria)) | |
488 (setq criteria nil) | |
489 ;; only 'stop specifically says do not add a newline | |
490 (setq add-newline-p (not (eq answer 'stop))) | |
491 )) | |
492 (if add-newline-p | |
493 (progn (newline) | |
494 (c-indent-line))) | |
495 ))))) | |
496 | |
497 (defun c-electric-colon (arg) | |
498 "Insert a colon. | |
499 | |
500 If the auto-newline feature is turned on, as evidenced by the \"/a\" | |
501 or \"/ah\" string on the mode line, newlines are inserted before and | |
502 after colons based on the value of `c-hanging-colons-alist'. | |
503 | |
504 Also, the line is re-indented unless a numeric ARG is supplied, there | |
505 are non-whitespace characters present on the line after the colon, or | |
506 the colon is inserted inside a literal. | |
507 | |
508 This function cleans up double colon scope operators based on the | |
509 value of `c-cleanup-list'." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
510 (interactive "*P") |
18720 | 511 (let* ((bod (c-point 'bod)) |
512 (literal (c-in-literal bod)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
513 syntax newlines is-scope-op |
18720 | 514 ;; shut this up |
515 (c-echo-syntactic-information-p nil)) | |
516 (if (or literal | |
517 arg | |
518 (not (looking-at "[ \t]*$"))) | |
519 (self-insert-command (prefix-numeric-value arg)) | |
520 ;; insert the colon, then do any specified cleanups | |
521 (self-insert-command (prefix-numeric-value arg)) | |
522 (let ((pos (- (point-max) (point))) | |
523 (here (point))) | |
524 (if (and c-auto-newline | |
525 (memq 'scope-operator c-cleanup-list) | |
526 (eq (char-before) ?:) | |
527 (progn | |
528 (forward-char -1) | |
529 (skip-chars-backward " \t\n") | |
530 (eq (char-before) ?:)) | |
531 (not (c-in-literal)) | |
532 (not (eq (char-after (- (point) 2)) ?:))) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
533 (progn |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
534 (delete-region (point) (1- here)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
535 (setq is-scope-op t))) |
18720 | 536 (goto-char (- (point-max) pos))) |
537 ;; lets do some special stuff with the colon character | |
538 (setq syntax (c-guess-basic-syntax) | |
539 ;; some language elements can only be determined by | |
540 ;; checking the following line. Lets first look for ones | |
541 ;; that can be found when looking on the line with the | |
542 ;; colon | |
543 newlines | |
544 (and c-auto-newline | |
545 (or (c-lookup-lists '(case-label label access-label) | |
546 syntax c-hanging-colons-alist) | |
547 (c-lookup-lists '(member-init-intro inher-intro) | |
24282 | 548 (let ((buffer-undo-list t)) |
549 (insert "\n") | |
550 (unwind-protect | |
551 (c-guess-basic-syntax) | |
552 (delete-char -1))) | |
18720 | 553 c-hanging-colons-alist)))) |
554 ;; indent the current line | |
555 (c-indent-line syntax) | |
556 ;; does a newline go before the colon? Watch out for already | |
557 ;; non-hung colons. However, we don't unhang them because that | |
558 ;; would be a cleanup (and anti-social). | |
559 (if (and (memq 'before newlines) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
560 (not is-scope-op) |
18720 | 561 (save-excursion |
562 (skip-chars-backward ": \t") | |
563 (not (bolp)))) | |
564 (let ((pos (- (point-max) (point)))) | |
565 (forward-char -1) | |
566 (newline) | |
567 (c-indent-line) | |
568 (goto-char (- (point-max) pos)))) | |
569 ;; does a newline go after the colon? | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
570 (if (and (memq 'after (cdr-safe newlines)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
571 (not is-scope-op)) |
18720 | 572 (progn |
573 (newline) | |
574 (c-indent-line))) | |
575 ))) | |
576 | |
577 (defun c-electric-lt-gt (arg) | |
578 "Insert a less-than, or greater-than character. | |
24282 | 579 The line will be re-indented if the character inserted is the second |
580 of a C++ style stream operator and the buffer is in C++ mode. | |
581 Exceptions are when a numeric argument is supplied, or point is inside | |
582 a literal, in which case the line will not be re-indented." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
583 (interactive "*P") |
18720 | 584 (let ((indentp (and (not arg) |
585 (eq (char-before) last-command-char) | |
586 (not (c-in-literal)))) | |
587 ;; shut this up | |
588 (c-echo-syntactic-information-p nil)) | |
589 (self-insert-command (prefix-numeric-value arg)) | |
590 (if indentp | |
591 (c-indent-line)))) | |
592 | |
24282 | 593 (defun c-electric-paren (arg) |
594 "Insert a parenthesis. | |
595 | |
596 If the auto-newline feature is turned on, as evidenced by the \"/a\" | |
597 or \"/ah\" string on the mode line, some newline cleanups are done if | |
598 appropriate; see the variable `c-cleanup-list'. | |
599 | |
600 Also, the line is re-indented unless a numeric ARG is supplied, there | |
601 are non-whitespace characters present on the line after the colon, or | |
602 the colon is inserted inside a literal." | |
603 (interactive "*P") | |
604 (let (;; shut this up | |
605 (c-echo-syntactic-information-p nil)) | |
606 (if (or arg | |
607 (not (looking-at "[ \t]*$")) | |
608 (c-in-literal (c-point 'bod))) | |
609 (self-insert-command (prefix-numeric-value arg)) | |
610 ;; do some special stuff with the character | |
611 (let* (;; We want to inhibit blinking the paren since this will | |
612 ;; be most disruptive. We'll blink it ourselves | |
613 ;; afterwards. | |
614 (old-blink-paren blink-paren-function) | |
615 blink-paren-function) | |
616 (self-insert-command (prefix-numeric-value arg)) | |
617 (c-indent-line) | |
618 (when c-auto-newline | |
619 ;; Do all appropriate clean ups | |
620 (let ((here (point)) | |
621 (pos (- (point-max) (point))) | |
622 mbeg mend) | |
623 ;; clean up brace-elseif-brace | |
624 (if (and (memq 'brace-elseif-brace c-cleanup-list) | |
625 (eq last-command-char ?\() | |
626 (re-search-backward "}[ \t\n]*else[ \t\n]+if[ \t\n]*(" | |
627 nil t) | |
628 (save-excursion | |
629 (setq mbeg (match-beginning 0) | |
630 mend (match-end 0)) | |
631 (= mend here)) | |
632 (not (c-in-literal))) | |
633 (progn | |
634 (delete-region mbeg mend) | |
635 (insert "} else if ("))) | |
636 ;; clean up brace-catch-brace | |
637 (if (and (memq 'brace-catch-brace c-cleanup-list) | |
638 (eq last-command-char ?\() | |
639 (re-search-backward "}[ \t\n]*catch[ \t\n]*(" nil t) | |
640 (save-excursion | |
641 (setq mbeg (match-beginning 0) | |
642 mend (match-end 0)) | |
643 (= mend here)) | |
644 (not (c-in-literal))) | |
645 (progn | |
646 (delete-region mbeg mend) | |
647 (insert "} catch ("))) | |
648 (goto-char (- (point-max) pos)) | |
649 )) | |
650 (funcall old-blink-paren))))) | |
651 | |
18720 | 652 |
653 | |
654 ;; better movement routines for ThisStyleOfVariablesCommonInCPlusPlus | |
655 ;; originally contributed by Terry_Glanfield.Southern@rxuk.xerox.com | |
656 (defun c-forward-into-nomenclature (&optional arg) | |
657 "Move forward to end of a nomenclature section or word. | |
658 With arg, to it arg times." | |
659 (interactive "p") | |
660 (let ((case-fold-search nil)) | |
661 (if (> arg 0) | |
662 (re-search-forward "\\W*\\([A-Z]*[a-z0-9]*\\)" (point-max) t arg) | |
663 (while (and (< arg 0) | |
664 (re-search-backward | |
665 "\\(\\(\\W\\|[a-z0-9]\\)[A-Z]+\\|\\W\\w+\\)" | |
666 (point-min) 0)) | |
667 (forward-char 1) | |
668 (setq arg (1+ arg))))) | |
669 (c-keep-region-active)) | |
670 | |
671 (defun c-backward-into-nomenclature (&optional arg) | |
672 "Move backward to beginning of a nomenclature section or word. | |
673 With optional ARG, move that many times. If ARG is negative, move | |
674 forward." | |
675 (interactive "p") | |
676 (c-forward-into-nomenclature (- arg)) | |
677 (c-keep-region-active)) | |
678 | |
679 (defun c-scope-operator () | |
680 "Insert a double colon scope operator at point. | |
681 No indentation or other \"electric\" behavior is performed." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
682 (interactive "*") |
18720 | 683 (insert "::")) |
684 | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
685 (defun c-beginning-of-defun (&optional arg) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
686 "Move backward to the beginning of a defun. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
687 With argument, do it that many times. Negative arg -N |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
688 means move forward to Nth following beginning of defun. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
689 Returns t unless search stops due to beginning or end of buffer. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
690 |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
691 Unlike the built-in `beginning-of-defun' this tries to be smarter |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
692 about finding the char with open-parenthesis syntax that starts the |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
693 defun." |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
694 (interactive "p") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
695 (if (< arg 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
696 (c-end-of-defun (- arg)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
697 (while (> arg 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
698 (let ((state (nreverse (c-parse-state))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
699 prevbod bod) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
700 (while (and state (not bod)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
701 (setq bod (car state) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
702 state (cdr state)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
703 (if (consp bod) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
704 (setq prevbod (car bod) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
705 bod nil))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
706 (cond |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
707 (bod (goto-char bod)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
708 (prevbod (goto-char prevbod)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
709 (t (goto-char (c-point 'bod))))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
710 (setq arg (1- arg)))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
711 (c-keep-region-active)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
712 |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
713 (defun c-end-of-defun (&optional arg) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
714 "Move forward to next end of defun. With argument, do it that many times. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
715 Negative argument -N means move back to Nth preceding end of defun. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
716 |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
717 An end of a defun occurs right after the close-parenthesis that matches |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
718 the open-parenthesis that starts a defun; see `beginning-of-defun'." |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
719 (interactive "p") |
24282 | 720 (if (not arg) |
721 (setq arg 1)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
722 (if (< arg 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
723 (c-beginning-of-defun (- arg)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
724 (while (> arg 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
725 ;; skip down into the next defun-block |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
726 (while (and (c-safe (down-list 1) t) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
727 (not (eq (char-before) ?{))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
728 (forward-char -1) |
24282 | 729 (c-forward-sexp)) |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
730 (c-beginning-of-defun 1) |
24282 | 731 (c-forward-sexp 1) |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
732 (setq arg (1- arg))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
733 (forward-line 1)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
734 (c-keep-region-active)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
735 |
18720 | 736 |
737 (defun c-beginning-of-statement (&optional count lim sentence-flag) | |
738 "Go to the beginning of the innermost C statement. | |
739 With prefix arg, go back N - 1 statements. If already at the | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
740 beginning of a statement then go to the beginning of the closest |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
741 preceding one, moving into nested blocks if necessary (use |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
742 \\[backward-sexp] to skip over a block). If within a comment, or next |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
743 to a comment (only whitespace between), move by sentences instead of |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
744 statements. |
18720 | 745 |
746 When called from a program, this function takes 3 optional args: the | |
747 repetition count, a buffer position limit which is the farthest back | |
748 to search, and a flag saying whether to do sentence motion when in a | |
749 comment." | |
750 (interactive (list (prefix-numeric-value current-prefix-arg) | |
751 nil t)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
752 (let* ((count (or count 1)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
753 here |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
754 (range (c-collect-line-comments (c-literal-limits lim)))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
755 (while (and (/= count 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
756 (or (not lim) (> (point) lim))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
757 (setq here (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
758 (if (and (not range) sentence-flag) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
759 (save-excursion |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
760 ;; Find the comment next to point if we're not in one. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
761 (if (> count 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
762 ;; Finding a comment backwards is a bit cumbersome |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
763 ;; because `forward-comment' regards every newline as |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
764 ;; a comment when searching backwards (Emacs 19.34). |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
765 (while (and (progn (skip-chars-backward " \t") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
766 (setq range (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
767 (setq range (if (forward-comment -1) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
768 (cons (point) range) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
769 nil))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
770 (= (char-after) ?\n))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
771 (skip-chars-forward " \t\n") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
772 (setq range (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
773 (setq range (if (forward-comment 1) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
774 (cons range (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
775 nil))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
776 (setq range (c-collect-line-comments range)))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
777 (if (and (< count 0) (= here (point-max))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
778 ;; Special case because eob might be in a literal. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
779 (setq range nil)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
780 (if range |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
781 (if (and sentence-flag |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
782 (/= (char-syntax (char-after (car range))) ?\")) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
783 (progn |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
784 ;; move by sentence, but not past the limit of the literal |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
785 (save-restriction |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
786 (narrow-to-region (save-excursion |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
787 (goto-char (car range)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
788 (looking-at comment-start-skip) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
789 (goto-char (match-end 0)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
790 (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
791 (save-excursion |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
792 (goto-char (cdr range)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
793 (if (save-excursion |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
794 (goto-char (car range)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
795 (looking-at "/\\*")) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
796 (backward-char 2)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
797 (skip-chars-backward " \t\n") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
798 (point))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
799 (c-safe (forward-sentence (if (> count 0) -1 1)))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
800 ;; See if we should escape the literal. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
801 (if (> count 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
802 (if (< (point) here) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
803 (setq count (1- count)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
804 (goto-char (car range)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
805 (setq range nil)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
806 (if (> (point) here) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
807 (setq count (1+ count)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
808 (goto-char (cdr range)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
809 (setq range nil)))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
810 (goto-char (if (> count 0) (car range) (cdr range))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
811 (setq range nil)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
812 ;; Below we do approximately the same as |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
813 ;; c-beginning-of-statement-1 and c-end-of-statement-1 and |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
814 ;; perhaps they should be changed, but that'd likely break a |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
815 ;; lot in cc-engine. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
816 (goto-char here) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
817 (if (> count 0) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
818 (if (condition-case nil |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
819 ;; Stop before `{' and after `;', `{', `}' and |
24282 | 820 ;; `};' when not followed by `}' or `)', but on |
821 ;; the other side of the syntactic ws. Also stop | |
822 ;; before `}', but only to catch comments. Move | |
823 ;; by sexps and move into parens. | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
824 (catch 'done |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
825 (let (last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
826 (while t |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
827 (setq last (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
828 (if (and (looking-at "[{}]") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
829 (/= here last)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
830 (throw 'done (= (char-after) ?{))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
831 (c-backward-syntactic-ws) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
832 (cond ((bobp) ; Must handle bob specially. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
833 (if (= here last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
834 (if (= last (point-min)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
835 (throw 'done t) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
836 (goto-char last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
837 (throw 'done nil)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
838 (goto-char last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
839 (throw 'done t))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
840 ((progn (backward-char) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
841 (looking-at "[;{}]")) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
842 (if (or (= here last) |
24282 | 843 (memq (char-after last) '(?\) ?}))) |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
844 (if (and (= (char-before) ?}) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
845 (= (char-after) ?\;)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
846 (backward-char)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
847 (goto-char last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
848 (throw 'done t))) |
24282 | 849 ((= (char-syntax (char-after)) ?\") |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
850 (forward-char) |
24282 | 851 (c-backward-sexp)) |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
852 )))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
853 (error |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
854 (goto-char (point-min)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
855 t)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
856 (setq count (1- count))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
857 (if (condition-case nil |
24282 | 858 ;; Stop before `{' and `}', but on the other side of |
859 ;; the syntactic ws, and after `;', `}' and `};'. | |
860 ;; Only stop before `{' if at top level or inside | |
861 ;; braces, though. Also stop after `{', but only to | |
862 ;; catch comments. Move by sexps and move into | |
863 ;; parens. | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
864 (catch 'done |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
865 (let (last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
866 (while t |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
867 (setq last (point)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
868 (c-forward-syntactic-ws) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
869 (cond ((= (char-after) ?{) |
24282 | 870 (if (or (= here last) |
871 (save-excursion | |
872 (and (c-safe (progn (up-list -1) t)) | |
873 (/= (char-after) ?{)))) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
874 (progn (forward-char) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
875 (throw 'done nil)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
876 (goto-char last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
877 (throw 'done t))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
878 ((and (= (char-after) ?}) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
879 (/= here last)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
880 (goto-char last) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
881 (throw 'done t)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
882 ((looking-at ";\\|};?") |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
883 (goto-char (match-end 0)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
884 (throw 'done t)) |
24282 | 885 ((= (char-syntax (char-after)) ?\") |
886 (c-forward-sexp)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
887 (t |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
888 (forward-char)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
889 )))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
890 (error |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
891 (goto-char (point-max)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
892 t)) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
893 (setq count (1+ count))))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
894 ;; If we haven't moved we're near a buffer limit. |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
895 (when (= (point) here) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
896 (goto-char (if (> count 0) (point-min) (point-max))) |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
897 (setq count 0))) |
18720 | 898 ;; its possible we've been left up-buf of lim |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
899 (if lim (goto-char (max (point) lim)))) |
18720 | 900 (c-keep-region-active)) |
901 | |
902 (defun c-end-of-statement (&optional count lim sentence-flag) | |
903 "Go to the end of the innermost C statement. | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
904 With prefix arg, go forward N - 1 statements. Move forward to the end |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
905 of the next statement if already at end, and move into nested blocks |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
906 \(use \\[forward-sexp] to skip over a block). If within a comment, or |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
907 next to a comment (only whitespace between), move by sentences instead |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
908 of statements. |
18720 | 909 |
910 When called from a program, this function takes 3 optional args: the | |
911 repetition count, a buffer position limit which is the farthest back | |
912 to search, and a flag saying whether to do sentence motion when in a | |
913 comment." | |
914 (interactive (list (prefix-numeric-value current-prefix-arg) | |
915 nil t)) | |
916 (c-beginning-of-statement (- (or count 1)) lim sentence-flag) | |
917 (c-keep-region-active)) | |
918 | |
919 | |
920 ;; set up electric character functions to work with pending-del, | |
921 ;; (a.k.a. delsel) mode. All symbols get the t value except | |
18843
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
922 ;; the functions which delete, which gets 'supersede. |
18720 | 923 (mapcar |
924 (function | |
925 (lambda (sym) | |
926 (put sym 'delete-selection t) ; for delsel (Emacs) | |
927 (put sym 'pending-delete t))) ; for pending-del (XEmacs) | |
928 '(c-electric-pound | |
929 c-electric-brace | |
930 c-electric-slash | |
931 c-electric-star | |
932 c-electric-semi&comma | |
933 c-electric-lt-gt | |
24282 | 934 c-electric-colon |
935 c-electric-paren)) | |
18843
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
936 (put 'c-electric-delete 'delete-selection 'supersede) ; delsel |
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
937 (put 'c-electric-delete 'pending-delete 'supersede) ; pending-del |
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
938 (put 'c-electric-backspace 'delete-selection 'supersede) ; delsel |
6e04c0670f55
Require cc-defs for the c-add-syntax macro.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
939 (put 'c-electric-backspace 'pending-delete 'supersede) ; pending-del |
18720 | 940 |
941 | |
942 ;; This is used by indent-for-comment to decide how much to indent a | |
943 ;; comment in C code based on its context. | |
944 (defun c-comment-indent () | |
945 (if (looking-at (concat "^\\(" c-comment-start-regexp "\\)")) | |
946 0 ;Existing comment at bol stays there. | |
947 (let ((opoint (point)) | |
948 placeholder) | |
949 (save-excursion | |
950 (beginning-of-line) | |
951 (cond | |
952 ;; CASE 1: A comment following a solitary close-brace should | |
953 ;; have only one space. | |
954 ((looking-at (concat "[ \t]*}[ \t]*\\($\\|" | |
955 c-comment-start-regexp | |
956 "\\)")) | |
957 (search-forward "}") | |
958 (1+ (current-column))) | |
959 ;; CASE 2: 2 spaces after #endif | |
960 ((or (looking-at "^#[ \t]*endif[ \t]*") | |
961 (looking-at "^#[ \t]*else[ \t]*")) | |
962 7) | |
24282 | 963 ;; CASE 3: when c-indent-comments-syntactically-p is t, |
964 ;; calculate the offset according to c-offsets-alist. | |
965 ;; E.g. identical to hitting TAB. | |
18720 | 966 ((and c-indent-comments-syntactically-p |
967 (save-excursion | |
968 (skip-chars-forward " \t") | |
24282 | 969 (or (looking-at c-comment-start-regexp) |
18720 | 970 (eolp)))) |
971 (let ((syntax (c-guess-basic-syntax))) | |
972 ;; BOGOSITY ALERT: if we're looking at the eol, its | |
973 ;; because indent-for-comment hasn't put the comment-start | |
974 ;; in the buffer yet. this will screw up the syntactic | |
975 ;; analysis so we kludge in the necessary info. Another | |
976 ;; kludge is that if we're at the bol, then we really want | |
977 ;; to ignore any anchoring as specified by | |
978 ;; c-comment-only-line-offset since it doesn't apply here. | |
979 (if (save-excursion | |
980 (beginning-of-line) | |
981 (skip-chars-forward " \t") | |
982 (eolp)) | |
983 (c-add-syntax 'comment-intro)) | |
984 (let ((c-comment-only-line-offset | |
985 (if (consp c-comment-only-line-offset) | |
986 c-comment-only-line-offset | |
987 (cons c-comment-only-line-offset | |
988 c-comment-only-line-offset)))) | |
989 (apply '+ (mapcar 'c-get-offset syntax))))) | |
990 ;; CASE 4: use comment-column if previous line is a | |
991 ;; comment-only line indented to the left of comment-column | |
992 ((save-excursion | |
993 (beginning-of-line) | |
994 (and (not (bobp)) | |
995 (forward-line -1)) | |
996 (skip-chars-forward " \t") | |
997 (prog1 | |
998 (looking-at c-comment-start-regexp) | |
999 (setq placeholder (point)))) | |
1000 (goto-char placeholder) | |
1001 (if (< (current-column) comment-column) | |
1002 comment-column | |
1003 (current-column))) | |
1004 ;; CASE 5: If comment-column is 0, and nothing but space | |
1005 ;; before the comment, align it at 0 rather than 1. | |
1006 ((progn | |
1007 (goto-char opoint) | |
1008 (skip-chars-backward " \t") | |
1009 (and (= comment-column 0) (bolp))) | |
1010 0) | |
1011 ;; CASE 6: indent at comment column except leave at least one | |
1012 ;; space. | |
1013 (t (max (1+ (current-column)) | |
1014 comment-column)) | |
1015 ))))) | |
1016 | |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1017 |
19297
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1018 ;; for proposed new variable comment-line-break-function |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1019 (defun c-comment-line-break-function (&optional soft) |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1020 ;; we currently don't do anything with soft line breaks |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1021 (let ((literal (c-in-literal)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1022 at-comment-col) |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1023 (cond |
24282 | 1024 ((eq literal 'string) |
1025 (insert ?\n)) | |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1026 ((or (not c-comment-continuation-stars) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1027 (not literal)) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1028 (indent-new-comment-line soft)) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1029 (t (let ((here (point)) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1030 (leader c-comment-continuation-stars)) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1031 (back-to-indentation) |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1032 ;; comment could be hanging |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1033 (if (not (c-in-literal)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1034 (progn |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1035 (forward-line 1) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1036 (forward-comment -1) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1037 (setq at-comment-col (= (current-column) comment-column)))) |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1038 ;; are we looking at a block or lines style comment? |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1039 (if (and (looking-at (concat "\\(" c-comment-start-regexp |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1040 "\\)[ \t]+")) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1041 (string-equal (match-string 1) "//")) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1042 ;; line style |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1043 (setq leader (match-string 0))) |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1044 (goto-char here) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1045 (delete-region (progn (skip-chars-backward " \t") (point)) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1046 (progn (skip-chars-forward " \t") (point))) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1047 (newline) |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1048 ;; to avoid having an anchored comment that c-indent-line will |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1049 ;; trip up on |
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1050 (insert " " leader) |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1051 (if at-comment-col |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1052 (indent-for-comment)) |
19804
37e25ff5a7f1
(c-beginning-of-statement): Fixes in sentence movement to properly
Richard M. Stallman <rms@gnu.org>
parents:
19378
diff
changeset
|
1053 (c-indent-line)))))) |
19297
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1054 |
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1055 ;; advice for indent-new-comment-line for older Emacsen |
24282 | 1056 (or (boundp 'comment-line-break-function) |
1057 (defadvice indent-new-comment-line (around c-line-break-advice | |
1058 activate preactivate) | |
1059 "Calls c-comment-line-break-function if in a comment in CC Mode." | |
1060 (if (or (not c-buffer-is-cc-mode) | |
1061 (not (c-in-literal)) | |
1062 (not c-comment-continuation-stars)) | |
1063 ad-do-it | |
1064 (c-comment-line-break-function (ad-get-arg 0))))) | |
19297
1982f8488449
(indent-new-comment-line): Add advice for older Emacs versions if they
Richard M. Stallman <rms@gnu.org>
parents:
19252
diff
changeset
|
1065 |
18720 | 1066 ;; used by outline-minor-mode |
1067 (defun c-outline-level () | |
24447 | 1068 ;; This so that `current-column' DTRT in otherwise-hidden text. |
1069 (let (buffer-invisibility-spec) | |
1070 (save-excursion | |
1071 (skip-chars-forward "\t ") | |
1072 (current-column)))) | |
18720 | 1073 |
1074 | |
1075 (defun c-up-conditional (count) | |
1076 "Move back to the containing preprocessor conditional, leaving mark behind. | |
1077 A prefix argument acts as a repeat count. With a negative argument, | |
1078 move forward to the end of the containing preprocessor conditional. | |
1079 When going backwards, `#elif' is treated like `#else' followed by | |
1080 `#if'. When going forwards, `#elif' is ignored." | |
1081 (interactive "p") | |
1082 (c-forward-conditional (- count) t) | |
1083 (c-keep-region-active)) | |
1084 | |
1085 (defun c-backward-conditional (count &optional up-flag) | |
1086 "Move back across a preprocessor conditional, leaving mark behind. | |
1087 A prefix argument acts as a repeat count. With a negative argument, | |
1088 move forward across a preprocessor conditional." | |
1089 (interactive "p") | |
1090 (c-forward-conditional (- count) up-flag) | |
1091 (c-keep-region-active)) | |
1092 | |
1093 (defun c-forward-conditional (count &optional up-flag) | |
1094 "Move forward across a preprocessor conditional, leaving mark behind. | |
1095 A prefix argument acts as a repeat count. With a negative argument, | |
1096 move backward across a preprocessor conditional." | |
1097 (interactive "p") | |
1098 (let* ((forward (> count 0)) | |
1099 (increment (if forward -1 1)) | |
1100 (search-function (if forward 're-search-forward 're-search-backward)) | |
1101 (new)) | |
1102 (save-excursion | |
1103 (while (/= count 0) | |
1104 (let ((depth (if up-flag 0 -1)) found) | |
1105 (save-excursion | |
1106 ;; Find the "next" significant line in the proper direction. | |
1107 (while (and (not found) | |
1108 ;; Rather than searching for a # sign that | |
1109 ;; comes at the beginning of a line aside from | |
1110 ;; whitespace, search first for a string | |
1111 ;; starting with # sign. Then verify what | |
1112 ;; precedes it. This is faster on account of | |
1113 ;; the fastmap feature of the regexp matcher. | |
1114 (funcall search-function | |
1115 "#[ \t]*\\(if\\|elif\\|endif\\)" | |
1116 nil t)) | |
1117 (beginning-of-line) | |
1118 ;; Now verify it is really a preproc line. | |
1119 (if (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)") | |
1120 (let ((prev depth)) | |
1121 ;; Update depth according to what we found. | |
1122 (beginning-of-line) | |
1123 (cond ((looking-at "[ \t]*#[ \t]*endif") | |
1124 (setq depth (+ depth increment))) | |
1125 ((looking-at "[ \t]*#[ \t]*elif") | |
1126 (if (and forward (= depth 0)) | |
1127 (setq found (point)))) | |
1128 (t (setq depth (- depth increment)))) | |
1129 ;; If we are trying to move across, and we find an | |
1130 ;; end before we find a beginning, get an error. | |
1131 (if (and (< prev 0) (< depth prev)) | |
1132 (error (if forward | |
1133 "No following conditional at this level" | |
1134 "No previous conditional at this level"))) | |
1135 ;; When searching forward, start from next line so | |
1136 ;; that we don't find the same line again. | |
1137 (if forward (forward-line 1)) | |
1138 ;; If this line exits a level of conditional, exit | |
1139 ;; inner loop. | |
1140 (if (< depth 0) | |
1141 (setq found (point)))) | |
1142 ;; else | |
1143 (if forward (forward-line 1)) | |
1144 ))) | |
1145 (or found | |
1146 (error "No containing preprocessor conditional")) | |
1147 (goto-char (setq new found))) | |
1148 (setq count (+ count increment)))) | |
1149 (push-mark) | |
1150 (goto-char new)) | |
1151 (c-keep-region-active)) | |
1152 | |
1153 | |
1154 ;; commands to indent lines, regions, defuns, and expressions | |
1155 (defun c-indent-command (&optional whole-exp) | |
1156 "Indent current line as C code, and/or insert some whitespace. | |
1157 | |
1158 If `c-tab-always-indent' is t, always just indent the current line. | |
1159 If nil, indent the current line only if point is at the left margin or | |
1160 in the line's indentation; otherwise insert some whitespace[*]. If | |
1161 other than nil or t, then some whitespace[*] is inserted only within | |
1162 literals (comments and strings) and inside preprocessor directives, | |
1163 but the line is always reindented. | |
1164 | |
1165 A numeric argument, regardless of its value, means indent rigidly all | |
1166 the lines of the expression starting after point so that this line | |
1167 becomes properly indented. The relative indentation among the lines | |
24529 | 1168 of the expression is preserved. |
18720 | 1169 |
1170 [*] The amount and kind of whitespace inserted is controlled by the | |
1171 variable `c-insert-tab-function', which is called to do the actual | |
1172 insertion of whitespace. Normally the function in this variable | |
1173 just inserts a tab character, or the equivalent number of spaces, | |
1174 depending on the variable `indent-tabs-mode'." | |
1175 | |
24282 | 1176 (interactive "P") |
18720 | 1177 (let ((bod (c-point 'bod))) |
1178 (if whole-exp | |
1179 ;; If arg, always indent this line as C | |
1180 ;; and shift remaining lines of expression the same amount. | |
1181 (let ((shift-amt (c-indent-line)) | |
1182 beg end) | |
1183 (save-excursion | |
1184 (if (eq c-tab-always-indent t) | |
1185 (beginning-of-line)) | |
1186 (setq beg (point)) | |
24282 | 1187 (c-forward-sexp 1) |
18720 | 1188 (setq end (point)) |
1189 (goto-char beg) | |
1190 (forward-line 1) | |
1191 (setq beg (point))) | |
1192 (if (> end beg) | |
1193 (indent-code-rigidly beg end (- shift-amt) "#"))) | |
1194 ;; No arg supplied, use c-tab-always-indent to determine | |
1195 ;; behavior | |
1196 (cond | |
1197 ;; CASE 1: indent when at column zero or in lines indentation, | |
1198 ;; otherwise insert a tab | |
1199 ((not c-tab-always-indent) | |
1200 (if (save-excursion | |
1201 (skip-chars-backward " \t") | |
1202 (not (bolp))) | |
1203 (funcall c-insert-tab-function) | |
1204 (c-indent-line))) | |
1205 ;; CASE 2: just indent the line | |
1206 ((eq c-tab-always-indent t) | |
1207 (c-indent-line)) | |
1208 ;; CASE 3: if in a literal, insert a tab, but always indent the | |
1209 ;; line | |
1210 (t | |
1211 (if (c-in-literal bod) | |
1212 (funcall c-insert-tab-function)) | |
1213 (c-indent-line) | |
1214 ))))) | |
1215 | |
1216 (defun c-indent-exp (&optional shutup-p) | |
1217 "Indent each line in balanced expression following point. | |
1218 Optional SHUTUP-P if non-nil, inhibits message printing and error checking." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1219 (interactive "*P") |
18720 | 1220 (let ((here (point)) |
1221 end progress-p) | |
1222 (unwind-protect | |
1223 (let ((c-echo-syntactic-information-p nil) ;keep quiet for speed | |
1224 (start (progn | |
1225 ;; try to be smarter about finding the range of | |
1226 ;; lines to indent. skip all following | |
1227 ;; whitespace. failing that, try to find any | |
1228 ;; opening brace on the current line | |
1229 (skip-chars-forward " \t\n") | |
1230 (if (memq (char-after) '(?\( ?\[ ?\{)) | |
1231 (point) | |
1232 (let ((state (parse-partial-sexp (point) | |
1233 (c-point 'eol)))) | |
1234 (and (nth 1 state) | |
1235 (goto-char (nth 1 state)) | |
1236 (memq (char-after) '(?\( ?\[ ?\{)) | |
1237 (point))))))) | |
1238 ;; find balanced expression end | |
24282 | 1239 (setq end (and (c-safe (progn (c-forward-sexp 1) t)) |
18720 | 1240 (point-marker))) |
1241 ;; sanity check | |
1242 (and (not start) | |
1243 (not shutup-p) | |
1244 (error "Cannot find start of balanced expression to indent.")) | |
1245 (and (not end) | |
1246 (not shutup-p) | |
1247 (error "Cannot find end of balanced expression to indent.")) | |
1248 (c-progress-init start end 'c-indent-exp) | |
1249 (setq progress-p t) | |
1250 (goto-char start) | |
1251 (beginning-of-line) | |
1252 (while (< (point) end) | |
1253 (if (not (looking-at "[ \t]*$")) | |
1254 (c-indent-line)) | |
1255 (c-progress-update) | |
1256 (forward-line 1))) | |
1257 ;; make sure marker is deleted | |
1258 (and end | |
1259 (set-marker end nil)) | |
1260 (and progress-p | |
1261 (c-progress-fini 'c-indent-exp)) | |
1262 (goto-char here)))) | |
1263 | |
1264 (defun c-indent-defun () | |
1265 "Re-indents the current top-level function def, struct or class declaration." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1266 (interactive "*") |
18720 | 1267 (let ((here (point-marker)) |
1268 (c-echo-syntactic-information-p nil) | |
1269 (brace (c-least-enclosing-brace (c-parse-state)))) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1270 (goto-char (or brace (c-point 'bod))) |
18720 | 1271 ;; if we're sitting at b-o-b, it might be because there was no |
1272 ;; least enclosing brace and we were sitting on the defun's open | |
1273 ;; brace. | |
1274 (if (and (bobp) (not (eq (char-after) ?\{))) | |
1275 (goto-char here)) | |
1276 ;; if defun-prompt-regexp is non-nil, b-o-d might not leave us at | |
1277 ;; the open brace. I consider this an Emacs bug. | |
1278 (and (boundp 'defun-prompt-regexp) | |
1279 defun-prompt-regexp | |
1280 (looking-at defun-prompt-regexp) | |
1281 (goto-char (match-end 0))) | |
1282 ;; catch all errors in c-indent-exp so we can 1. give more | |
1283 ;; meaningful error message, and 2. restore point | |
1284 (unwind-protect | |
1285 (c-indent-exp) | |
1286 (goto-char here) | |
1287 (set-marker here nil)))) | |
1288 | |
1289 (defun c-indent-region (start end) | |
1290 ;; Indent every line whose first char is between START and END inclusive. | |
1291 (save-excursion | |
1292 (goto-char start) | |
1293 ;; Advance to first nonblank line. | |
1294 (skip-chars-forward " \t\n") | |
1295 (beginning-of-line) | |
1296 (let (endmark) | |
1297 (unwind-protect | |
1298 (let ((c-tab-always-indent t) | |
1299 ;; shut up any echo msgs on indiv lines | |
1300 (c-echo-syntactic-information-p nil) | |
1301 fence) | |
1302 (c-progress-init start end 'c-indent-region) | |
1303 (setq endmark (copy-marker end)) | |
1304 (while (and (bolp) | |
1305 (not (eobp)) | |
1306 (< (point) endmark)) | |
1307 ;; update progress | |
1308 (c-progress-update) | |
1309 ;; Indent one line as with TAB. | |
1310 (let (nextline sexpend sexpbeg) | |
1311 ;; skip blank lines | |
1312 (skip-chars-forward " \t\n") | |
1313 (beginning-of-line) | |
1314 ;; indent the current line | |
1315 (c-indent-line) | |
1316 (setq fence (point)) | |
1317 (if (save-excursion | |
1318 (beginning-of-line) | |
1319 (looking-at "[ \t]*#")) | |
1320 (forward-line 1) | |
1321 (save-excursion | |
1322 ;; Find beginning of following line. | |
1323 (setq nextline (c-point 'bonl)) | |
1324 ;; Find first beginning-of-sexp for sexp extending past | |
1325 ;; this line. | |
1326 (beginning-of-line) | |
1327 (while (< (point) nextline) | |
1328 (condition-case nil | |
1329 (progn | |
24282 | 1330 (c-forward-sexp 1) |
18720 | 1331 (setq sexpend (point))) |
1332 (error (setq sexpend nil) | |
1333 (goto-char nextline))) | |
1334 (c-forward-syntactic-ws)) | |
1335 (if sexpend | |
24282 | 1336 (progn |
18720 | 1337 ;; make sure the sexp we found really starts on the |
1338 ;; current line and extends past it | |
1339 (goto-char sexpend) | |
1340 (setq sexpend (point-marker)) | |
24282 | 1341 (c-safe (c-backward-sexp 1)) |
18720 | 1342 (setq sexpbeg (point)))) |
1343 (if (and sexpbeg (< sexpbeg fence)) | |
1344 (setq sexpbeg fence))) | |
1345 ;; check to see if the next line starts a | |
1346 ;; comment-only line | |
1347 (save-excursion | |
1348 (forward-line 1) | |
1349 (skip-chars-forward " \t") | |
1350 (if (looking-at c-comment-start-regexp) | |
1351 (setq sexpbeg (c-point 'bol)))) | |
1352 ;; If that sexp ends within the region, indent it all at | |
1353 ;; once, fast. | |
1354 (condition-case nil | |
1355 (if (and sexpend | |
1356 (> sexpend nextline) | |
1357 (<= sexpend endmark)) | |
1358 (progn | |
1359 (goto-char sexpbeg) | |
1360 (c-indent-exp 'shutup) | |
1361 (c-progress-update) | |
1362 (goto-char sexpend))) | |
1363 (error | |
1364 (goto-char sexpbeg) | |
1365 (c-indent-line))) | |
1366 ;; Move to following line and try again. | |
1367 (and sexpend | |
1368 (markerp sexpend) | |
1369 (set-marker sexpend nil)) | |
1370 (forward-line 1) | |
1371 (setq fence (point)))))) | |
1372 (set-marker endmark nil) | |
1373 (c-progress-fini 'c-indent-region) | |
1374 (c-echo-parsing-error) | |
1375 )))) | |
1376 | |
1377 (defun c-mark-function () | |
24282 | 1378 "Put mark at end of current top-level defun, point at beginning." |
18720 | 1379 (interactive) |
1380 (let ((here (point)) | |
24282 | 1381 (eod (c-point 'eod)) |
1382 (state (c-parse-state))) | |
1383 ;; Are we sitting at the top level, someplace between either the | |
1384 ;; beginning of buffer, or the nearest preceding defun? If so, | |
1385 ;; try first to figure out whether we're sitting on the | |
1386 ;; introduction to a top-level defun, in which case we want to | |
1387 ;; mark the entire defun we're sitting on. | |
1388 ;; | |
1389 ;; If we're sitting on anything else at the top-level, we want to | |
1390 ;; just mark the statement that we're on | |
1391 (if (or (and (consp (car state)) | |
1392 (= (length state) 1)) | |
1393 (null state)) | |
1394 ;; Are we in the whitespace after the nearest preceding defun? | |
1395 (if (and state | |
1396 (looking-at "[ \t]*$") | |
1397 (= (save-excursion | |
1398 (c-backward-syntactic-ws) | |
1399 (skip-chars-backward ";") | |
1400 (point)) | |
1401 (cdar state))) | |
1402 (progn | |
1403 (setq eod (point)) | |
1404 (goto-char (caar state)) | |
1405 (c-beginning-of-statement-1)) | |
1406 (if (= ?{ (save-excursion | |
1407 (c-end-of-statement-1) | |
1408 (char-before))) | |
1409 ;; We must be in a defuns's introduction | |
1410 (progn | |
1411 (c-end-of-statement-1) | |
1412 (skip-chars-backward "{") | |
1413 (c-beginning-of-statement-1) | |
1414 (c-forward-syntactic-ws)) | |
1415 ;; Just mark the statement | |
1416 (c-end-of-statement-1) | |
1417 (forward-line 1) | |
1418 (setq eod (point)) | |
1419 (c-beginning-of-statement-1))) | |
1420 ;; We are inside some enclosing brace structure, so we first | |
1421 ;; need to find our way to the least enclosing brace. Then, in | |
1422 ;; both cases, we to mark the region from the beginning of the | |
1423 ;; current statement, until the end of the next following defun | |
1424 (while (and state) | |
1425 (or (consp (car state)) | |
1426 (goto-char (car state))) | |
1427 (setq state (cdr state))) | |
1428 (c-beginning-of-statement-1)) | |
18720 | 1429 (push-mark here) |
1430 (push-mark eod nil t))) | |
1431 | |
24282 | 1432 (defun c-indent-line-or-region () |
1433 "When the region is active, indent it. Otherwise indent the current line." | |
1434 ;; Emacs has a variable called mark-active, XEmacs uses region-active-p | |
1435 (interactive) | |
1436 (if (c-region-is-active-p) | |
1437 (c-indent-region (region-beginning) (region-end)) | |
1438 (c-indent-command))) | |
1439 | |
18720 | 1440 |
1441 ;; for progress reporting | |
1442 (defvar c-progress-info nil) | |
1443 | |
1444 (defun c-progress-init (start end context) | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1445 (cond |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1446 ;; Be silent |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1447 ((not c-progress-interval)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1448 ;; Start the progress update messages. If this Emacs doesn't have |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1449 ;; a built-in timer, just be dumb about it. |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1450 ((not (fboundp 'current-time)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1451 (message "indenting region... (this may take a while)")) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1452 ;; If progress has already been initialized, do nothing. otherwise |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1453 ;; initialize the counter with a vector of: |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1454 ;; [start end lastsec context] |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1455 (c-progress-info) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1456 (t (setq c-progress-info (vector start |
18720 | 1457 (save-excursion |
1458 (goto-char end) | |
1459 (point-marker)) | |
1460 (nth 1 (current-time)) | |
1461 context)) | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1462 (message "indenting region...")) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1463 )) |
18720 | 1464 |
1465 (defun c-progress-update () | |
1466 ;; update progress | |
1467 (if (not (and c-progress-info c-progress-interval)) | |
1468 nil | |
1469 (let ((now (nth 1 (current-time))) | |
1470 (start (aref c-progress-info 0)) | |
1471 (end (aref c-progress-info 1)) | |
1472 (lastsecs (aref c-progress-info 2))) | |
1473 ;; should we update? currently, update happens every 2 seconds, | |
1474 ;; what's the right value? | |
1475 (if (< c-progress-interval (- now lastsecs)) | |
1476 (progn | |
1477 (message "indenting region... (%d%% complete)" | |
1478 (/ (* 100 (- (point) start)) (- end start))) | |
1479 (aset c-progress-info 2 now))) | |
1480 ))) | |
1481 | |
1482 (defun c-progress-fini (context) | |
1483 ;; finished | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1484 (if (not c-progress-interval) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1485 nil |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1486 (if (or (eq context (aref c-progress-info 3)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1487 (eq context t)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1488 (progn |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1489 (set-marker (aref c-progress-info 1) nil) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1490 (setq c-progress-info nil) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1491 (message "indenting region...done"))))) |
18720 | 1492 |
1493 | |
1494 | |
1495 ;;; This page handles insertion and removal of backslashes for C macros. | |
1496 | |
1497 (defun c-backslash-region (from to delete-flag) | |
1498 "Insert, align, or delete end-of-line backslashes on the lines in the region. | |
1499 With no argument, inserts backslashes and aligns existing backslashes. | |
1500 With an argument, deletes the backslashes. | |
1501 | |
1502 This function does not modify blank lines at the start of the region. | |
1503 If the region ends at the start of a line, it always deletes the | |
1504 backslash (if any) at the end of the previous line. | |
24282 | 1505 |
18720 | 1506 You can put the region around an entire macro definition and use this |
1507 command to conveniently insert and align the necessary backslashes." | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1508 (interactive "*r\nP") |
18720 | 1509 (save-excursion |
1510 (goto-char from) | |
1511 (let ((column c-backslash-column) | |
1512 (endmark (make-marker))) | |
1513 (move-marker endmark to) | |
1514 ;; Compute the smallest column number past the ends of all the lines. | |
1515 (if (not delete-flag) | |
1516 (while (< (point) to) | |
1517 (end-of-line) | |
1518 (if (eq (char-before) ?\\) | |
1519 (progn (forward-char -1) | |
1520 (skip-chars-backward " \t"))) | |
1521 (setq column (max column (1+ (current-column)))) | |
1522 (forward-line 1))) | |
1523 ;; Adjust upward to a tab column, if that doesn't push past the margin. | |
1524 (if (> (% column tab-width) 0) | |
1525 (let ((adjusted (* (/ (+ column tab-width -1) tab-width) tab-width))) | |
1526 (if (< adjusted (window-width)) | |
1527 (setq column adjusted)))) | |
1528 ;; Don't modify blank lines at start of region. | |
1529 (goto-char from) | |
1530 (while (and (< (point) endmark) (eolp)) | |
1531 (forward-line 1)) | |
1532 ;; Add or remove backslashes on all the lines. | |
1533 (while (< (point) endmark) | |
1534 (if (and (not delete-flag) | |
1535 ;; Un-backslashify the last line | |
1536 ;; if the region ends right at the start of the next line. | |
1537 (save-excursion | |
1538 (forward-line 1) | |
1539 (< (point) endmark))) | |
1540 (c-append-backslash column) | |
1541 (c-delete-backslash)) | |
1542 (forward-line 1)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1543 (move-marker endmark nil)))) |
18720 | 1544 |
1545 (defun c-append-backslash (column) | |
1546 (end-of-line) | |
1547 (if (eq (char-before) ?\\) | |
1548 (progn (forward-char -1) | |
1549 (delete-horizontal-space) | |
1550 (indent-to column)) | |
1551 (indent-to column) | |
1552 (insert "\\"))) | |
1553 | |
1554 (defun c-delete-backslash () | |
1555 (end-of-line) | |
1556 (or (bolp) | |
1557 (progn | |
1558 (forward-char -1) | |
1559 (if (looking-at "\\\\") | |
1560 (delete-region (1+ (point)) | |
1561 (progn (skip-chars-backward " \t") (point))))))) | |
1562 | |
1563 | |
1564 (defun c-fill-paragraph (&optional arg) | |
1565 "Like \\[fill-paragraph] but handles C and C++ style comments. | |
1566 If any of the current line is a comment or within a comment, | |
1567 fill the comment or the paragraph of it that point is in, | |
1568 preserving the comment indentation or line-starting decorations. | |
1569 | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1570 If point is inside multiline string literal, fill it. This currently |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1571 does not respect escaped newlines, except for the special case when it |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1572 is the very first thing in the string. The intended use for this rule |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1573 is in situations like the following: |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1574 |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1575 char description[] = \"\\ |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1576 A very long description of something that you want to fill to make |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1577 nicely formatted output.\"\; |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1578 |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1579 If point is in any other situation, i.e. in normal code, do nothing. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1580 |
18720 | 1581 Optional prefix ARG means justify paragraph as well." |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1582 (interactive "*P") |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1583 (let* ((point-save (point-marker)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1584 limits |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1585 comment-start-place |
18720 | 1586 (first-line |
1587 ;; Check for obvious entry to comment. | |
1588 (save-excursion | |
1589 (beginning-of-line) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1590 (skip-chars-forward " \t") |
18720 | 1591 (and (looking-at comment-start-skip) |
1592 (setq comment-start-place (point))))) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1593 (re1 "\\|\\([ \t]*/\\*[ \t]*\\|[ \t]*\\*/[ \t]*\\|[ \t/*]*\\)")) |
19378
a1987ab30543
(c-comment-line-break-function): In this function, and the defadvice,
Richard M. Stallman <rms@gnu.org>
parents:
19306
diff
changeset
|
1594 (if (save-excursion |
a1987ab30543
(c-comment-line-break-function): In this function, and the defadvice,
Richard M. Stallman <rms@gnu.org>
parents:
19306
diff
changeset
|
1595 (beginning-of-line) |
a1987ab30543
(c-comment-line-break-function): In this function, and the defadvice,
Richard M. Stallman <rms@gnu.org>
parents:
19306
diff
changeset
|
1596 (looking-at ".*//")) |
18720 | 1597 (let ((fill-prefix fill-prefix) |
1598 ;; Lines containing just a comment start or just an end | |
1599 ;; should not be filled into paragraphs they are next | |
1600 ;; to. | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1601 (paragraph-start (concat paragraph-start re1 "$")) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1602 (paragraph-separate (concat paragraph-separate re1 "$"))) |
18720 | 1603 (save-excursion |
1604 (beginning-of-line) | |
1605 ;; Move up to first line of this comment. | |
1606 (while (and (not (bobp)) | |
1607 (looking-at "[ \t]*//[ \t]*[^ \t\n]")) | |
1608 (forward-line -1)) | |
1609 (if (not (looking-at ".*//[ \t]*[^ \t\n]")) | |
1610 (forward-line 1)) | |
1611 ;; Find the comment start in this line. | |
1612 (re-search-forward "[ \t]*//[ \t]*") | |
1613 ;; Set the fill-prefix to be what all lines except the first | |
1614 ;; should start with. But do not alter a user set fill-prefix. | |
1615 (if (null fill-prefix) | |
1616 (setq fill-prefix (buffer-substring (match-beginning 0) | |
1617 (match-end 0)))) | |
1618 (save-restriction | |
1619 ;; Narrow down to just the lines of this comment. | |
1620 (narrow-to-region (c-point 'bol) | |
1621 (save-excursion | |
1622 (forward-line 1) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1623 (while |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1624 (looking-at (regexp-quote fill-prefix)) |
18720 | 1625 (forward-line 1)) |
1626 (point))) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1627 (or (c-safe |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1628 ;; fill-paragraph sometimes fails to detect when we |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1629 ;; are between paragraphs. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1630 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1631 (search-forward fill-prefix (c-point 'eol)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1632 (looking-at paragraph-separate)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1633 ;; Avoids recursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1634 (let (fill-paragraph-function) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1635 (fill-paragraph arg)))))) |
18720 | 1636 ;; else C style comments |
1637 (if (or first-line | |
1638 ;; t if we enter a comment between start of function and | |
1639 ;; this line. | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1640 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1641 (setq limits (c-literal-limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1642 (and (consp limits) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1643 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1644 (goto-char (car limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1645 (looking-at c-comment-start-regexp)))) |
18720 | 1646 ;; t if this line contains a comment starter. |
1647 (setq first-line | |
1648 (save-excursion | |
1649 (beginning-of-line) | |
1650 (prog1 | |
1651 (re-search-forward comment-start-skip | |
1652 (save-excursion (end-of-line) | |
1653 (point)) | |
1654 t) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1655 (setq comment-start-place (point))))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1656 ;; t if we're in the whitespace after a comment ender |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1657 ;; which ends its line. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1658 (and (not limits) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1659 (when (and (looking-at "[ \t]*$") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1660 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1661 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1662 (looking-at ".*\\*/[ \t]*$"))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1663 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1664 (forward-comment -1) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1665 (setq comment-start-place (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1666 t))) |
18720 | 1667 ;; Inside a comment: fill one comment paragraph. |
1668 (let ((fill-prefix | |
24282 | 1669 (or |
1670 ;; Keep user set fill prefix if any. | |
1671 fill-prefix | |
1672 ;; The prefix for each line of this paragraph | |
1673 ;; is the appropriate part of the start of this line, | |
1674 ;; up to the column at which text should be indented. | |
1675 (save-excursion | |
1676 (beginning-of-line) | |
1677 (if (looking-at ".*/\\*.*\\*/") | |
1678 (progn (re-search-forward comment-start-skip) | |
1679 (make-string (current-column) ?\ )) | |
1680 (if first-line | |
1681 (forward-line 1) | |
1682 (if (and (looking-at "[ \t]*\\*/") | |
1683 (not (save-excursion | |
1684 (forward-line -1) | |
1685 (looking-at ".*/\\*")))) | |
1686 (forward-line -1))) | |
18720 | 1687 |
24282 | 1688 (let ((line-width (progn (end-of-line) |
1689 (current-column)))) | |
1690 (beginning-of-line) | |
1691 (prog1 | |
1692 (buffer-substring | |
1693 (point) | |
18720 | 1694 |
24282 | 1695 ;; How shall we decide where the end of the |
1696 ;; fill-prefix is? | |
1697 (progn | |
1698 (skip-chars-forward " \t*" (c-point 'eol)) | |
1699 ;; kludge alert, watch out for */, in | |
1700 ;; which case fill-prefix should *not* | |
1701 ;; be "*"! | |
1702 (if (and (eq (char-after) ?/) | |
1703 (eq (char-before) ?*)) | |
1704 (forward-char -1)) | |
1705 (point))) | |
18720 | 1706 |
24282 | 1707 ;; If the comment is only one line followed |
1708 ;; by a blank line, calling move-to-column | |
1709 ;; above may have added some spaces and tabs | |
1710 ;; to the end of the line; the fill-paragraph | |
1711 ;; function will then delete it and the | |
1712 ;; newline following it, so we'll lose a | |
1713 ;; blank line when we shouldn't. So delete | |
1714 ;; anything move-to-column added to the end | |
1715 ;; of the line. We record the line width | |
1716 ;; instead of the position of the old line | |
1717 ;; end because move-to-column might break a | |
1718 ;; tab into spaces, and the new characters | |
1719 ;; introduced there shouldn't be deleted. | |
18720 | 1720 |
24282 | 1721 ;; If you can see a better way to do this, |
1722 ;; please make the change. This seems very | |
1723 ;; messy to me. | |
1724 (delete-region (progn (move-to-column line-width) | |
1725 (point)) | |
1726 (progn (end-of-line) (point))))))))) | |
18720 | 1727 |
1728 ;; Lines containing just a comment start or just an end | |
1729 ;; should not be filled into paragraphs they are next | |
1730 ;; to. | |
24282 | 1731 (paragraph-start (if (c-major-mode-is 'java-mode) |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1732 (concat paragraph-start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1733 re1 "\\(" |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1734 c-Java-javadoc-paragraph-start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1735 "\\|$\\)") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1736 (concat paragraph-start re1 "$"))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1737 (paragraph-separate (concat paragraph-separate re1 "$")) |
18720 | 1738 (chars-to-delete 0) |
1739 ) | |
1740 (save-restriction | |
1741 ;; Don't fill the comment together with the code | |
1742 ;; following it. So temporarily exclude everything | |
1743 ;; before the comment start, and everything after the | |
1744 ;; line where the comment ends. If comment-start-place | |
1745 ;; is non-nil, the comment starter is there. Otherwise, | |
1746 ;; point is inside the comment. | |
1747 (narrow-to-region (save-excursion | |
1748 (if comment-start-place | |
1749 (goto-char comment-start-place) | |
1750 (search-backward "/*")) | |
1751 (if (and (not c-hanging-comment-starter-p) | |
1752 (looking-at | |
1753 (concat c-comment-start-regexp | |
1754 "[ \t]*$"))) | |
1755 (forward-line 1)) | |
1756 ;; Protect text before the comment | |
1757 ;; start by excluding it. Add | |
1758 ;; spaces to bring back proper | |
1759 ;; indentation of that point. | |
1760 (let ((column (current-column))) | |
1761 (prog1 (point) | |
1762 (setq chars-to-delete column) | |
1763 (insert-char ?\ column)))) | |
1764 (save-excursion | |
1765 (if comment-start-place | |
1766 (goto-char (+ comment-start-place 2))) | |
1767 (search-forward "*/" nil 'move) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1768 (if (and (not c-hanging-comment-ender-p) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1769 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1770 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1771 (looking-at "[ \t]*\\*/"))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1772 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1773 (forward-line 1)) |
18720 | 1774 (point))) |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1775 (or (c-safe |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1776 ;; fill-paragraph sometimes fails to detect when we |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1777 ;; are between paragraphs. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1778 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1779 (search-forward fill-prefix (c-point 'eol)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1780 (looking-at paragraph-separate)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1781 ;; Avoids recursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1782 (let (fill-paragraph-function) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1783 (fill-paragraph arg))) |
18720 | 1784 (save-excursion |
1785 ;; Delete the chars we inserted to avoid clobbering | |
1786 ;; the stuff before the comment start. | |
1787 (goto-char (point-min)) | |
1788 (if (> chars-to-delete 0) | |
1789 (delete-region (point) (+ (point) chars-to-delete))) | |
1790 ;; Find the comment ender (should be on last line of | |
1791 ;; buffer, given the narrowing) and don't leave it on | |
1792 ;; its own line, unless that's the style that's desired. | |
1793 (goto-char (point-max)) | |
1794 (forward-line -1) | |
1795 (search-forward "*/" nil 'move) | |
1796 (beginning-of-line) | |
1797 (if (and c-hanging-comment-ender-p | |
1798 (looking-at "[ \t]*\\*/")) | |
1799 ;(delete-indentation))))) | |
1800 (let ((fill-column (+ fill-column 9999))) | |
1801 (forward-line -1) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1802 (fill-region-as-paragraph (point) (point-max)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1803 ;; If fill-prefix ended with a `*', it may be |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1804 ;; taken away from the comment ender. We got to |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1805 ;; check this and put it back if that is the |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1806 ;; case. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1807 (goto-char (- (point-max) 2)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1808 (if (not (= (char-before) ?*)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1809 (insert ?*)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1810 ))))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1811 ;; Else maybe a string. Fill it if it's a multiline string. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1812 ;; FIXME: This currently doesn't handle escaped newlines. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1813 ;; Doing that correctly is a bit tricky. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1814 (if (and limits |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1815 (eq (char-syntax (char-after (car limits))) ?\") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1816 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1817 (goto-char (car limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1818 (end-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1819 (< (point) (cdr limits)))) |
24282 | 1820 (let (fill-paragraph-function) |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1821 (save-restriction |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1822 (narrow-to-region (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1823 (goto-char (1+ (car limits))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1824 (if (looking-at "\\\\$") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1825 ;; Some DWIM: Leave the start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1826 ;; line if it's nothing but an |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1827 ;; escaped newline. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1828 (1+ (match-end 0)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1829 (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1830 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1831 (goto-char (1- (cdr limits))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1832 ;; Inserting a newline and |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1833 ;; removing it again after |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1834 ;; fill-paragraph makes it more |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1835 ;; predictable. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1836 (insert ?\n) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1837 (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1838 ;; Do not compensate for the narrowed column. This |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1839 ;; way the literal will always be filled at the same |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1840 ;; column internally. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1841 (fill-paragraph arg) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1842 (goto-char (1- (point-max))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1843 (delete-char 1))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1844 ))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1845 (goto-char (marker-position point-save)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1846 (set-marker point-save nil) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1847 ;; Always return t. This has the effect that if filling isn't |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1848 ;; done above, it isn't done at all, and it's therefore |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1849 ;; effectively disabled in normal code. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1850 t)) |
18720 | 1851 |
1852 | |
1853 (provide 'cc-cmds) | |
1854 ;;; cc-cmds.el ends here |