]> code.delx.au - gnu-emacs/blob - lisp/progmodes/cc-langs.el
* faces.el (secondary-selection): Change background to yellow.
[gnu-emacs] / lisp / progmodes / cc-langs.el
1 ;;; cc-langs.el --- specific language support for CC Mode
2
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
4
5 ;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm
6 ;; 1992-1997 Barry A. Warsaw
7 ;; 1987 Dave Detlefs and Stewart Clamen
8 ;; 1985 Richard M. Stallman
9 ;; Maintainer: bug-cc-mode@gnu.org
10 ;; Created: 22-Apr-1997 (split from cc-mode.el)
11 ;; Version: See cc-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
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
31
32 \f
33 (eval-when-compile
34 (require 'cc-defs))
35
36 ;; Regular expressions and other values which must be parameterized on
37 ;; a per-language basis.
38
39 ;; Keywords defining protection levels
40 (defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
41
42 ;; Regex describing a `symbol' in all languages. We cannot use just
43 ;; `word' syntax class since `_' cannot be in word class. Putting
44 ;; underscore in word class breaks forward word movement behavior that
45 ;; users are familiar with. Besides, this runs counter to Emacs
46 ;; convention.
47 ;;
48 ;; I suspect this definition isn't correct in light of Java's
49 ;; definition of a symbol as being Unicode. I know so little about
50 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to
51 ;; punt on this for now.
52
53 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*")
54
55 \f
56 ;; keywords introducing class definitions. language specific
57 (defconst c-C-class-key "\\(struct\\|union\\)")
58 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)")
59 (defconst c-IDL-class-key "\\(class\\|struct\\|union\\|interface\\)")
60 (defconst c-C-extra-toplevel-key "\\(extern\\)")
61 (defconst c-C++-extra-toplevel-key "\\(extern\\|namespace\\)")
62 (defconst c-IDL-extra-toplevel-key "\\(module\\)")
63
64 (defconst c-ObjC-class-key
65 (concat
66 "@\\(interface\\|implementation\\)\\s +"
67 c-symbol-key ;name of the class
68 "\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
69 "\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
70 ))
71
72 (defconst c-Java-class-key
73 (concat
74 "\\(" c-protection-key "\\s +\\)?"
75 "\\(interface\\|class\\)\\s +"
76 c-symbol-key ;name of the class
77 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
78 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
79 ))
80
81 (defconst c-Pike-class-key "class")
82
83 (defvar c-class-key c-C-class-key)
84 (make-variable-buffer-local 'c-class-key)
85
86 (defvar c-extra-toplevel-key c-C-extra-toplevel-key)
87 (make-variable-buffer-local 'c-extra-toplevel-key)
88
89 \f
90 ;; regexp describing access protection clauses. language specific
91 (defvar c-access-key nil)
92 (make-variable-buffer-local 'c-access-key)
93 (defconst c-C++-access-key (concat c-protection-key "[ \t]*:"))
94 (defconst c-ObjC-access-key (concat "@" c-protection-key))
95 (defconst c-Java-access-key nil)
96 (defconst c-Pike-access-key nil)
97
98 \f
99 ;; keywords introducing conditional blocks
100 (defconst c-C-conditional-key nil)
101 (defconst c-C++-conditional-key nil)
102 (defconst c-Java-conditional-key nil)
103 (defconst c-Pike-conditional-key nil)
104
105 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
106 (exc-kws "\\|try\\|catch")
107 (thr-kws "\\|finally\\|synchronized")
108 (front "\\b\\(")
109 (back "\\)\\b[^_]"))
110 (setq c-C-conditional-key (concat front all-kws back)
111 c-C++-conditional-key (concat front all-kws exc-kws back)
112 c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)
113 c-Pike-conditional-key (concat front all-kws "\\|foreach" back)))
114
115 (defvar c-conditional-key c-C-conditional-key)
116 (make-variable-buffer-local 'c-conditional-key)
117
118 \f
119 ;; keywords describing method definition introductions
120 (defvar c-method-key nil)
121 (make-variable-buffer-local 'c-method-key)
122
123 (defconst c-ObjC-method-key
124 (concat
125 "^\\s *[+-]\\s *"
126 "\\(([^)]*)\\)?" ; return type
127 ;; \\s- in objc syntax table does not include \n
128 ;; since it is considered the end of //-comments.
129 "[ \t\n]*" c-symbol-key))
130
131
132 \f
133 ;; comment starter definitions for various languages. language specific
134 (defconst c-C++-comment-start-regexp "/[/*]")
135 ;; We need to match all 3 Java style comments
136 ;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
137 (defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
138 (defvar c-comment-start-regexp c-C++-comment-start-regexp)
139 (make-variable-buffer-local 'c-comment-start-regexp)
140
141
142 \f
143 ;; Regexp describing a switch's case or default label for all languages
144 (defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
145 ;; Regexp describing any label.
146 (defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
147
148 ;; Regexp describing class inheritance declarations. TBD: this should
149 ;; be language specific, and only makes sense for C++
150 (defconst c-inher-key
151 (concat "\\(\\<static\\>\\s +\\)?"
152 c-C++-class-key "[ \t]+" c-symbol-key
153 "\\([ \t]*:[ \t]*\\)\\s *[^;]"))
154
155 ;; Regexp describing C++ base classes in a derived class definition.
156 ;; TBD: this should be language specific, and only makes sense for C++
157 (defvar c-baseclass-key
158 (concat
159 ":?[ \t]*\\(virtual[ \t]+\\)?\\("
160 c-protection-key "[ \t]+\\)" c-symbol-key))
161 (make-variable-buffer-local 'c-baseclass-key)
162
163 ;; Regexp describing friend declarations in C++ classes.
164 (defconst c-C++-friend-key
165 "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
166
167 ;; Regexp describing Java inheritance and throws clauses.
168 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
169
170 ;; Regexp describing the beginning of a Java top-level definition.
171 (defconst c-Java-defun-prompt-regexp
172 "^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()\7f=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*")
173
174 ;; Regexp describing Javadoc markup that always starts paragraphs.
175 (defconst c-Java-javadoc-paragraph-start
176 "@\\(author\\|exception\\|param\\|return\\|see\\|version\\)")
177
178 ;; Regexp that starts lambda constructs.
179 (defvar c-lambda-key nil)
180 (make-variable-buffer-local 'c-lambda-key)
181 (defconst c-Pike-lambda-key "\\<lambda\\>")
182
183 ;; Regexp that are followed by a statement block in expressions.
184 (defvar c-inexpr-block-key nil)
185 (make-variable-buffer-local 'c-inexpr-block-key)
186 (defconst c-Pike-inexpr-block-key "\\<\\(catch\\|gauge\\)\\>")
187
188 ;; Regexp that may be followed by an anonymous class in expressions.
189 (defvar c-inexpr-class-key nil)
190 (make-variable-buffer-local 'c-inexpr-class-key)
191 (defconst c-Java-inexpr-class-key "\\<new\\>")
192
193 ;; List of open- and close-chars that makes up a pike-style brace
194 ;; list, ie for a `([ ])' list there should be a cons (?\[ . ?\]) in
195 ;; this list.
196 (defvar c-special-brace-lists nil)
197 (make-variable-buffer-local 'c-special-brace-lists)
198 (defconst c-Pike-special-brace-lists '((?{ . ?})
199 (?\[ . ?\])
200 (?< . ?>)))
201
202
203 \f
204 ;; internal state variables
205
206 ;; Internal state of hungry delete key feature
207 (defvar c-hungry-delete-key nil)
208 (make-variable-buffer-local 'c-hungry-delete-key)
209
210 ;; Internal state of auto newline feature.
211 (defvar c-auto-newline nil)
212 (make-variable-buffer-local 'c-auto-newline)
213
214 ;; Internal auto-newline/hungry-delete designation string for mode line.
215 (defvar c-auto-hungry-string nil)
216 (make-variable-buffer-local 'c-auto-hungry-string)
217
218 ;; Non-nil means K&R style argument declarations are valid.
219 (defvar c-recognize-knr-p t)
220 (make-variable-buffer-local 'c-recognize-knr-p)
221
222
223 \f
224 (defun c-common-init ()
225 ;; Common initializations for all modes.
226 ;; these variables should always be buffer local; they do not affect
227 ;; indentation style.
228 (make-local-variable 'paragraph-start)
229 (make-local-variable 'paragraph-separate)
230 (make-local-variable 'paragraph-ignore-fill-prefix)
231 (make-local-variable 'require-final-newline)
232 (make-local-variable 'parse-sexp-ignore-comments)
233 (make-local-variable 'indent-line-function)
234 (make-local-variable 'indent-region-function)
235 (make-local-variable 'comment-start)
236 (make-local-variable 'comment-end)
237 (make-local-variable 'comment-column)
238 (make-local-variable 'comment-start-skip)
239 (make-local-variable 'comment-multi-line)
240 (make-local-variable 'outline-regexp)
241 (make-local-variable 'outline-level)
242 (make-local-variable 'adaptive-fill-regexp)
243 (make-local-variable 'adaptive-fill-mode)
244 (make-local-variable 'imenu-generic-expression) ;set in the mode functions
245 ;; X/Emacs 20 only
246 (and (boundp 'comment-line-break-function)
247 (make-local-variable 'comment-line-break-function))
248 ;; Emacs 19.30 and beyond only, AFAIK
249 (if (boundp 'fill-paragraph-function)
250 (progn
251 (make-local-variable 'fill-paragraph-function)
252 (setq fill-paragraph-function 'c-fill-paragraph)))
253 ;; now set their values
254 (setq paragraph-start (concat page-delimiter "\\|$")
255 paragraph-separate paragraph-start
256 paragraph-ignore-fill-prefix t
257 require-final-newline t
258 parse-sexp-ignore-comments t
259 indent-line-function 'c-indent-line
260 indent-region-function 'c-indent-region
261 outline-regexp "[^#\n\^M]"
262 outline-level 'c-outline-level
263 comment-column 32
264 comment-start-skip "/\\*+ *\\|// *"
265 comment-multi-line nil
266 comment-line-break-function 'c-comment-line-break-function
267 adaptive-fill-regexp nil
268 adaptive-fill-mode nil)
269 ;; we have to do something special for c-offsets-alist so that the
270 ;; buffer local value has its own alist structure.
271 (setq c-offsets-alist (copy-alist c-offsets-alist))
272 ;; setup the comment indent variable in a Emacs version portable way
273 ;; ignore any byte compiler warnings you might get here
274 (make-local-variable 'comment-indent-function)
275 (setq comment-indent-function 'c-comment-indent)
276 ;; add menus to menubar
277 (easy-menu-add (c-mode-menu mode-name))
278 ;; put auto-hungry designators onto minor-mode-alist, but only once
279 (or (assq 'c-auto-hungry-string minor-mode-alist)
280 (setq minor-mode-alist
281 (cons '(c-auto-hungry-string c-auto-hungry-string)
282 minor-mode-alist)))
283 ;; now set the mode style based on c-default-style
284 (c-set-style (if (stringp c-default-style)
285 (if (c-major-mode-is 'java-mode)
286 "java"
287 c-default-style)
288 (or (cdr (assq major-mode c-default-style))
289 (cdr (assq 'other c-default-style))
290 "gnu")))
291 )
292
293
294 (defun c-postprocess-file-styles ()
295 "Function that post processes relevant file local variables.
296 Currently, this function simply applies any style and offset settings
297 found in the file's Local Variable list. It first applies any style
298 setting found in `c-file-style', then it applies any offset settings
299 it finds in `c-file-offsets'.
300
301 Note that the style variables are always made local to the buffer."
302 ;; apply file styles and offsets
303 (if (or c-file-style c-file-offsets)
304 (c-make-styles-buffer-local t))
305 (and c-file-style
306 (c-set-style c-file-style))
307 (and c-file-offsets
308 (mapcar
309 (function
310 (lambda (langentry)
311 (let ((langelem (car langentry))
312 (offset (cdr langentry)))
313 (c-set-offset langelem offset)
314 )))
315 c-file-offsets)))
316
317 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
318
319 \f
320 (defvar c-mode-base-map ()
321 "Keymap shared by all CC Mode related modes.")
322
323 ;; Common routines
324 (defun c-make-inherited-keymap ()
325 (let ((map (make-sparse-keymap)))
326 (cond
327 ;; XEmacs 19 & 20
328 ((fboundp 'set-keymap-parents)
329 (set-keymap-parents map c-mode-base-map))
330 ;; Emacs 19
331 ((fboundp 'set-keymap-parent)
332 (set-keymap-parent map c-mode-base-map))
333 ;; incompatible
334 (t (error "CC Mode is incompatible with this version of Emacs")))
335 map))
336
337 (defun c-populate-syntax-table (table)
338 ;; Populate the syntax TABLE
339 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
340 (modify-syntax-entry ?_ "_" table)
341 (modify-syntax-entry ?\\ "\\" table)
342 (modify-syntax-entry ?+ "." table)
343 (modify-syntax-entry ?- "." table)
344 (modify-syntax-entry ?= "." table)
345 (modify-syntax-entry ?% "." table)
346 (modify-syntax-entry ?< "." table)
347 (modify-syntax-entry ?> "." table)
348 (modify-syntax-entry ?& "." table)
349 (modify-syntax-entry ?| "." table)
350 (modify-syntax-entry ?\' "\"" table)
351 ;; Set up block and line oriented comments. The new C standard
352 ;; mandates both comment styles even in C, so since all languages
353 ;; now require dual comments, we make this the default.
354 (cond
355 ;; XEmacs 19 & 20
356 ((memq '8-bit c-emacs-features)
357 (modify-syntax-entry ?/ ". 1456" table)
358 (modify-syntax-entry ?* ". 23" table))
359 ;; Emacs 19 & 20
360 ((memq '1-bit c-emacs-features)
361 (modify-syntax-entry ?/ ". 124b" table)
362 (modify-syntax-entry ?* ". 23" table))
363 ;; incompatible
364 (t (error "CC Mode is incompatible with this version of Emacs"))
365 )
366 (modify-syntax-entry ?\n "> b" table)
367 ;; Give CR the same syntax as newline, for selective-display
368 (modify-syntax-entry ?\^m "> b" table))
369
370
371 (if c-mode-base-map
372 nil
373 ;; TBD: should we even worry about naming this keymap. My vote: no,
374 ;; because Emacs and XEmacs do it differently.
375 (setq c-mode-base-map (make-sparse-keymap))
376 ;; put standard keybindings into MAP
377 ;; the following mappings correspond more or less directly to BOCM
378 (define-key c-mode-base-map "{" 'c-electric-brace)
379 (define-key c-mode-base-map "}" 'c-electric-brace)
380 (define-key c-mode-base-map ";" 'c-electric-semi&comma)
381 (define-key c-mode-base-map "#" 'c-electric-pound)
382 (define-key c-mode-base-map ":" 'c-electric-colon)
383 (define-key c-mode-base-map "(" 'c-electric-paren)
384 (define-key c-mode-base-map ")" 'c-electric-paren)
385 ;; Separate M-BS from C-M-h. The former should remain
386 ;; backward-kill-word.
387 (define-key c-mode-base-map [(control meta h)] 'c-mark-function)
388 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp)
389 (define-key c-mode-base-map "\ea" 'c-beginning-of-statement)
390 (define-key c-mode-base-map "\ee" 'c-end-of-statement)
391 ;; RMS says don't make these the default.
392 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun)
393 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun)
394 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
395 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
396 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
397 (define-key c-mode-base-map "\t" 'c-indent-command)
398 ;; Caution! Enter here at your own risk. We are trying to support
399 ;; several behaviors and it gets disgusting. :-(
400 ;;
401 ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind
402 ;; backwards deletion behavior to DEL, which both Delete and
403 ;; Backspace get translated to. There's no way to separate this
404 ;; behavior in a clean way, so deal with it! Besides, it's been
405 ;; this way since the dawn of BOCM.
406 (if (not (boundp 'delete-key-deletes-forward))
407 (define-key c-mode-base-map "\177" 'c-electric-backspace)
408 ;; However, XEmacs 20 actually achieved enlightenment. It is
409 ;; possible to sanely define both backward and forward deletion
410 ;; behavior under X separately (TTYs are forever beyond hope, but
411 ;; who cares? XEmacs 20 does the right thing with these too).
412 (define-key c-mode-base-map [delete] 'c-electric-delete)
413 (define-key c-mode-base-map [backspace] 'c-electric-backspace))
414 ;; these are new keybindings, with no counterpart to BOCM
415 (define-key c-mode-base-map "," 'c-electric-semi&comma)
416 (define-key c-mode-base-map "*" 'c-electric-star)
417 (define-key c-mode-base-map "/" 'c-electric-slash)
418 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
419 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
420 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature
421 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state)
422 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report)
423 (define-key c-mode-base-map "\C-c\C-c" 'comment-region)
424 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state)
425 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
426 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
427 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state)
428 (define-key c-mode-base-map "\C-c." 'c-set-style)
429 ;; conflicts with OOBR
430 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
431 )
432
433 ;; menu support for both XEmacs and Emacs. If you don't have easymenu
434 ;; with your version of Emacs, you are incompatible!
435 (require 'easymenu)
436
437 (defvar c-c-menu nil)
438 (defvar c-c++-menu nil)
439 (defvar c-objc-menu nil)
440 (defvar c-java-menu nil)
441 (defvar c-pike-menu nil)
442
443 (defun c-mode-menu (modestr)
444 (let ((m
445 '(["Comment Out Region" comment-region (c-region-is-active-p)]
446 ["Uncomment Region"
447 (comment-region (region-beginning) (region-end) '(4))
448 (c-region-is-active-p)]
449 ["Fill Comment Paragraph" c-fill-paragraph t]
450 "---"
451 ["Indent Expression" c-indent-exp
452 (memq (char-after) '(?\( ?\[ ?\{))]
453 ["Indent Line or Region" c-indent-line-or-region t]
454 ["Up Conditional" c-up-conditional t]
455 ["Backward Conditional" c-backward-conditional t]
456 ["Forward Conditional" c-forward-conditional t]
457 ["Backward Statement" c-beginning-of-statement t]
458 ["Forward Statement" c-end-of-statement t]
459 "---"
460 ["Macro Expand Region" c-macro-expand (c-region-is-active-p)]
461 ["Backslashify" c-backslash-region (c-region-is-active-p)]
462 )))
463 (cons modestr m)))
464
465
466 \f
467 ;; Support for C
468
469 (defvar c-mode-abbrev-table nil
470 "Abbreviation table used in c-mode buffers.")
471 (define-abbrev-table 'c-mode-abbrev-table ())
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 )
481
482 ;;;###autoload
483 (defvar c-mode-syntax-table nil
484 "Syntax table used in c-mode buffers.")
485 (if c-mode-syntax-table
486 ()
487 (setq c-mode-syntax-table (make-syntax-table))
488 (c-populate-syntax-table c-mode-syntax-table))
489
490 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
491 (c-mode-menu "C"))
492
493 \f
494 ;; Support for C++
495
496 (defvar c++-mode-abbrev-table nil
497 "Abbreviation table used in c++-mode buffers.")
498 (define-abbrev-table 'c++-mode-abbrev-table ())
499
500 (defvar c++-mode-map ()
501 "Keymap used in c++-mode buffers.")
502 (if c++-mode-map
503 nil
504 (setq c++-mode-map (c-make-inherited-keymap))
505 ;; add bindings which are only useful for C++
506 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
507 (define-key c++-mode-map "\C-c:" 'c-scope-operator)
508 (define-key c++-mode-map "<" 'c-electric-lt-gt)
509 (define-key c++-mode-map ">" 'c-electric-lt-gt))
510
511 ;;;###autoload
512 (defvar c++-mode-syntax-table nil
513 "Syntax table used in c++-mode buffers.")
514 (if c++-mode-syntax-table
515 ()
516 (setq c++-mode-syntax-table (make-syntax-table))
517 (c-populate-syntax-table c++-mode-syntax-table)
518 ;; TBD: does it make sense for colon to be symbol class in C++?
519 ;; I'm not so sure, since c-label-key is busted on lines like:
520 ;; Foo::bar( i );
521 ;; maybe c-label-key should be fixed instead of commenting this out,
522 ;; but it also bothers me that this only seems appropriate for C++
523 ;; and not C.
524 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
525 )
526
527 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
528 (c-mode-menu "C++"))
529
530 \f
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
537 (defvar objc-mode-map ()
538 "Keymap used in objc-mode buffers.")
539 (if objc-mode-map
540 nil
541 (setq objc-mode-map (c-make-inherited-keymap))
542 ;; add bindings which are only useful for Objective-C
543 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
544
545 ;;;###autoload
546 (defvar objc-mode-syntax-table nil
547 "Syntax table used in objc-mode buffers.")
548 (if objc-mode-syntax-table
549 ()
550 (setq objc-mode-syntax-table (make-syntax-table))
551 (c-populate-syntax-table objc-mode-syntax-table)
552 ;; add extra Objective-C only syntax
553 (modify-syntax-entry ?@ "_" objc-mode-syntax-table))
554
555 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
556 (c-mode-menu "ObjC"))
557
558 \f
559 ;; Support for Java
560
561 (defvar java-mode-abbrev-table nil
562 "Abbreviation table used in java-mode buffers.")
563 (define-abbrev-table 'java-mode-abbrev-table ())
564
565 (defvar java-mode-map ()
566 "Keymap used in java-mode buffers.")
567 (if java-mode-map
568 nil
569 (setq java-mode-map (c-make-inherited-keymap))
570 ;; add bindings which are only useful for Java
571 )
572
573 ;;;###autoload
574 (defvar java-mode-syntax-table nil
575 "Syntax table used in java-mode buffers.")
576 (if java-mode-syntax-table
577 ()
578 (setq java-mode-syntax-table (make-syntax-table))
579 (c-populate-syntax-table java-mode-syntax-table))
580
581 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
582 (c-mode-menu "Java"))
583
584 \f
585 ;; Support for CORBA's IDL language
586
587 (defvar idl-mode-abbrev-table nil
588 "Abbreviation table used in idl-mode buffers.")
589 (define-abbrev-table 'idl-mode-abbrev-table ())
590
591 (defvar idl-mode-map ()
592 "Keymap used in idl-mode buffers.")
593 (if idl-mode-map
594 nil
595 (setq idl-mode-map (c-make-inherited-keymap))
596 ;; add bindings which are only useful for IDL
597 )
598
599 ;;;###autoload
600 (defvar idl-mode-syntax-table nil
601 "Syntax table used in idl-mode buffers.")
602 (if idl-mode-syntax-table
603 nil
604 (setq idl-mode-syntax-table (make-syntax-table))
605 (c-populate-syntax-table idl-mode-syntax-table))
606
607 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
608 (c-mode-menu "IDL"))
609
610 \f
611 ;; Support for Pike
612
613 (defvar pike-mode-abbrev-table nil
614 "Abbreviation table used in pike-mode buffers.")
615 (define-abbrev-table 'pike-mode-abbrev-table ())
616
617 (defvar pike-mode-map ()
618 "Keymap used in pike-mode buffers.")
619 (if pike-mode-map
620 nil
621 (setq pike-mode-map (c-make-inherited-keymap))
622 ;; additional bindings
623 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
624
625 ;;;###autoload
626 (defvar pike-mode-syntax-table nil
627 "Syntax table used in pike-mode buffers.")
628 (if pike-mode-syntax-table
629 ()
630 (setq pike-mode-syntax-table (make-syntax-table))
631 (c-populate-syntax-table pike-mode-syntax-table)
632 (modify-syntax-entry ?@ "." pike-mode-syntax-table))
633
634 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
635 (c-mode-menu "Pike"))
636
637
638 \f
639 (provide 'cc-langs)
640 ;;; cc-langs.el ends here