Mercurial > emacs
annotate lisp/progmodes/cc-mode.el @ 37451:ff30b541575a
Add @opindex entries to index all command-line options.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Wed, 25 Apr 2001 05:57:08 +0000 |
parents | 32a4317c6aa5 |
children | 79039a33283a |
rev | line source |
---|---|
18720 | 1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code |
2 | |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 4 |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5 ;; Authors: 2000- Martin Stjernholm |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
24282 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: a long, long, time ago. adapted from the original c-mode.el |
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 | |
36920 | 27 ;; along with this program; see the file COPYING. If not, write to |
28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
36920 | 31 (defconst c-version "5.28" |
32 "CC Mode version number.") | |
33 | |
34 ;; NOTE: Read the commentary below for the right way to submit bug reports! | |
35 ;; NOTE: See the accompanying texinfo manual for details on using this mode! | |
36 | |
18720 | 37 ;;; Commentary: |
38 | |
39 ;; This package provides GNU Emacs major modes for editing C, C++, | |
24282 | 40 ;; Objective-C, Java, IDL and Pike code. As of the latest Emacs and |
41 ;; XEmacs releases, it is the default package for editing these | |
42 ;; languages. This package is called "CC Mode", and should be spelled | |
43 ;; exactly this way. | |
44 | |
45 ;; CC Mode supports K&R and ANSI C, ANSI C++, Objective-C, Java, | |
46 ;; CORBA's IDL, and Pike with a consistent indentation model across | |
47 ;; all modes. This indentation model is intuitive and very flexible, | |
48 ;; so that almost any desired style of indentation can be supported. | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
49 ;; Installation, usage, and programming details are contained in an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
50 ;; accompanying texinfo manual. |
18720 | 51 |
52 ;; CC Mode's immediate ancestors were, c++-mode.el, cplus-md.el, and | |
53 ;; cplus-md1.el.. | |
54 | |
55 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic | |
56 ;; coloring, keyword highlighting, etc.) for any of the supported | |
57 ;; modes. Typically this is done by a package called font-lock.el | |
24282 | 58 ;; which we do *not* maintain. You should contact the Emacs or XEmacs |
18720 | 59 ;; maintainers for questions about coloring or highlighting in any |
60 ;; language mode. | |
61 | |
62 ;; To submit bug reports, type "C-c C-b". These will be sent to | |
24282 | 63 ;; bug-gnu-emacs@gnu.org (mirrored as the Usenet newsgroup |
64 ;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly | |
65 ;; contacts the CC Mode maintainers. Questions can sent to | |
66 ;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or | |
36920 | 67 ;; bug-cc-mode@gnu.org. Please do not send bugs or questions to our |
68 ;; personal accounts; we reserve the right to ignore such email! | |
18720 | 69 |
70 ;; Many, many thanks go out to all the folks on the beta test list. | |
71 ;; Without their patience, testing, insight, code contributions, and | |
72 ;; encouragement CC Mode would be a far inferior package. | |
73 | |
74 ;; You can get the latest version of CC Mode, including PostScript | |
75 ;; documentation and separate individual files from: | |
76 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
77 ;; http://cc-mode.sourceforge.net/ |
18720 | 78 ;; |
24282 | 79 ;; You can join a moderated CC Mode announcement-only mailing list by |
80 ;; visiting | |
81 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
82 ;; http://lists.sourceforge.net/mailman/listinfo/cc-mode-announce |
18720 | 83 |
84 ;;; Code: | |
85 | |
26817 | 86 (eval-when-compile |
87 (let ((load-path | |
36920 | 88 (if (and (boundp 'byte-compile-dest-file) |
89 (stringp byte-compile-dest-file)) | |
90 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 91 load-path))) |
36920 | 92 (require 'cc-bytecomp))) |
21109
a0eda86dd0be
(c-initialize-cc-mode): Moved require's to top level.
Richard M. Stallman <rms@gnu.org>
parents:
20917
diff
changeset
|
93 |
36920 | 94 (cc-require 'cc-defs) |
95 (cc-require 'cc-menus) | |
96 (cc-require 'cc-vars) | |
97 (cc-require 'cc-langs) | |
98 (cc-require 'cc-styles) | |
99 (cc-require 'cc-engine) | |
100 (cc-require 'cc-cmds) | |
101 (cc-require 'cc-align) | |
102 | |
103 ;; Silence the compiler. | |
104 (cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+ | |
105 (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+ | |
106 (cc-bytecomp-defun set-keymap-parents) ; XEmacs | |
107 | |
108 ;; Menu support for both XEmacs and Emacs. If you don't have easymenu | |
109 ;; with your version of Emacs, you are incompatible! | |
110 (require 'easymenu) | |
18720 | 111 |
112 | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
113 ;; Other modes and packages which depend on CC Mode should do the |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
114 ;; following to make sure everything is loaded and available for their |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
115 ;; use: |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
116 ;; |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
117 ;; (require 'cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
118 ;; (c-initialize-cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
119 |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
120 ;;;###autoload |
24282 | 121 (defun c-initialize-cc-mode () |
19299
7cd7373cc021
(c-initialize-cc-mode): Set c-buffer-is-cc-mode to t.
Richard M. Stallman <rms@gnu.org>
parents:
19253
diff
changeset
|
122 (setq c-buffer-is-cc-mode t) |
24282 | 123 (let ((initprop 'cc-mode-is-initialized) |
124 c-initialization-ok) | |
125 (unless (get 'c-initialize-cc-mode initprop) | |
126 (unwind-protect | |
127 (progn | |
26817 | 128 (put 'c-initialize-cc-mode initprop t) |
129 (c-initialize-builtin-style) | |
24282 | 130 (run-hooks 'c-initialization-hook) |
26817 | 131 ;; Fix obsolete variables. |
132 (if (boundp 'c-comment-continuation-stars) | |
133 (setq c-block-comment-prefix c-comment-continuation-stars)) | |
24282 | 134 (setq c-initialization-ok t)) |
135 ;; Will try initialization hooks again if they failed. | |
26817 | 136 (put 'c-initialize-cc-mode initprop c-initialization-ok))) |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
137 )) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
138 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
139 |
36920 | 140 ;; Common routines |
141 (defvar c-mode-base-map () | |
142 "Keymap shared by all CC Mode related modes.") | |
143 | |
144 (defun c-make-inherited-keymap () | |
145 (let ((map (make-sparse-keymap))) | |
146 (cond | |
147 ;; XEmacs 19 & 20 | |
148 ((fboundp 'set-keymap-parents) | |
149 (set-keymap-parents map c-mode-base-map)) | |
150 ;; Emacs 19 | |
151 ((fboundp 'set-keymap-parent) | |
152 (set-keymap-parent map c-mode-base-map)) | |
153 ;; incompatible | |
154 (t (error "CC Mode is incompatible with this version of Emacs"))) | |
155 map)) | |
156 | |
157 (if c-mode-base-map | |
158 nil | |
159 ;; TBD: should we even worry about naming this keymap. My vote: no, | |
160 ;; because Emacs and XEmacs do it differently. | |
161 (setq c-mode-base-map (make-sparse-keymap)) | |
162 ;; put standard keybindings into MAP | |
163 ;; the following mappings correspond more or less directly to BOCM | |
164 (define-key c-mode-base-map "{" 'c-electric-brace) | |
165 (define-key c-mode-base-map "}" 'c-electric-brace) | |
166 (define-key c-mode-base-map ";" 'c-electric-semi&comma) | |
167 (define-key c-mode-base-map "#" 'c-electric-pound) | |
168 (define-key c-mode-base-map ":" 'c-electric-colon) | |
169 (define-key c-mode-base-map "(" 'c-electric-paren) | |
170 (define-key c-mode-base-map ")" 'c-electric-paren) | |
171 ;; Separate M-BS from C-M-h. The former should remain | |
172 ;; backward-kill-word. | |
173 (define-key c-mode-base-map [(control meta h)] 'c-mark-function) | |
174 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp) | |
175 (substitute-key-definition 'backward-sentence | |
176 'c-beginning-of-statement | |
177 c-mode-base-map global-map) | |
178 (substitute-key-definition 'forward-sentence | |
179 'c-end-of-statement | |
180 c-mode-base-map global-map) | |
181 (substitute-key-definition 'indent-new-comment-line | |
182 'c-indent-new-comment-line | |
183 c-mode-base-map global-map) | |
184 ;; RMS says don't make these the default. | |
185 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun) | |
186 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun) | |
187 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional) | |
188 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional) | |
189 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional) | |
190 (substitute-key-definition 'indent-for-tab-command | |
191 'c-indent-command | |
192 c-mode-base-map global-map) | |
193 ;; It doesn't suffice to put c-fill-paragraph on | |
194 ;; fill-paragraph-function due to the way it works. | |
195 (substitute-key-definition 'fill-paragraph 'c-fill-paragraph | |
196 c-mode-base-map global-map) | |
197 ;; In XEmacs the default fill function is called | |
198 ;; fill-paragraph-or-region. | |
199 (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph | |
200 c-mode-base-map global-map) | |
201 ;; Caution! Enter here at your own risk. We are trying to support | |
202 ;; several behaviors and it gets disgusting. :-( | |
203 ;; | |
204 (if (boundp 'delete-key-deletes-forward) | |
205 (progn | |
206 ;; In XEmacs 20 it is possible to sanely define both backward | |
207 ;; and forward deletion behavior under X separately (TTYs are | |
208 ;; forever beyond hope, but who cares? XEmacs 20 does the | |
209 ;; right thing with these too). | |
210 (define-key c-mode-base-map [delete] 'c-electric-delete) | |
211 (define-key c-mode-base-map [backspace] 'c-electric-backspace)) | |
212 ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind | |
213 ;; backwards deletion behavior to DEL, which both Delete and | |
214 ;; Backspace get translated to. There's no way to separate this | |
215 ;; behavior in a clean way, so deal with it! Besides, it's been | |
216 ;; this way since the dawn of BOCM. | |
217 (define-key c-mode-base-map "\177" 'c-electric-backspace)) | |
218 ;; these are new keybindings, with no counterpart to BOCM | |
219 (define-key c-mode-base-map "," 'c-electric-semi&comma) | |
220 (define-key c-mode-base-map "*" 'c-electric-star) | |
221 (define-key c-mode-base-map "/" 'c-electric-slash) | |
222 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun) | |
223 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region) | |
224 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature | |
225 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state) | |
226 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report) | |
227 (define-key c-mode-base-map "\C-c\C-c" 'comment-region) | |
228 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state) | |
229 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset) | |
230 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information) | |
231 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state) | |
232 (define-key c-mode-base-map "\C-c." 'c-set-style) | |
233 ;; conflicts with OOBR | |
234 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) | |
235 ) | |
236 | |
237 (defvar c-c-menu nil) | |
238 (defvar c-c++-menu nil) | |
239 (defvar c-objc-menu nil) | |
240 (defvar c-java-menu nil) | |
241 (defvar c-pike-menu nil) | |
242 | |
243 (defun c-mode-menu (modestr) | |
244 (let ((m | |
245 '(["Comment Out Region" comment-region (c-fn-region-is-active-p)] | |
246 ["Uncomment Region" | |
247 (comment-region (region-beginning) (region-end) '(4)) | |
248 (c-fn-region-is-active-p)] | |
249 ["Fill Comment Paragraph" c-fill-paragraph t] | |
250 "---" | |
251 ["Indent Expression" c-indent-exp | |
252 (memq (char-after) '(?\( ?\[ ?\{))] | |
253 ["Indent Line or Region" c-indent-line-or-region t] | |
254 ["Up Conditional" c-up-conditional t] | |
255 ["Backward Conditional" c-backward-conditional t] | |
256 ["Forward Conditional" c-forward-conditional t] | |
257 ["Backward Statement" c-beginning-of-statement t] | |
258 ["Forward Statement" c-end-of-statement t] | |
259 "---" | |
260 ["Macro Expand Region" c-macro-expand (c-fn-region-is-active-p)] | |
261 ["Backslashify" c-backslash-region | |
262 (c-fn-region-is-active-p)] | |
263 ))) | |
264 (cons modestr m))) | |
265 | |
266 ;; We don't require the outline package, but we configure it a bit anyway. | |
267 (cc-bytecomp-defvar outline-level) | |
268 | |
269 (defun c-common-init () | |
270 ;; Common initializations for all modes. | |
271 ;; these variables should always be buffer local; they do not affect | |
272 ;; indentation style. | |
273 (make-local-variable 'require-final-newline) | |
274 (make-local-variable 'parse-sexp-ignore-comments) | |
275 (make-local-variable 'indent-line-function) | |
276 (make-local-variable 'indent-region-function) | |
277 (make-local-variable 'outline-regexp) | |
278 (make-local-variable 'outline-level) | |
279 (make-local-variable 'normal-auto-fill-function) | |
280 (make-local-variable 'comment-start) | |
281 (make-local-variable 'comment-end) | |
282 (make-local-variable 'comment-column) | |
283 (make-local-variable 'comment-start-skip) | |
284 (make-local-variable 'comment-multi-line) | |
285 (make-local-variable 'paragraph-start) | |
286 (make-local-variable 'paragraph-separate) | |
287 (make-local-variable 'paragraph-ignore-fill-prefix) | |
288 (make-local-variable 'adaptive-fill-mode) | |
289 (make-local-variable 'adaptive-fill-regexp) | |
290 (make-local-variable 'imenu-generic-expression) ;set in the mode functions | |
291 ;; X/Emacs 20 only | |
292 (and (boundp 'comment-line-break-function) | |
293 (progn | |
294 (make-local-variable 'comment-line-break-function) | |
295 (setq comment-line-break-function | |
296 'c-indent-new-comment-line))) | |
297 ;; now set their values | |
298 (setq require-final-newline t | |
299 parse-sexp-ignore-comments t | |
300 indent-line-function 'c-indent-line | |
301 indent-region-function 'c-indent-region | |
302 outline-regexp "[^#\n\^M]" | |
303 outline-level 'c-outline-level | |
304 normal-auto-fill-function 'c-do-auto-fill | |
305 comment-column 32 | |
306 comment-start-skip "/\\*+ *\\|//+ *" | |
307 comment-multi-line t) | |
308 ;; now set the mode style based on c-default-style | |
309 (let ((style (if (stringp c-default-style) | |
310 c-default-style | |
311 (or (cdr (assq major-mode c-default-style)) | |
312 (cdr (assq 'other c-default-style)) | |
313 "gnu")))) | |
314 ;; Override style variables if `c-old-style-variable-behavior' is | |
315 ;; set. Also override if we are using global style variables, | |
316 ;; have already initialized a style once, and are switching to a | |
317 ;; different style. (It's doubtful whether this is desirable, but | |
318 ;; the whole situation with nonlocal style variables is a bit | |
319 ;; awkward. It's at least the most compatible way with the old | |
320 ;; style init procedure.) | |
321 (c-set-style style (not (or c-old-style-variable-behavior | |
322 (and (not c-style-variables-are-local-p) | |
323 c-indentation-style | |
324 (not (string-equal c-indentation-style | |
325 style))))))) | |
326 ;; Fix things up for paragraph recognition and filling inside | |
327 ;; comments by using c-current-comment-prefix in the relevant | |
328 ;; places. We use adaptive filling for this to make it possible to | |
329 ;; use filladapt or some other fancy package. | |
330 (setq c-current-comment-prefix | |
331 (if (listp c-comment-prefix-regexp) | |
332 (cdr-safe (or (assoc major-mode c-comment-prefix-regexp) | |
333 (assoc 'other c-comment-prefix-regexp))) | |
334 c-comment-prefix-regexp)) | |
335 (let ((comment-line-prefix | |
336 (concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*"))) | |
337 (setq paragraph-start (concat comment-line-prefix | |
338 c-append-paragraph-start | |
339 "\\|" | |
340 page-delimiter) | |
341 paragraph-separate (concat comment-line-prefix | |
342 c-append-paragraph-separate | |
343 "\\|" | |
344 page-delimiter) | |
345 paragraph-ignore-fill-prefix t | |
346 adaptive-fill-mode t | |
347 adaptive-fill-regexp | |
348 (concat comment-line-prefix | |
349 (if adaptive-fill-regexp | |
350 (concat "\\(" adaptive-fill-regexp "\\)") | |
351 ""))) | |
352 (when (boundp 'adaptive-fill-first-line-regexp) | |
353 ;; XEmacs (20.x) adaptive fill mode doesn't have this. | |
354 (make-local-variable 'adaptive-fill-first-line-regexp) | |
355 (setq adaptive-fill-first-line-regexp | |
356 (concat "\\`" comment-line-prefix | |
357 ;; Maybe we should incorporate the old value here, | |
358 ;; but then we have to do all sorts of kludges to | |
359 ;; deal with the \` and \' it probably contains. | |
360 "\\'")))) | |
361 ;; we have to do something special for c-offsets-alist so that the | |
362 ;; buffer local value has its own alist structure. | |
363 (setq c-offsets-alist (copy-alist c-offsets-alist)) | |
364 ;; setup the comment indent variable in a Emacs version portable way | |
365 ;; ignore any byte compiler warnings you might get here | |
366 (make-local-variable 'comment-indent-function) | |
367 (setq comment-indent-function 'c-comment-indent) | |
368 ;; add menus to menubar | |
369 (easy-menu-add (c-mode-menu mode-name)) | |
370 ;; put auto-hungry designators onto minor-mode-alist, but only once | |
371 (or (assq 'c-auto-hungry-string minor-mode-alist) | |
372 (setq minor-mode-alist | |
373 (cons '(c-auto-hungry-string c-auto-hungry-string) | |
374 minor-mode-alist))) | |
375 ) | |
376 | |
377 (defun c-postprocess-file-styles () | |
378 "Function that post processes relevant file local variables. | |
379 Currently, this function simply applies any style and offset settings | |
380 found in the file's Local Variable list. It first applies any style | |
381 setting found in `c-file-style', then it applies any offset settings | |
382 it finds in `c-file-offsets'. | |
383 | |
384 Note that the style variables are always made local to the buffer." | |
385 ;; apply file styles and offsets | |
386 (if (or c-file-style c-file-offsets) | |
387 (c-make-styles-buffer-local t)) | |
388 (and c-file-style | |
389 (c-set-style c-file-style)) | |
390 (and c-file-offsets | |
391 (mapcar | |
392 (function | |
393 (lambda (langentry) | |
394 (let ((langelem (car langentry)) | |
395 (offset (cdr langentry))) | |
396 (c-set-offset langelem offset) | |
397 ))) | |
398 c-file-offsets))) | |
399 | |
400 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles) | |
401 | |
402 | |
403 ;; Support for C | |
404 | |
405 (defvar c-mode-abbrev-table nil | |
406 "Abbreviation table used in c-mode buffers.") | |
407 (define-abbrev-table 'c-mode-abbrev-table | |
408 '(("else" "else" c-electric-continued-statement 0) | |
409 ("while" "while" c-electric-continued-statement 0))) | |
410 | |
411 (defvar c-mode-map () | |
412 "Keymap used in c-mode buffers.") | |
413 (if c-mode-map | |
414 nil | |
415 (setq c-mode-map (c-make-inherited-keymap)) | |
416 ;; add bindings which are only useful for C | |
417 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) | |
418 ) | |
419 | |
420 (easy-menu-define c-c-menu c-mode-map "C Mode Commands" | |
421 (c-mode-menu "C")) | |
422 | |
18720 | 423 ;;;###autoload |
424 (defun c-mode () | |
425 "Major mode for editing K&R and ANSI C code. | |
426 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
427 c-mode buffer. This automatically sets up a mail buffer with version | |
428 information already added. You just need to add a description of the | |
429 problem, including a reproducible test case and send the message. | |
430 | |
431 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
432 | |
433 The hook variable `c-mode-hook' is run with no args, if that value is | |
434 bound and has a non-nil value. Also the hook `c-mode-common-hook' is | |
435 run first. | |
436 | |
437 Key bindings: | |
438 \\{c-mode-map}" | |
439 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
440 (c-initialize-cc-mode) |
18720 | 441 (kill-all-local-variables) |
442 (set-syntax-table c-mode-syntax-table) | |
443 (setq major-mode 'c-mode | |
444 mode-name "C" | |
36920 | 445 local-abbrev-table c-mode-abbrev-table |
446 abbrev-mode t) | |
18720 | 447 (use-local-map c-mode-map) |
448 (c-common-init) | |
449 (setq comment-start "/* " | |
450 comment-end " */" | |
36920 | 451 c-keywords (c-identifier-re c-C-keywords) |
18720 | 452 c-conditional-key c-C-conditional-key |
453 c-class-key c-C-class-key | |
454 c-baseclass-key nil | |
26817 | 455 c-comment-start-regexp c-C-comment-start-regexp |
456 c-bitfield-key c-C-bitfield-key | |
24282 | 457 ) |
26817 | 458 (cc-imenu-init cc-imenu-c-generic-expression) |
18720 | 459 (run-hooks 'c-mode-common-hook) |
460 (run-hooks 'c-mode-hook) | |
461 (c-update-modeline)) | |
462 | |
463 | |
36920 | 464 ;; Support for C++ |
465 | |
466 (defvar c++-mode-abbrev-table nil | |
467 "Abbreviation table used in c++-mode buffers.") | |
468 (define-abbrev-table 'c++-mode-abbrev-table | |
469 '(("else" "else" c-electric-continued-statement 0) | |
470 ("while" "while" c-electric-continued-statement 0) | |
471 ("catch" "catch" c-electric-continued-statement 0))) | |
472 | |
473 (defvar c++-mode-map () | |
474 "Keymap used in c++-mode buffers.") | |
475 (if c++-mode-map | |
476 nil | |
477 (setq c++-mode-map (c-make-inherited-keymap)) | |
478 ;; add bindings which are only useful for C++ | |
479 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand) | |
480 (define-key c++-mode-map "\C-c:" 'c-scope-operator) | |
481 (define-key c++-mode-map "<" 'c-electric-lt-gt) | |
482 (define-key c++-mode-map ">" 'c-electric-lt-gt)) | |
483 | |
484 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" | |
485 (c-mode-menu "C++")) | |
486 | |
18720 | 487 ;;;###autoload |
488 (defun c++-mode () | |
489 "Major mode for editing C++ code. | |
490 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
491 c++-mode buffer. This automatically sets up a mail buffer with | |
492 version information already added. You just need to add a description | |
493 of the problem, including a reproducible test case, and send the | |
494 message. | |
495 | |
496 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
497 | |
498 The hook variable `c++-mode-hook' is run with no args, if that | |
499 variable is bound and has a non-nil value. Also the hook | |
500 `c-mode-common-hook' is run first. | |
501 | |
502 Key bindings: | |
503 \\{c++-mode-map}" | |
504 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
505 (c-initialize-cc-mode) |
18720 | 506 (kill-all-local-variables) |
507 (set-syntax-table c++-mode-syntax-table) | |
508 (setq major-mode 'c++-mode | |
509 mode-name "C++" | |
36920 | 510 local-abbrev-table c++-mode-abbrev-table |
511 abbrev-mode t) | |
18720 | 512 (use-local-map c++-mode-map) |
513 (c-common-init) | |
514 (setq comment-start "// " | |
515 comment-end "" | |
36920 | 516 c-keywords (c-identifier-re c-C++-keywords) |
18720 | 517 c-conditional-key c-C++-conditional-key |
518 c-comment-start-regexp c-C++-comment-start-regexp | |
519 c-class-key c-C++-class-key | |
24282 | 520 c-extra-toplevel-key c-C++-extra-toplevel-key |
18720 | 521 c-access-key c-C++-access-key |
522 c-recognize-knr-p nil | |
26817 | 523 c-bitfield-key c-C-bitfield-key |
24282 | 524 ) |
26817 | 525 (cc-imenu-init cc-imenu-c++-generic-expression) |
18720 | 526 (run-hooks 'c-mode-common-hook) |
527 (run-hooks 'c++-mode-hook) | |
528 (c-update-modeline)) | |
529 | |
530 | |
36920 | 531 ;; Support for Objective-C |
532 | |
533 (defvar objc-mode-abbrev-table nil | |
534 "Abbreviation table used in objc-mode buffers.") | |
535 (define-abbrev-table 'objc-mode-abbrev-table | |
536 '(("else" "else" c-electric-continued-statement 0) | |
537 ("while" "while" c-electric-continued-statement 0))) | |
538 | |
539 (defvar objc-mode-map () | |
540 "Keymap used in objc-mode buffers.") | |
541 (if objc-mode-map | |
542 nil | |
543 (setq objc-mode-map (c-make-inherited-keymap)) | |
544 ;; add bindings which are only useful for Objective-C | |
545 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)) | |
546 | |
547 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" | |
548 (c-mode-menu "ObjC")) | |
549 | |
18720 | 550 ;;;###autoload |
551 (defun objc-mode () | |
552 "Major mode for editing Objective C code. | |
553 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
554 objc-mode buffer. This automatically sets up a mail buffer with | |
555 version information already added. You just need to add a description | |
556 of the problem, including a reproducible test case, and send the | |
557 message. | |
558 | |
559 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
560 | |
561 The hook variable `objc-mode-hook' is run with no args, if that value | |
562 is bound and has a non-nil value. Also the hook `c-mode-common-hook' | |
563 is run first. | |
564 | |
565 Key bindings: | |
566 \\{objc-mode-map}" | |
567 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
568 (c-initialize-cc-mode) |
18720 | 569 (kill-all-local-variables) |
570 (set-syntax-table objc-mode-syntax-table) | |
571 (setq major-mode 'objc-mode | |
572 mode-name "ObjC" | |
36920 | 573 local-abbrev-table objc-mode-abbrev-table |
574 abbrev-mode t) | |
18720 | 575 (use-local-map objc-mode-map) |
576 (c-common-init) | |
577 (setq comment-start "// " | |
578 comment-end "" | |
36920 | 579 c-keywords (c-identifier-re c-ObjC-keywords) |
26817 | 580 c-conditional-key c-ObjC-conditional-key |
581 c-comment-start-regexp c-ObjC-comment-start-regexp | |
18720 | 582 c-class-key c-ObjC-class-key |
583 c-baseclass-key nil | |
584 c-access-key c-ObjC-access-key | |
20135
ecb78a6ccd8d
(objc-mode): Bind imenu-create-index-function
Karl Heuer <kwzh@gnu.org>
parents:
19808
diff
changeset
|
585 c-method-key c-ObjC-method-key |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
586 ) |
26817 | 587 (cc-imenu-init cc-imenu-objc-generic-expression) |
18720 | 588 (run-hooks 'c-mode-common-hook) |
589 (run-hooks 'objc-mode-hook) | |
590 (c-update-modeline)) | |
591 | |
592 | |
36920 | 593 ;; Support for Java |
594 | |
595 (defvar java-mode-abbrev-table nil | |
596 "Abbreviation table used in java-mode buffers.") | |
597 (define-abbrev-table 'java-mode-abbrev-table | |
598 '(("else" "else" c-electric-continued-statement 0) | |
599 ("while" "while" c-electric-continued-statement 0) | |
600 ("catch" "catch" c-electric-continued-statement 0) | |
601 ("finally" "finally" c-electric-continued-statement 0))) | |
602 | |
603 (defvar java-mode-map () | |
604 "Keymap used in java-mode buffers.") | |
605 (if java-mode-map | |
606 nil | |
607 (setq java-mode-map (c-make-inherited-keymap)) | |
608 ;; add bindings which are only useful for Java | |
609 ) | |
610 | |
611 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands" | |
612 (c-mode-menu "Java")) | |
613 | |
18720 | 614 ;;;###autoload |
615 (defun java-mode () | |
616 "Major mode for editing Java code. | |
20135
ecb78a6ccd8d
(objc-mode): Bind imenu-create-index-function
Karl Heuer <kwzh@gnu.org>
parents:
19808
diff
changeset
|
617 To submit a problem report, enter `\\[c-submit-bug-report]' from a |
18720 | 618 java-mode buffer. This automatically sets up a mail buffer with |
619 version information already added. You just need to add a description | |
620 of the problem, including a reproducible test case and send the | |
621 message. | |
622 | |
623 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
624 | |
625 The hook variable `java-mode-hook' is run with no args, if that value | |
626 is bound and has a non-nil value. Also the common hook | |
627 `c-mode-common-hook' is run first. Note that this mode automatically | |
628 sets the \"java\" style before calling any hooks so be careful if you | |
629 set styles in `c-mode-common-hook'. | |
630 | |
631 Key bindings: | |
632 \\{java-mode-map}" | |
633 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
634 (c-initialize-cc-mode) |
18720 | 635 (kill-all-local-variables) |
636 (set-syntax-table java-mode-syntax-table) | |
637 (setq major-mode 'java-mode | |
638 mode-name "Java" | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
639 local-abbrev-table java-mode-abbrev-table |
36920 | 640 abbrev-mode t |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
641 c-append-paragraph-start c-Java-javadoc-paragraph-start) |
18720 | 642 (use-local-map java-mode-map) |
643 (c-common-init) | |
644 (setq comment-start "// " | |
645 comment-end "" | |
36920 | 646 c-keywords (c-identifier-re c-Java-keywords) |
18720 | 647 c-conditional-key c-Java-conditional-key |
648 c-comment-start-regexp c-Java-comment-start-regexp | |
649 c-class-key c-Java-class-key | |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
650 c-method-key nil |
18720 | 651 c-baseclass-key nil |
652 c-recognize-knr-p nil | |
24282 | 653 c-inexpr-class-key c-Java-inexpr-class-key |
18720 | 654 ;defun-prompt-regexp c-Java-defun-prompt-regexp |
655 ) | |
26817 | 656 (cc-imenu-init cc-imenu-java-generic-expression) |
18720 | 657 (run-hooks 'c-mode-common-hook) |
658 (run-hooks 'java-mode-hook) | |
659 (c-update-modeline)) | |
660 | |
661 | |
36920 | 662 ;; Support for CORBA's IDL language |
663 | |
664 (defvar idl-mode-abbrev-table nil | |
665 "Abbreviation table used in idl-mode buffers.") | |
666 (define-abbrev-table 'idl-mode-abbrev-table ()) | |
667 | |
668 (defvar idl-mode-map () | |
669 "Keymap used in idl-mode buffers.") | |
670 (if idl-mode-map | |
671 nil | |
672 (setq idl-mode-map (c-make-inherited-keymap)) | |
673 ;; add bindings which are only useful for IDL | |
674 ) | |
675 | |
676 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" | |
677 (c-mode-menu "IDL")) | |
678 | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
679 ;;;###autoload |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
680 (defun idl-mode () |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
681 "Major mode for editing CORBA's IDL code. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
682 To submit a problem report, enter `\\[c-submit-bug-report]' from an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
683 idl-mode buffer. This automatically sets up a mail buffer with |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
684 version information already added. You just need to add a description |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
685 of the problem, including a reproducible test case, and send the |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
686 message. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
687 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
688 To see what version of CC Mode you are running, enter `\\[c-version]'. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
689 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
690 The hook variable `idl-mode-hook' is run with no args, if that |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
691 variable is bound and has a non-nil value. Also the hook |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
692 `c-mode-common-hook' is run first. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
693 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
694 Key bindings: |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
695 \\{idl-mode-map}" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
696 (interactive) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
697 (c-initialize-cc-mode) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
698 (kill-all-local-variables) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
699 (set-syntax-table idl-mode-syntax-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
700 (setq major-mode 'idl-mode |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
701 mode-name "IDL" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
702 local-abbrev-table idl-mode-abbrev-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
703 (use-local-map idl-mode-map) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
704 (c-common-init) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
705 (setq comment-start "// " |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
706 comment-end "" |
36920 | 707 c-keywords (c-identifier-re c-IDL-keywords) |
26817 | 708 c-conditional-key c-IDL-conditional-key |
709 c-comment-start-regexp c-IDL-comment-start-regexp | |
24282 | 710 c-class-key c-IDL-class-key |
26817 | 711 c-method-key nil |
712 c-baseclass-key nil | |
24282 | 713 c-extra-toplevel-key c-IDL-extra-toplevel-key |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
714 c-recognize-knr-p nil |
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
715 ) |
26817 | 716 ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;FIXME |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
717 (run-hooks 'c-mode-common-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
718 (run-hooks 'idl-mode-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
719 (c-update-modeline)) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
720 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
721 |
36920 | 722 ;; Support for Pike |
723 | |
724 (defvar pike-mode-abbrev-table nil | |
725 "Abbreviation table used in pike-mode buffers.") | |
726 (define-abbrev-table 'pike-mode-abbrev-table | |
727 '(("else" "else" c-electric-continued-statement 0) | |
728 ("while" "while" c-electric-continued-statement 0))) | |
729 | |
730 (defvar pike-mode-map () | |
731 "Keymap used in pike-mode buffers.") | |
732 (if pike-mode-map | |
733 nil | |
734 (setq pike-mode-map (c-make-inherited-keymap)) | |
735 ;; additional bindings | |
736 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)) | |
737 | |
738 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" | |
739 (c-mode-menu "Pike")) | |
740 | |
24282 | 741 ;;;###autoload |
742 (defun pike-mode () | |
743 "Major mode for editing Pike code. | |
744 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
745 idl-mode buffer. This automatically sets up a mail buffer with | |
746 version information already added. You just need to add a description | |
747 of the problem, including a reproducible test case, and send the | |
748 message. | |
749 | |
750 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
751 | |
752 The hook variable `pike-mode-hook' is run with no args, if that value | |
753 is bound and has a non-nil value. Also the common hook | |
754 `c-mode-common-hook' is run first. | |
755 | |
756 Key bindings: | |
757 \\{pike-mode-map}" | |
758 (interactive) | |
759 (c-initialize-cc-mode) | |
760 (kill-all-local-variables) | |
761 (set-syntax-table pike-mode-syntax-table) | |
762 (setq major-mode 'pike-mode | |
763 mode-name "Pike" | |
36920 | 764 local-abbrev-table pike-mode-abbrev-table |
765 abbrev-mode t | |
766 c-append-paragraph-start c-Pike-pikedoc-paragraph-start | |
767 c-append-paragraph-separate c-Pike-pikedoc-paragraph-separate) | |
24282 | 768 (use-local-map pike-mode-map) |
769 (c-common-init) | |
770 (setq comment-start "// " | |
771 comment-end "" | |
36920 | 772 c-keywords (c-identifier-re c-Pike-keywords) |
24282 | 773 c-conditional-key c-Pike-conditional-key |
26817 | 774 c-comment-start-regexp c-Pike-comment-start-regexp |
24282 | 775 c-class-key c-Pike-class-key |
776 c-method-key nil | |
777 c-baseclass-key nil | |
778 c-recognize-knr-p nil | |
779 c-lambda-key c-Pike-lambda-key | |
780 c-inexpr-block-key c-Pike-inexpr-block-key | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
781 c-inexpr-class-key c-Pike-inexpr-class-key |
24282 | 782 c-special-brace-lists c-Pike-special-brace-lists |
783 ) | |
26817 | 784 ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;FIXME |
24282 | 785 (run-hooks 'c-mode-common-hook) |
786 (run-hooks 'pike-mode-hook) | |
787 (c-update-modeline)) | |
788 | |
789 | |
36920 | 790 ;; Helper for setting up Filladapt mode. It's not used by CC Mode itself. |
791 | |
792 (cc-bytecomp-defvar filladapt-token-table) | |
793 (cc-bytecomp-defvar filladapt-token-match-table) | |
794 (cc-bytecomp-defvar filladapt-token-conversion-table) | |
795 | |
26817 | 796 (defun c-setup-filladapt () |
797 "Convenience function to configure Kyle E. Jones' Filladapt mode for | |
798 CC Mode by making sure the proper entries are present on | |
799 `filladapt-token-table', `filladapt-token-match-table', and | |
800 `filladapt-token-conversion-table'. This is intended to be used on | |
801 `c-mode-common-hook' or similar." | |
802 ;; This function is intended to be used explicitly by the end user | |
803 ;; only. | |
804 ;; | |
805 ;; The default configuration already handles C++ comments, but we | |
806 ;; need to add handling of C block comments. A new filladapt token | |
807 ;; `c-comment' is added for that. | |
808 (let (p) | |
809 (setq p filladapt-token-table) | |
810 (while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment))) | |
811 (setq p (cdr-safe p))) | |
812 (if p | |
36920 | 813 (setcar (car p) c-current-comment-prefix) |
26817 | 814 (setq filladapt-token-table |
815 (append (list (car filladapt-token-table) | |
36920 | 816 (list c-current-comment-prefix 'c-comment)) |
26817 | 817 (cdr filladapt-token-table))))) |
818 (unless (assq 'c-comment filladapt-token-match-table) | |
819 (setq filladapt-token-match-table | |
820 (append '((c-comment c-comment)) | |
821 filladapt-token-match-table))) | |
822 (unless (assq 'c-comment filladapt-token-conversion-table) | |
823 (setq filladapt-token-conversion-table | |
824 (append '((c-comment . exact)) | |
825 filladapt-token-conversion-table)))) | |
826 | |
827 | |
20146 | 828 ;; bug reporting |
18720 | 829 |
830 (defconst c-mode-help-address | |
24282 | 831 "bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org" |
832 "Addresses for CC Mode bug reports.") | |
18720 | 833 |
834 (defun c-version () | |
835 "Echo the current version of CC Mode in the minibuffer." | |
836 (interactive) | |
837 (message "Using CC Mode version %s" c-version) | |
838 (c-keep-region-active)) | |
839 | |
36920 | 840 (defvar c-prepare-bug-report-hooks nil) |
841 | |
842 ;; Dynamic variables used by reporter. | |
843 (defvar reporter-prompt-for-summary-p) | |
844 (defvar reporter-dont-compact-list) | |
845 | |
18720 | 846 (defun c-submit-bug-report () |
847 "Submit via mail a bug report on CC Mode." | |
848 (interactive) | |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
849 (require 'reporter) |
18720 | 850 ;; load in reporter |
851 (let ((reporter-prompt-for-summary-p t) | |
852 (reporter-dont-compact-list '(c-offsets-alist)) | |
853 (style c-indentation-style) | |
854 (c-features c-emacs-features)) | |
855 (and | |
856 (if (y-or-n-p "Do you want to submit a report on CC Mode? ") | |
857 t (message "") nil) | |
858 (require 'reporter) | |
859 (reporter-submit-bug-report | |
860 c-mode-help-address | |
861 (concat "CC Mode " c-version " (" | |
862 (cond ((eq major-mode 'c++-mode) "C++") | |
863 ((eq major-mode 'c-mode) "C") | |
864 ((eq major-mode 'objc-mode) "ObjC") | |
865 ((eq major-mode 'java-mode) "Java") | |
26817 | 866 ((eq major-mode 'idl-mode) "IDL") |
24282 | 867 ((eq major-mode 'pike-mode) "Pike") |
18720 | 868 ) |
869 ")") | |
26817 | 870 (let ((vars (append |
18720 | 871 ;; report only the vars that affect indentation |
26817 | 872 c-style-variables |
873 '(c-delete-function | |
874 c-electric-pound-behavior | |
875 c-indent-comments-syntactically-p | |
876 c-tab-always-indent | |
877 defun-prompt-regexp | |
878 tab-width | |
879 comment-column | |
880 parse-sexp-ignore-comments | |
881 ;; A brain-damaged XEmacs only variable that, if | |
882 ;; set to nil can cause all kinds of chaos. | |
883 signal-error-on-buffer-boundary | |
884 ;; Variables that affect line breaking and comments. | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
885 auto-fill-function |
26817 | 886 filladapt-mode |
887 comment-multi-line | |
888 comment-start-skip | |
889 fill-prefix | |
890 paragraph-start | |
891 adaptive-fill-mode | |
892 adaptive-fill-regexp) | |
893 nil))) | |
894 (delq 'c-special-indent-hook vars) | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
895 (mapcar (lambda (var) (unless (boundp var) (delq var vars))) |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
896 '(signal-error-on-buffer-boundary |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
897 filladapt-mode |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
898 defun-prompt-regexp)) |
26817 | 899 vars) |
18720 | 900 (function |
901 (lambda () | |
36920 | 902 (run-hooks 'c-prepare-bug-report-hooks) |
18720 | 903 (insert |
904 "Buffer Style: " style "\n\n" | |
905 (format "c-emacs-features: %s\n" c-features) | |
36920 | 906 ))))))) |
18720 | 907 |
908 | |
36920 | 909 (cc-provide 'cc-mode) |
18720 | 910 ;;; cc-mode.el ends here |