Mercurial > emacs
annotate lisp/progmodes/cc-cmds.el @ 24282:5b0864259a4b Release_5_25
Installed CC Mode 5.25.
author | Barry A. Warsaw <barry@zope.org> |
---|---|
date | Mon, 08 Feb 1999 16:53:18 +0000 |
parents | d67e858e738b |
children | 8309f6535486 |
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 () | |
1068 (save-excursion | |
1069 (skip-chars-forward "\t ") | |
1070 (current-column))) | |
1071 | |
1072 | |
1073 (defun c-up-conditional (count) | |
1074 "Move back to the containing preprocessor conditional, leaving mark behind. | |
1075 A prefix argument acts as a repeat count. With a negative argument, | |
1076 move forward to the end of the containing preprocessor conditional. | |
1077 When going backwards, `#elif' is treated like `#else' followed by | |
1078 `#if'. When going forwards, `#elif' is ignored." | |
1079 (interactive "p") | |
1080 (c-forward-conditional (- count) t) | |
1081 (c-keep-region-active)) | |
1082 | |
1083 (defun c-backward-conditional (count &optional up-flag) | |
1084 "Move back across a preprocessor conditional, leaving mark behind. | |
1085 A prefix argument acts as a repeat count. With a negative argument, | |
1086 move forward across a preprocessor conditional." | |
1087 (interactive "p") | |
1088 (c-forward-conditional (- count) up-flag) | |
1089 (c-keep-region-active)) | |
1090 | |
1091 (defun c-forward-conditional (count &optional up-flag) | |
1092 "Move forward across a preprocessor conditional, leaving mark behind. | |
1093 A prefix argument acts as a repeat count. With a negative argument, | |
1094 move backward across a preprocessor conditional." | |
1095 (interactive "p") | |
1096 (let* ((forward (> count 0)) | |
1097 (increment (if forward -1 1)) | |
1098 (search-function (if forward 're-search-forward 're-search-backward)) | |
1099 (new)) | |
1100 (save-excursion | |
1101 (while (/= count 0) | |
1102 (let ((depth (if up-flag 0 -1)) found) | |
1103 (save-excursion | |
1104 ;; Find the "next" significant line in the proper direction. | |
1105 (while (and (not found) | |
1106 ;; Rather than searching for a # sign that | |
1107 ;; comes at the beginning of a line aside from | |
1108 ;; whitespace, search first for a string | |
1109 ;; starting with # sign. Then verify what | |
1110 ;; precedes it. This is faster on account of | |
1111 ;; the fastmap feature of the regexp matcher. | |
1112 (funcall search-function | |
1113 "#[ \t]*\\(if\\|elif\\|endif\\)" | |
1114 nil t)) | |
1115 (beginning-of-line) | |
1116 ;; Now verify it is really a preproc line. | |
1117 (if (looking-at "^[ \t]*#[ \t]*\\(if\\|elif\\|endif\\)") | |
1118 (let ((prev depth)) | |
1119 ;; Update depth according to what we found. | |
1120 (beginning-of-line) | |
1121 (cond ((looking-at "[ \t]*#[ \t]*endif") | |
1122 (setq depth (+ depth increment))) | |
1123 ((looking-at "[ \t]*#[ \t]*elif") | |
1124 (if (and forward (= depth 0)) | |
1125 (setq found (point)))) | |
1126 (t (setq depth (- depth increment)))) | |
1127 ;; If we are trying to move across, and we find an | |
1128 ;; end before we find a beginning, get an error. | |
1129 (if (and (< prev 0) (< depth prev)) | |
1130 (error (if forward | |
1131 "No following conditional at this level" | |
1132 "No previous conditional at this level"))) | |
1133 ;; When searching forward, start from next line so | |
1134 ;; that we don't find the same line again. | |
1135 (if forward (forward-line 1)) | |
1136 ;; If this line exits a level of conditional, exit | |
1137 ;; inner loop. | |
1138 (if (< depth 0) | |
1139 (setq found (point)))) | |
1140 ;; else | |
1141 (if forward (forward-line 1)) | |
1142 ))) | |
1143 (or found | |
1144 (error "No containing preprocessor conditional")) | |
1145 (goto-char (setq new found))) | |
1146 (setq count (+ count increment)))) | |
1147 (push-mark) | |
1148 (goto-char new)) | |
1149 (c-keep-region-active)) | |
1150 | |
1151 | |
1152 ;; commands to indent lines, regions, defuns, and expressions | |
1153 (defun c-indent-command (&optional whole-exp) | |
1154 "Indent current line as C code, and/or insert some whitespace. | |
1155 | |
1156 If `c-tab-always-indent' is t, always just indent the current line. | |
1157 If nil, indent the current line only if point is at the left margin or | |
1158 in the line's indentation; otherwise insert some whitespace[*]. If | |
1159 other than nil or t, then some whitespace[*] is inserted only within | |
1160 literals (comments and strings) and inside preprocessor directives, | |
1161 but the line is always reindented. | |
1162 | |
1163 A numeric argument, regardless of its value, means indent rigidly all | |
1164 the lines of the expression starting after point so that this line | |
1165 becomes properly indented. The relative indentation among the lines | |
1166 of the expression are preserved. | |
1167 | |
1168 [*] The amount and kind of whitespace inserted is controlled by the | |
1169 variable `c-insert-tab-function', which is called to do the actual | |
1170 insertion of whitespace. Normally the function in this variable | |
1171 just inserts a tab character, or the equivalent number of spaces, | |
1172 depending on the variable `indent-tabs-mode'." | |
1173 | |
24282 | 1174 (interactive "P") |
18720 | 1175 (let ((bod (c-point 'bod))) |
1176 (if whole-exp | |
1177 ;; If arg, always indent this line as C | |
1178 ;; and shift remaining lines of expression the same amount. | |
1179 (let ((shift-amt (c-indent-line)) | |
1180 beg end) | |
1181 (save-excursion | |
1182 (if (eq c-tab-always-indent t) | |
1183 (beginning-of-line)) | |
1184 (setq beg (point)) | |
24282 | 1185 (c-forward-sexp 1) |
18720 | 1186 (setq end (point)) |
1187 (goto-char beg) | |
1188 (forward-line 1) | |
1189 (setq beg (point))) | |
1190 (if (> end beg) | |
1191 (indent-code-rigidly beg end (- shift-amt) "#"))) | |
1192 ;; No arg supplied, use c-tab-always-indent to determine | |
1193 ;; behavior | |
1194 (cond | |
1195 ;; CASE 1: indent when at column zero or in lines indentation, | |
1196 ;; otherwise insert a tab | |
1197 ((not c-tab-always-indent) | |
1198 (if (save-excursion | |
1199 (skip-chars-backward " \t") | |
1200 (not (bolp))) | |
1201 (funcall c-insert-tab-function) | |
1202 (c-indent-line))) | |
1203 ;; CASE 2: just indent the line | |
1204 ((eq c-tab-always-indent t) | |
1205 (c-indent-line)) | |
1206 ;; CASE 3: if in a literal, insert a tab, but always indent the | |
1207 ;; line | |
1208 (t | |
1209 (if (c-in-literal bod) | |
1210 (funcall c-insert-tab-function)) | |
1211 (c-indent-line) | |
1212 ))))) | |
1213 | |
1214 (defun c-indent-exp (&optional shutup-p) | |
1215 "Indent each line in balanced expression following point. | |
1216 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
|
1217 (interactive "*P") |
18720 | 1218 (let ((here (point)) |
1219 end progress-p) | |
1220 (unwind-protect | |
1221 (let ((c-echo-syntactic-information-p nil) ;keep quiet for speed | |
1222 (start (progn | |
1223 ;; try to be smarter about finding the range of | |
1224 ;; lines to indent. skip all following | |
1225 ;; whitespace. failing that, try to find any | |
1226 ;; opening brace on the current line | |
1227 (skip-chars-forward " \t\n") | |
1228 (if (memq (char-after) '(?\( ?\[ ?\{)) | |
1229 (point) | |
1230 (let ((state (parse-partial-sexp (point) | |
1231 (c-point 'eol)))) | |
1232 (and (nth 1 state) | |
1233 (goto-char (nth 1 state)) | |
1234 (memq (char-after) '(?\( ?\[ ?\{)) | |
1235 (point))))))) | |
1236 ;; find balanced expression end | |
24282 | 1237 (setq end (and (c-safe (progn (c-forward-sexp 1) t)) |
18720 | 1238 (point-marker))) |
1239 ;; sanity check | |
1240 (and (not start) | |
1241 (not shutup-p) | |
1242 (error "Cannot find start of balanced expression to indent.")) | |
1243 (and (not end) | |
1244 (not shutup-p) | |
1245 (error "Cannot find end of balanced expression to indent.")) | |
1246 (c-progress-init start end 'c-indent-exp) | |
1247 (setq progress-p t) | |
1248 (goto-char start) | |
1249 (beginning-of-line) | |
1250 (while (< (point) end) | |
1251 (if (not (looking-at "[ \t]*$")) | |
1252 (c-indent-line)) | |
1253 (c-progress-update) | |
1254 (forward-line 1))) | |
1255 ;; make sure marker is deleted | |
1256 (and end | |
1257 (set-marker end nil)) | |
1258 (and progress-p | |
1259 (c-progress-fini 'c-indent-exp)) | |
1260 (goto-char here)))) | |
1261 | |
1262 (defun c-indent-defun () | |
1263 "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
|
1264 (interactive "*") |
18720 | 1265 (let ((here (point-marker)) |
1266 (c-echo-syntactic-information-p nil) | |
1267 (brace (c-least-enclosing-brace (c-parse-state)))) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1268 (goto-char (or brace (c-point 'bod))) |
18720 | 1269 ;; if we're sitting at b-o-b, it might be because there was no |
1270 ;; least enclosing brace and we were sitting on the defun's open | |
1271 ;; brace. | |
1272 (if (and (bobp) (not (eq (char-after) ?\{))) | |
1273 (goto-char here)) | |
1274 ;; if defun-prompt-regexp is non-nil, b-o-d might not leave us at | |
1275 ;; the open brace. I consider this an Emacs bug. | |
1276 (and (boundp 'defun-prompt-regexp) | |
1277 defun-prompt-regexp | |
1278 (looking-at defun-prompt-regexp) | |
1279 (goto-char (match-end 0))) | |
1280 ;; catch all errors in c-indent-exp so we can 1. give more | |
1281 ;; meaningful error message, and 2. restore point | |
1282 (unwind-protect | |
1283 (c-indent-exp) | |
1284 (goto-char here) | |
1285 (set-marker here nil)))) | |
1286 | |
1287 (defun c-indent-region (start end) | |
1288 ;; Indent every line whose first char is between START and END inclusive. | |
1289 (save-excursion | |
1290 (goto-char start) | |
1291 ;; Advance to first nonblank line. | |
1292 (skip-chars-forward " \t\n") | |
1293 (beginning-of-line) | |
1294 (let (endmark) | |
1295 (unwind-protect | |
1296 (let ((c-tab-always-indent t) | |
1297 ;; shut up any echo msgs on indiv lines | |
1298 (c-echo-syntactic-information-p nil) | |
1299 fence) | |
1300 (c-progress-init start end 'c-indent-region) | |
1301 (setq endmark (copy-marker end)) | |
1302 (while (and (bolp) | |
1303 (not (eobp)) | |
1304 (< (point) endmark)) | |
1305 ;; update progress | |
1306 (c-progress-update) | |
1307 ;; Indent one line as with TAB. | |
1308 (let (nextline sexpend sexpbeg) | |
1309 ;; skip blank lines | |
1310 (skip-chars-forward " \t\n") | |
1311 (beginning-of-line) | |
1312 ;; indent the current line | |
1313 (c-indent-line) | |
1314 (setq fence (point)) | |
1315 (if (save-excursion | |
1316 (beginning-of-line) | |
1317 (looking-at "[ \t]*#")) | |
1318 (forward-line 1) | |
1319 (save-excursion | |
1320 ;; Find beginning of following line. | |
1321 (setq nextline (c-point 'bonl)) | |
1322 ;; Find first beginning-of-sexp for sexp extending past | |
1323 ;; this line. | |
1324 (beginning-of-line) | |
1325 (while (< (point) nextline) | |
1326 (condition-case nil | |
1327 (progn | |
24282 | 1328 (c-forward-sexp 1) |
18720 | 1329 (setq sexpend (point))) |
1330 (error (setq sexpend nil) | |
1331 (goto-char nextline))) | |
1332 (c-forward-syntactic-ws)) | |
1333 (if sexpend | |
24282 | 1334 (progn |
18720 | 1335 ;; make sure the sexp we found really starts on the |
1336 ;; current line and extends past it | |
1337 (goto-char sexpend) | |
1338 (setq sexpend (point-marker)) | |
24282 | 1339 (c-safe (c-backward-sexp 1)) |
18720 | 1340 (setq sexpbeg (point)))) |
1341 (if (and sexpbeg (< sexpbeg fence)) | |
1342 (setq sexpbeg fence))) | |
1343 ;; check to see if the next line starts a | |
1344 ;; comment-only line | |
1345 (save-excursion | |
1346 (forward-line 1) | |
1347 (skip-chars-forward " \t") | |
1348 (if (looking-at c-comment-start-regexp) | |
1349 (setq sexpbeg (c-point 'bol)))) | |
1350 ;; If that sexp ends within the region, indent it all at | |
1351 ;; once, fast. | |
1352 (condition-case nil | |
1353 (if (and sexpend | |
1354 (> sexpend nextline) | |
1355 (<= sexpend endmark)) | |
1356 (progn | |
1357 (goto-char sexpbeg) | |
1358 (c-indent-exp 'shutup) | |
1359 (c-progress-update) | |
1360 (goto-char sexpend))) | |
1361 (error | |
1362 (goto-char sexpbeg) | |
1363 (c-indent-line))) | |
1364 ;; Move to following line and try again. | |
1365 (and sexpend | |
1366 (markerp sexpend) | |
1367 (set-marker sexpend nil)) | |
1368 (forward-line 1) | |
1369 (setq fence (point)))))) | |
1370 (set-marker endmark nil) | |
1371 (c-progress-fini 'c-indent-region) | |
1372 (c-echo-parsing-error) | |
1373 )))) | |
1374 | |
1375 (defun c-mark-function () | |
24282 | 1376 "Put mark at end of current top-level defun, point at beginning." |
18720 | 1377 (interactive) |
1378 (let ((here (point)) | |
24282 | 1379 (eod (c-point 'eod)) |
1380 (state (c-parse-state))) | |
1381 ;; Are we sitting at the top level, someplace between either the | |
1382 ;; beginning of buffer, or the nearest preceding defun? If so, | |
1383 ;; try first to figure out whether we're sitting on the | |
1384 ;; introduction to a top-level defun, in which case we want to | |
1385 ;; mark the entire defun we're sitting on. | |
1386 ;; | |
1387 ;; If we're sitting on anything else at the top-level, we want to | |
1388 ;; just mark the statement that we're on | |
1389 (if (or (and (consp (car state)) | |
1390 (= (length state) 1)) | |
1391 (null state)) | |
1392 ;; Are we in the whitespace after the nearest preceding defun? | |
1393 (if (and state | |
1394 (looking-at "[ \t]*$") | |
1395 (= (save-excursion | |
1396 (c-backward-syntactic-ws) | |
1397 (skip-chars-backward ";") | |
1398 (point)) | |
1399 (cdar state))) | |
1400 (progn | |
1401 (setq eod (point)) | |
1402 (goto-char (caar state)) | |
1403 (c-beginning-of-statement-1)) | |
1404 (if (= ?{ (save-excursion | |
1405 (c-end-of-statement-1) | |
1406 (char-before))) | |
1407 ;; We must be in a defuns's introduction | |
1408 (progn | |
1409 (c-end-of-statement-1) | |
1410 (skip-chars-backward "{") | |
1411 (c-beginning-of-statement-1) | |
1412 (c-forward-syntactic-ws)) | |
1413 ;; Just mark the statement | |
1414 (c-end-of-statement-1) | |
1415 (forward-line 1) | |
1416 (setq eod (point)) | |
1417 (c-beginning-of-statement-1))) | |
1418 ;; We are inside some enclosing brace structure, so we first | |
1419 ;; need to find our way to the least enclosing brace. Then, in | |
1420 ;; both cases, we to mark the region from the beginning of the | |
1421 ;; current statement, until the end of the next following defun | |
1422 (while (and state) | |
1423 (or (consp (car state)) | |
1424 (goto-char (car state))) | |
1425 (setq state (cdr state))) | |
1426 (c-beginning-of-statement-1)) | |
18720 | 1427 (push-mark here) |
1428 (push-mark eod nil t))) | |
1429 | |
24282 | 1430 (defun c-indent-line-or-region () |
1431 "When the region is active, indent it. Otherwise indent the current line." | |
1432 ;; Emacs has a variable called mark-active, XEmacs uses region-active-p | |
1433 (interactive) | |
1434 (if (c-region-is-active-p) | |
1435 (c-indent-region (region-beginning) (region-end)) | |
1436 (c-indent-command))) | |
1437 | |
18720 | 1438 |
1439 ;; for progress reporting | |
1440 (defvar c-progress-info nil) | |
1441 | |
1442 (defun c-progress-init (start end context) | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1443 (cond |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1444 ;; Be silent |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1445 ((not c-progress-interval)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1446 ;; 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
|
1447 ;; 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
|
1448 ((not (fboundp 'current-time)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1449 (message "indenting region... (this may take a while)")) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1450 ;; 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
|
1451 ;; initialize the counter with a vector of: |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1452 ;; [start end lastsec context] |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1453 (c-progress-info) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1454 (t (setq c-progress-info (vector start |
18720 | 1455 (save-excursion |
1456 (goto-char end) | |
1457 (point-marker)) | |
1458 (nth 1 (current-time)) | |
1459 context)) | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1460 (message "indenting region...")) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1461 )) |
18720 | 1462 |
1463 (defun c-progress-update () | |
1464 ;; update progress | |
1465 (if (not (and c-progress-info c-progress-interval)) | |
1466 nil | |
1467 (let ((now (nth 1 (current-time))) | |
1468 (start (aref c-progress-info 0)) | |
1469 (end (aref c-progress-info 1)) | |
1470 (lastsecs (aref c-progress-info 2))) | |
1471 ;; should we update? currently, update happens every 2 seconds, | |
1472 ;; what's the right value? | |
1473 (if (< c-progress-interval (- now lastsecs)) | |
1474 (progn | |
1475 (message "indenting region... (%d%% complete)" | |
1476 (/ (* 100 (- (point) start)) (- end start))) | |
1477 (aset c-progress-info 2 now))) | |
1478 ))) | |
1479 | |
1480 (defun c-progress-fini (context) | |
1481 ;; finished | |
20143
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1482 (if (not c-progress-interval) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1483 nil |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1484 (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
|
1485 (eq context t)) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1486 (progn |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1487 (set-marker (aref c-progress-info 1) nil) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1488 (setq c-progress-info nil) |
69ce7b7acfd5
(c-progress-init, c-progress-fini):
Karl Heuer <kwzh@gnu.org>
parents:
20137
diff
changeset
|
1489 (message "indenting region...done"))))) |
18720 | 1490 |
1491 | |
1492 | |
1493 ;;; This page handles insertion and removal of backslashes for C macros. | |
1494 | |
1495 (defun c-backslash-region (from to delete-flag) | |
1496 "Insert, align, or delete end-of-line backslashes on the lines in the region. | |
1497 With no argument, inserts backslashes and aligns existing backslashes. | |
1498 With an argument, deletes the backslashes. | |
1499 | |
1500 This function does not modify blank lines at the start of the region. | |
1501 If the region ends at the start of a line, it always deletes the | |
1502 backslash (if any) at the end of the previous line. | |
24282 | 1503 |
18720 | 1504 You can put the region around an entire macro definition and use this |
1505 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
|
1506 (interactive "*r\nP") |
18720 | 1507 (save-excursion |
1508 (goto-char from) | |
1509 (let ((column c-backslash-column) | |
1510 (endmark (make-marker))) | |
1511 (move-marker endmark to) | |
1512 ;; Compute the smallest column number past the ends of all the lines. | |
1513 (if (not delete-flag) | |
1514 (while (< (point) to) | |
1515 (end-of-line) | |
1516 (if (eq (char-before) ?\\) | |
1517 (progn (forward-char -1) | |
1518 (skip-chars-backward " \t"))) | |
1519 (setq column (max column (1+ (current-column)))) | |
1520 (forward-line 1))) | |
1521 ;; Adjust upward to a tab column, if that doesn't push past the margin. | |
1522 (if (> (% column tab-width) 0) | |
1523 (let ((adjusted (* (/ (+ column tab-width -1) tab-width) tab-width))) | |
1524 (if (< adjusted (window-width)) | |
1525 (setq column adjusted)))) | |
1526 ;; Don't modify blank lines at start of region. | |
1527 (goto-char from) | |
1528 (while (and (< (point) endmark) (eolp)) | |
1529 (forward-line 1)) | |
1530 ;; Add or remove backslashes on all the lines. | |
1531 (while (< (point) endmark) | |
1532 (if (and (not delete-flag) | |
1533 ;; Un-backslashify the last line | |
1534 ;; if the region ends right at the start of the next line. | |
1535 (save-excursion | |
1536 (forward-line 1) | |
1537 (< (point) endmark))) | |
1538 (c-append-backslash column) | |
1539 (c-delete-backslash)) | |
1540 (forward-line 1)) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1541 (move-marker endmark nil)))) |
18720 | 1542 |
1543 (defun c-append-backslash (column) | |
1544 (end-of-line) | |
1545 (if (eq (char-before) ?\\) | |
1546 (progn (forward-char -1) | |
1547 (delete-horizontal-space) | |
1548 (indent-to column)) | |
1549 (indent-to column) | |
1550 (insert "\\"))) | |
1551 | |
1552 (defun c-delete-backslash () | |
1553 (end-of-line) | |
1554 (or (bolp) | |
1555 (progn | |
1556 (forward-char -1) | |
1557 (if (looking-at "\\\\") | |
1558 (delete-region (1+ (point)) | |
1559 (progn (skip-chars-backward " \t") (point))))))) | |
1560 | |
1561 | |
1562 (defun c-fill-paragraph (&optional arg) | |
1563 "Like \\[fill-paragraph] but handles C and C++ style comments. | |
1564 If any of the current line is a comment or within a comment, | |
1565 fill the comment or the paragraph of it that point is in, | |
1566 preserving the comment indentation or line-starting decorations. | |
1567 | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1568 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
|
1569 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
|
1570 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
|
1571 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
|
1572 |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1573 char description[] = \"\\ |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1574 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
|
1575 nicely formatted output.\"\; |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1576 |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1577 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
|
1578 |
18720 | 1579 Optional prefix ARG means justify paragraph as well." |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1580 (interactive "*P") |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1581 (let* ((point-save (point-marker)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1582 limits |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1583 comment-start-place |
18720 | 1584 (first-line |
1585 ;; Check for obvious entry to comment. | |
1586 (save-excursion | |
1587 (beginning-of-line) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1588 (skip-chars-forward " \t") |
18720 | 1589 (and (looking-at comment-start-skip) |
1590 (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
|
1591 (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
|
1592 (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
|
1593 (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
|
1594 (looking-at ".*//")) |
18720 | 1595 (let ((fill-prefix fill-prefix) |
1596 ;; Lines containing just a comment start or just an end | |
1597 ;; should not be filled into paragraphs they are next | |
1598 ;; to. | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1599 (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
|
1600 (paragraph-separate (concat paragraph-separate re1 "$"))) |
18720 | 1601 (save-excursion |
1602 (beginning-of-line) | |
1603 ;; Move up to first line of this comment. | |
1604 (while (and (not (bobp)) | |
1605 (looking-at "[ \t]*//[ \t]*[^ \t\n]")) | |
1606 (forward-line -1)) | |
1607 (if (not (looking-at ".*//[ \t]*[^ \t\n]")) | |
1608 (forward-line 1)) | |
1609 ;; Find the comment start in this line. | |
1610 (re-search-forward "[ \t]*//[ \t]*") | |
1611 ;; Set the fill-prefix to be what all lines except the first | |
1612 ;; should start with. But do not alter a user set fill-prefix. | |
1613 (if (null fill-prefix) | |
1614 (setq fill-prefix (buffer-substring (match-beginning 0) | |
1615 (match-end 0)))) | |
1616 (save-restriction | |
1617 ;; Narrow down to just the lines of this comment. | |
1618 (narrow-to-region (c-point 'bol) | |
1619 (save-excursion | |
1620 (forward-line 1) | |
20912
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1621 (while |
a0748eef9a76
(c-beginning-of-statement)
Richard M. Stallman <rms@gnu.org>
parents:
20143
diff
changeset
|
1622 (looking-at (regexp-quote fill-prefix)) |
18720 | 1623 (forward-line 1)) |
1624 (point))) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1625 (or (c-safe |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1626 ;; 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
|
1627 ;; are between paragraphs. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1628 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1629 (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
|
1630 (looking-at paragraph-separate)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1631 ;; Avoids recursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1632 (let (fill-paragraph-function) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1633 (fill-paragraph arg)))))) |
18720 | 1634 ;; else C style comments |
1635 (if (or first-line | |
1636 ;; t if we enter a comment between start of function and | |
1637 ;; this line. | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1638 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1639 (setq limits (c-literal-limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1640 (and (consp limits) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1641 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1642 (goto-char (car limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1643 (looking-at c-comment-start-regexp)))) |
18720 | 1644 ;; t if this line contains a comment starter. |
1645 (setq first-line | |
1646 (save-excursion | |
1647 (beginning-of-line) | |
1648 (prog1 | |
1649 (re-search-forward comment-start-skip | |
1650 (save-excursion (end-of-line) | |
1651 (point)) | |
1652 t) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1653 (setq comment-start-place (point))))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1654 ;; 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
|
1655 ;; which ends its line. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1656 (and (not limits) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1657 (when (and (looking-at "[ \t]*$") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1658 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1659 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1660 (looking-at ".*\\*/[ \t]*$"))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1661 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1662 (forward-comment -1) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1663 (setq comment-start-place (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1664 t))) |
18720 | 1665 ;; Inside a comment: fill one comment paragraph. |
1666 (let ((fill-prefix | |
24282 | 1667 (or |
1668 ;; Keep user set fill prefix if any. | |
1669 fill-prefix | |
1670 ;; The prefix for each line of this paragraph | |
1671 ;; is the appropriate part of the start of this line, | |
1672 ;; up to the column at which text should be indented. | |
1673 (save-excursion | |
1674 (beginning-of-line) | |
1675 (if (looking-at ".*/\\*.*\\*/") | |
1676 (progn (re-search-forward comment-start-skip) | |
1677 (make-string (current-column) ?\ )) | |
1678 (if first-line | |
1679 (forward-line 1) | |
1680 (if (and (looking-at "[ \t]*\\*/") | |
1681 (not (save-excursion | |
1682 (forward-line -1) | |
1683 (looking-at ".*/\\*")))) | |
1684 (forward-line -1))) | |
18720 | 1685 |
24282 | 1686 (let ((line-width (progn (end-of-line) |
1687 (current-column)))) | |
1688 (beginning-of-line) | |
1689 (prog1 | |
1690 (buffer-substring | |
1691 (point) | |
18720 | 1692 |
24282 | 1693 ;; How shall we decide where the end of the |
1694 ;; fill-prefix is? | |
1695 (progn | |
1696 (skip-chars-forward " \t*" (c-point 'eol)) | |
1697 ;; kludge alert, watch out for */, in | |
1698 ;; which case fill-prefix should *not* | |
1699 ;; be "*"! | |
1700 (if (and (eq (char-after) ?/) | |
1701 (eq (char-before) ?*)) | |
1702 (forward-char -1)) | |
1703 (point))) | |
18720 | 1704 |
24282 | 1705 ;; If the comment is only one line followed |
1706 ;; by a blank line, calling move-to-column | |
1707 ;; above may have added some spaces and tabs | |
1708 ;; to the end of the line; the fill-paragraph | |
1709 ;; function will then delete it and the | |
1710 ;; newline following it, so we'll lose a | |
1711 ;; blank line when we shouldn't. So delete | |
1712 ;; anything move-to-column added to the end | |
1713 ;; of the line. We record the line width | |
1714 ;; instead of the position of the old line | |
1715 ;; end because move-to-column might break a | |
1716 ;; tab into spaces, and the new characters | |
1717 ;; introduced there shouldn't be deleted. | |
18720 | 1718 |
24282 | 1719 ;; If you can see a better way to do this, |
1720 ;; please make the change. This seems very | |
1721 ;; messy to me. | |
1722 (delete-region (progn (move-to-column line-width) | |
1723 (point)) | |
1724 (progn (end-of-line) (point))))))))) | |
18720 | 1725 |
1726 ;; Lines containing just a comment start or just an end | |
1727 ;; should not be filled into paragraphs they are next | |
1728 ;; to. | |
24282 | 1729 (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
|
1730 (concat paragraph-start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1731 re1 "\\(" |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1732 c-Java-javadoc-paragraph-start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1733 "\\|$\\)") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1734 (concat paragraph-start re1 "$"))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1735 (paragraph-separate (concat paragraph-separate re1 "$")) |
18720 | 1736 (chars-to-delete 0) |
1737 ) | |
1738 (save-restriction | |
1739 ;; Don't fill the comment together with the code | |
1740 ;; following it. So temporarily exclude everything | |
1741 ;; before the comment start, and everything after the | |
1742 ;; line where the comment ends. If comment-start-place | |
1743 ;; is non-nil, the comment starter is there. Otherwise, | |
1744 ;; point is inside the comment. | |
1745 (narrow-to-region (save-excursion | |
1746 (if comment-start-place | |
1747 (goto-char comment-start-place) | |
1748 (search-backward "/*")) | |
1749 (if (and (not c-hanging-comment-starter-p) | |
1750 (looking-at | |
1751 (concat c-comment-start-regexp | |
1752 "[ \t]*$"))) | |
1753 (forward-line 1)) | |
1754 ;; Protect text before the comment | |
1755 ;; start by excluding it. Add | |
1756 ;; spaces to bring back proper | |
1757 ;; indentation of that point. | |
1758 (let ((column (current-column))) | |
1759 (prog1 (point) | |
1760 (setq chars-to-delete column) | |
1761 (insert-char ?\ column)))) | |
1762 (save-excursion | |
1763 (if comment-start-place | |
1764 (goto-char (+ comment-start-place 2))) | |
1765 (search-forward "*/" nil 'move) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1766 (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
|
1767 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1768 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1769 (looking-at "[ \t]*\\*/"))) |
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 (forward-line 1)) |
18720 | 1772 (point))) |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1773 (or (c-safe |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1774 ;; 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
|
1775 ;; are between paragraphs. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1776 (beginning-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1777 (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
|
1778 (looking-at paragraph-separate)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1779 ;; Avoids recursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1780 (let (fill-paragraph-function) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1781 (fill-paragraph arg))) |
18720 | 1782 (save-excursion |
1783 ;; Delete the chars we inserted to avoid clobbering | |
1784 ;; the stuff before the comment start. | |
1785 (goto-char (point-min)) | |
1786 (if (> chars-to-delete 0) | |
1787 (delete-region (point) (+ (point) chars-to-delete))) | |
1788 ;; Find the comment ender (should be on last line of | |
1789 ;; buffer, given the narrowing) and don't leave it on | |
1790 ;; its own line, unless that's the style that's desired. | |
1791 (goto-char (point-max)) | |
1792 (forward-line -1) | |
1793 (search-forward "*/" nil 'move) | |
1794 (beginning-of-line) | |
1795 (if (and c-hanging-comment-ender-p | |
1796 (looking-at "[ \t]*\\*/")) | |
1797 ;(delete-indentation))))) | |
1798 (let ((fill-column (+ fill-column 9999))) | |
1799 (forward-line -1) | |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1800 (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
|
1801 ;; 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
|
1802 ;; 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
|
1803 ;; 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
|
1804 ;; case. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1805 (goto-char (- (point-max) 2)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1806 (if (not (= (char-before) ?*)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1807 (insert ?*)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1808 ))))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1809 ;; 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
|
1810 ;; 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
|
1811 ;; 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
|
1812 (if (and limits |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1813 (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
|
1814 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1815 (goto-char (car limits)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1816 (end-of-line) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1817 (< (point) (cdr limits)))) |
24282 | 1818 (let (fill-paragraph-function) |
21107
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1819 (save-restriction |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1820 (narrow-to-region (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1821 (goto-char (1+ (car limits))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1822 (if (looking-at "\\\\$") |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1823 ;; Some DWIM: Leave the start |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1824 ;; 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
|
1825 ;; escaped newline. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1826 (1+ (match-end 0)) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1827 (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1828 (save-excursion |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1829 (goto-char (1- (cdr limits))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1830 ;; Inserting a newline and |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1831 ;; removing it again after |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1832 ;; fill-paragraph makes it more |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1833 ;; predictable. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1834 (insert ?\n) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1835 (point))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1836 ;; 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
|
1837 ;; 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
|
1838 ;; column internally. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1839 (fill-paragraph arg) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1840 (goto-char (1- (point-max))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1841 (delete-char 1))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1842 ))) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1843 (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
|
1844 (set-marker point-save nil) |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1845 ;; 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
|
1846 ;; 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
|
1847 ;; effectively disabled in normal code. |
d67e858e738b
(c-fill-paragraph): Bind fill-paragraph-function to
Richard M. Stallman <rms@gnu.org>
parents:
20912
diff
changeset
|
1848 t)) |
18720 | 1849 |
1850 | |
1851 (provide 'cc-cmds) | |
1852 ;;; cc-cmds.el ends here |