1 ;;; cc-langs.el --- specific language support for CC Mode
3 ;; Copyright (C) 1985,1987,1992-1999 Free Software Foundation, Inc.
5 ;; Authors: 1998-1999 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
14 ;; This file is part of GNU Emacs.
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)
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.
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.
33 (if (and (boundp 'byte-compile-current-file)
34 (stringp byte-compile-current-file))
35 (cons (file-name-directory byte-compile-current-file)
38 (load "cc-defs" nil t)))
41 ;; Pull in some other packages.
44 ;; Not required and only needed during compilation to shut up
48 ;; menu support for both XEmacs and Emacs. If you don't have easymenu
49 ;; with your version of Emacs, you are incompatible!
53 (defvar c-buffer-is-cc-mode nil
54 "Non-nil for all buffers with a `major-mode' derived from CC Mode.
55 Otherwise, this variable is nil. I.e. this variable is non-nil for
56 `c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode',
57 `pike-mode', and any other non-CC Mode mode that calls
58 `c-initialize-cc-mode' (e.g. `awk-mode').")
59 (make-variable-buffer-local 'c-buffer-is-cc-mode)
60 (put 'c-buffer-is-cc-mode 'permanent-local t)
63 ;; Regular expressions and other values which must be parameterized on
64 ;; a per-language basis.
66 ;; Keywords defining protection levels
67 (defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
69 ;; Regex describing a `symbol' in all languages. We cannot use just
70 ;; `word' syntax class since `_' cannot be in word class. Putting
71 ;; underscore in word class breaks forward word movement behavior that
72 ;; users are familiar with. Besides, this runs counter to Emacs
75 ;; I suspect this definition isn't correct in light of Java's
76 ;; definition of a symbol as being Unicode. I know so little about
77 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to
78 ;; punt on this for now.
80 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*")
83 ;; keywords introducing class definitions. language specific
84 (defconst c-C-class-key "\\(struct\\|union\\)")
85 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)")
86 (defconst c-IDL-class-key "\\(interface\\|struct\\|union\\|valuetype\\)")
87 (defconst c-C-extra-toplevel-key "\\(extern\\)")
88 (defconst c-C++-extra-toplevel-key "\\(extern\\|namespace\\)")
89 (defconst c-IDL-extra-toplevel-key "\\(module\\)")
91 (defconst c-ObjC-class-key
93 "@\\(interface\\|implementation\\)\\s +"
94 c-symbol-key ;name of the class
95 "\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
96 "\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
99 (defconst c-Java-class-key
101 "\\(" c-protection-key "\\s +\\)?"
102 "\\(interface\\|class\\)\\s +"
103 c-symbol-key ;name of the class
104 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
105 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
108 (defconst c-Pike-class-key "class")
110 (defvar c-class-key c-C-class-key)
111 (make-variable-buffer-local 'c-class-key)
113 (defvar c-extra-toplevel-key c-C-extra-toplevel-key)
114 (make-variable-buffer-local 'c-extra-toplevel-key)
116 ;; Keywords that can introduce bitfields in the languages that supports that.
117 (defconst c-C-bitfield-key "\\(char\\|int\\|long\\|signed\\|unsigned\\)")
119 (defvar c-bitfield-key nil)
120 (make-variable-buffer-local 'c-bitfield-key)
123 ;; regexp describing access protection clauses. language specific
124 (defvar c-access-key nil)
125 (make-variable-buffer-local 'c-access-key)
126 (defconst c-C++-access-key (concat c-protection-key "[ \t]*:"))
127 (defconst c-IDL-access-key nil)
128 (defconst c-ObjC-access-key (concat "@" c-protection-key))
129 (defconst c-Java-access-key nil)
130 (defconst c-Pike-access-key nil)
133 ;; keywords introducing conditional blocks
134 (defconst c-C-conditional-key nil)
135 (defconst c-C++-conditional-key nil)
136 (defconst c-IDL-conditional-key nil)
137 (defconst c-ObjC-conditional-key nil)
138 (defconst c-Java-conditional-key nil)
139 (defconst c-Pike-conditional-key nil)
141 (let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
142 (exc-kws "\\|try\\|catch")
143 (thr-kws "\\|finally\\|synchronized")
146 (setq c-C-conditional-key (concat front all-kws back)
147 c-C++-conditional-key (concat front all-kws exc-kws back)
148 ;; c-IDL-conditional-key is nil.
149 c-ObjC-conditional-key c-C-conditional-key
150 c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)
151 c-Pike-conditional-key (concat front all-kws "\\|foreach" back)))
153 (defvar c-conditional-key c-C-conditional-key)
154 (make-variable-buffer-local 'c-conditional-key)
157 ;; keywords describing method definition introductions
158 (defvar c-method-key nil)
159 (make-variable-buffer-local 'c-method-key)
161 (defconst c-ObjC-method-key
164 "\\(([^)]*)\\)?" ; return type
165 ;; \\s- in objc syntax table does not include \n
166 ;; since it is considered the end of //-comments.
167 "[ \t\n]*" c-symbol-key))
171 ;; comment starter definitions for various languages. language specific
172 (defconst c-C++-comment-start-regexp "/[/*]")
173 (defconst c-C-comment-start-regexp c-C++-comment-start-regexp)
174 (defconst c-IDL-comment-start-regexp c-C++-comment-start-regexp)
175 (defconst c-ObjC-comment-start-regexp c-C++-comment-start-regexp)
176 (defconst c-Pike-comment-start-regexp c-C++-comment-start-regexp)
177 ;; We need to match all 3 Java style comments
178 ;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
179 (defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
180 (defvar c-comment-start-regexp c-C++-comment-start-regexp)
181 (make-variable-buffer-local 'c-comment-start-regexp)
185 ;; Regexp describing a switch's case or default label for all languages
186 (defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
187 ;; Regexp describing any label.
188 (defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
190 ;; Regexp describing class inheritance declarations. TBD: this should
191 ;; be language specific, and only makes sense for C++
192 (defconst c-inher-key
193 (concat "\\(\\<static\\>\\s +\\)?"
194 c-C++-class-key "[ \t]+" c-symbol-key
195 "\\([ \t]*:[ \t]*\\)\\s *[^;]"))
197 ;; Regexp describing C++ base classes in a derived class definition.
198 ;; TBD: this should be language specific, and only makes sense for C++
199 (defvar c-baseclass-key
201 ":?[ \t]*\\(virtual[ \t]+\\)?\\("
202 c-protection-key "[ \t]+\\)" c-symbol-key))
203 (make-variable-buffer-local 'c-baseclass-key)
205 ;; Regexp describing friend declarations in C++ classes.
206 (defconst c-C++-friend-key
207 "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
209 ;; Regexp describing Java inheritance and throws clauses.
210 (defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
212 ;; Regexp describing the beginning of a Java top-level definition.
213 (defconst c-Java-defun-prompt-regexp
214 "^[ \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-*")
216 ;; Regexp describing Javadoc markup that always starts paragraphs.
217 (defconst c-Java-javadoc-paragraph-start
218 "@\\(author\\|exception\\|param\\|return\\|see\\|throws\\|version\\)")
220 ;; Regexp that starts lambda constructs.
221 (defvar c-lambda-key nil)
222 (make-variable-buffer-local 'c-lambda-key)
223 (defconst c-Pike-lambda-key "\\<lambda\\>")
225 ;; Regexp that are followed by a statement block in expressions.
226 (defvar c-inexpr-block-key nil)
227 (make-variable-buffer-local 'c-inexpr-block-key)
228 (defconst c-Pike-inexpr-block-key "\\<\\(catch\\|gauge\\)\\>")
230 ;; Regexp that may be followed by an anonymous class in expressions.
231 (defvar c-inexpr-class-key nil)
232 (make-variable-buffer-local 'c-inexpr-class-key)
233 (defconst c-Java-inexpr-class-key "\\<new\\>")
235 ;; List of open- and close-chars that makes up a pike-style brace
236 ;; list, ie for a `([ ])' list there should be a cons (?\[ . ?\]) in
238 (defvar c-special-brace-lists nil)
239 (make-variable-buffer-local 'c-special-brace-lists)
240 (defconst c-Pike-special-brace-lists '((?{ . ?})
246 ;; internal state variables
248 ;; Internal state of hungry delete key feature
249 (defvar c-hungry-delete-key nil)
250 (make-variable-buffer-local 'c-hungry-delete-key)
252 ;; Internal state of auto newline feature.
253 (defvar c-auto-newline nil)
254 (make-variable-buffer-local 'c-auto-newline)
256 ;; Internal auto-newline/hungry-delete designation string for mode line.
257 (defvar c-auto-hungry-string nil)
258 (make-variable-buffer-local 'c-auto-hungry-string)
260 ;; Non-nil means K&R style argument declarations are valid.
261 (defvar c-recognize-knr-p t)
262 (make-variable-buffer-local 'c-recognize-knr-p)
266 (defun c-common-init ()
267 ;; Common initializations for all modes.
268 ;; these variables should always be buffer local; they do not affect
269 ;; indentation style.
270 (make-local-variable 'require-final-newline)
271 (make-local-variable 'parse-sexp-ignore-comments)
272 (make-local-variable 'indent-line-function)
273 (make-local-variable 'indent-region-function)
274 (make-local-variable 'outline-regexp)
275 (make-local-variable 'outline-level)
276 (make-local-variable 'normal-auto-fill-function)
277 (make-local-variable 'comment-start)
278 (make-local-variable 'comment-end)
279 (make-local-variable 'comment-column)
280 (make-local-variable 'comment-start-skip)
281 (make-local-variable 'comment-multi-line)
282 (make-local-variable 'paragraph-start)
283 (make-local-variable 'paragraph-separate)
284 (make-local-variable 'paragraph-ignore-fill-prefix)
285 (make-local-variable 'adaptive-fill-mode)
286 (make-local-variable 'adaptive-fill-regexp)
287 (make-local-variable 'imenu-generic-expression) ;set in the mode functions
289 (and (boundp 'comment-line-break-function)
291 (make-local-variable 'comment-line-break-function)
292 (setq comment-line-break-function
293 'c-indent-new-comment-line)))
294 ;; now set their values
295 (setq require-final-newline t
296 parse-sexp-ignore-comments t
297 indent-line-function 'c-indent-line
298 indent-region-function 'c-indent-region
299 outline-regexp "[^#\n\^M]"
300 outline-level 'c-outline-level
301 normal-auto-fill-function 'c-do-auto-fill
303 comment-start-skip "/\\*+ *\\|//+ *"
304 comment-multi-line t)
305 ;; now set the mode style based on c-default-style
306 (let ((style (if (stringp c-default-style)
307 (if (c-major-mode-is 'java-mode)
310 (or (cdr (assq major-mode c-default-style))
311 (cdr (assq 'other c-default-style))
313 ;; Override style variables if `c-old-style-variable-behavior' is
314 ;; set. Also override if we are using global style variables,
315 ;; have already initialized a style once, and are switching to a
316 ;; different style. (It's doubtful whether this is desirable, but
317 ;; the whole situation with nonlocal style variables is a bit
318 ;; awkward. It's at least the most compatible way with the old
319 ;; style init procedure.)
320 (c-set-style style (not (or c-old-style-variable-behavior
321 (and (not c-style-variables-are-local-p)
323 (not (string-equal c-indentation-style
325 ;; Fix things up for paragraph recognition and filling inside
326 ;; comments by using c-comment-prefix-regexp in the relevant places.
327 ;; We use adaptive filling for this to make it possible to use
328 ;; filladapt or some other fancy package.
329 (let ((comment-line-prefix
330 (concat "[ \t]*\\(" c-comment-prefix-regexp "\\)?[ \t]*")))
331 (setq paragraph-start (concat comment-line-prefix "$\\|"
333 paragraph-separate paragraph-start
334 paragraph-ignore-fill-prefix t
337 (concat comment-line-prefix
338 (if adaptive-fill-regexp
339 (concat "\\(" adaptive-fill-regexp "\\)")
341 (when (boundp 'adaptive-fill-first-line-regexp)
342 ;; XEmacs (20.x) adaptive fill mode doesn't have this.
343 (make-local-variable 'adaptive-fill-first-line-regexp)
344 (setq adaptive-fill-first-line-regexp
345 (concat "\\`" comment-line-prefix
346 ;; Maybe we should incorporate the old value here,
347 ;; but then we have to do all sorts of kludges to
348 ;; deal with the \` and \' it probably contains.
350 ;; we have to do something special for c-offsets-alist so that the
351 ;; buffer local value has its own alist structure.
352 (setq c-offsets-alist (copy-alist c-offsets-alist))
353 ;; setup the comment indent variable in a Emacs version portable way
354 ;; ignore any byte compiler warnings you might get here
355 (make-local-variable 'comment-indent-function)
356 (setq comment-indent-function 'c-comment-indent)
357 ;; add menus to menubar
358 (easy-menu-add (c-mode-menu mode-name))
359 ;; put auto-hungry designators onto minor-mode-alist, but only once
360 (or (assq 'c-auto-hungry-string minor-mode-alist)
361 (setq minor-mode-alist
362 (cons '(c-auto-hungry-string c-auto-hungry-string)
367 (defun c-postprocess-file-styles ()
368 "Function that post processes relevant file local variables.
369 Currently, this function simply applies any style and offset settings
370 found in the file's Local Variable list. It first applies any style
371 setting found in `c-file-style', then it applies any offset settings
372 it finds in `c-file-offsets'.
374 Note that the style variables are always made local to the buffer."
375 ;; apply file styles and offsets
376 (if (or c-file-style c-file-offsets)
377 (c-make-styles-buffer-local t))
379 (c-set-style c-file-style))
384 (let ((langelem (car langentry))
385 (offset (cdr langentry)))
386 (c-set-offset langelem offset)
390 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
393 (defvar c-mode-base-map ()
394 "Keymap shared by all CC Mode related modes.")
397 (defun c-make-inherited-keymap ()
398 (let ((map (make-sparse-keymap)))
401 ((fboundp 'set-keymap-parents)
402 (set-keymap-parents map c-mode-base-map))
404 ((fboundp 'set-keymap-parent)
405 (set-keymap-parent map c-mode-base-map))
407 (t (error "CC Mode is incompatible with this version of Emacs")))
410 (defun c-populate-syntax-table (table)
411 ;; Populate the syntax TABLE
412 ;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
413 (modify-syntax-entry ?_ "_" table)
414 (modify-syntax-entry ?\\ "\\" table)
415 (modify-syntax-entry ?+ "." table)
416 (modify-syntax-entry ?- "." table)
417 (modify-syntax-entry ?= "." table)
418 (modify-syntax-entry ?% "." table)
419 (modify-syntax-entry ?< "." table)
420 (modify-syntax-entry ?> "." table)
421 (modify-syntax-entry ?& "." table)
422 (modify-syntax-entry ?| "." table)
423 (modify-syntax-entry ?\' "\"" table)
424 ;; Set up block and line oriented comments. The new C standard
425 ;; mandates both comment styles even in C, so since all languages
426 ;; now require dual comments, we make this the default.
429 ((memq '8-bit c-emacs-features)
430 (modify-syntax-entry ?/ ". 1456" table)
431 (modify-syntax-entry ?* ". 23" table))
433 ((memq '1-bit c-emacs-features)
434 (modify-syntax-entry ?/ ". 124b" table)
435 (modify-syntax-entry ?* ". 23" table))
437 (t (error "CC Mode is incompatible with this version of Emacs"))
439 (modify-syntax-entry ?\n "> b" table)
440 ;; Give CR the same syntax as newline, for selective-display
441 (modify-syntax-entry ?\^m "> b" table))
446 ;; TBD: should we even worry about naming this keymap. My vote: no,
447 ;; because Emacs and XEmacs do it differently.
448 (setq c-mode-base-map (make-sparse-keymap))
449 ;; put standard keybindings into MAP
450 ;; the following mappings correspond more or less directly to BOCM
451 (define-key c-mode-base-map "{" 'c-electric-brace)
452 (define-key c-mode-base-map "}" 'c-electric-brace)
453 (define-key c-mode-base-map ";" 'c-electric-semi&comma)
454 (define-key c-mode-base-map "#" 'c-electric-pound)
455 (define-key c-mode-base-map ":" 'c-electric-colon)
456 (define-key c-mode-base-map "(" 'c-electric-paren)
457 (define-key c-mode-base-map ")" 'c-electric-paren)
458 ;; Separate M-BS from C-M-h. The former should remain
459 ;; backward-kill-word.
460 (define-key c-mode-base-map [(control meta h)] 'c-mark-function)
461 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp)
462 (substitute-key-definition 'backward-sentence
463 'c-beginning-of-statement
464 c-mode-base-map global-map)
465 (substitute-key-definition 'forward-sentence
467 c-mode-base-map global-map)
468 (substitute-key-definition 'indent-new-comment-line
469 'c-indent-new-comment-line
470 c-mode-base-map global-map)
471 ;; RMS says don't make these the default.
472 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun)
473 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun)
474 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional)
475 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional)
476 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional)
477 (substitute-key-definition 'indent-for-tab-command
479 c-mode-base-map global-map)
480 ;; It doesn't suffice to put c-fill-paragraph on
481 ;; fill-paragraph-function due to the way it works.
482 (substitute-key-definition 'fill-paragraph 'c-fill-paragraph
483 c-mode-base-map global-map)
484 ;; In XEmacs the default fill function is called
485 ;; fill-paragraph-or-region.
486 (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph
487 c-mode-base-map global-map)
488 ;; Caution! Enter here at your own risk. We are trying to support
489 ;; several behaviors and it gets disgusting. :-(
491 (if (boundp 'delete-key-deletes-forward)
493 ;; In XEmacs 20 it is possible to sanely define both backward
494 ;; and forward deletion behavior under X separately (TTYs are
495 ;; forever beyond hope, but who cares? XEmacs 20 does the
496 ;; right thing with these too).
497 (define-key c-mode-base-map [delete] 'c-electric-delete)
498 (define-key c-mode-base-map [backspace] 'c-electric-backspace))
499 ;; In XEmacs 19, Emacs 19, and Emacs 20, we use this to bind
500 ;; backwards deletion behavior to DEL, which both Delete and
501 ;; Backspace get translated to. There's no way to separate this
502 ;; behavior in a clean way, so deal with it! Besides, it's been
503 ;; this way since the dawn of BOCM.
504 (define-key c-mode-base-map "\177" 'c-electric-backspace))
505 ;; these are new keybindings, with no counterpart to BOCM
506 (define-key c-mode-base-map "," 'c-electric-semi&comma)
507 (define-key c-mode-base-map "*" 'c-electric-star)
508 (define-key c-mode-base-map "/" 'c-electric-slash)
509 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun)
510 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region)
511 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature
512 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state)
513 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report)
514 (define-key c-mode-base-map "\C-c\C-c" 'comment-region)
515 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state)
516 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset)
517 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information)
518 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state)
519 (define-key c-mode-base-map "\C-c." 'c-set-style)
520 ;; conflicts with OOBR
521 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version)
524 (defvar c-c-menu nil)
525 (defvar c-c++-menu nil)
526 (defvar c-objc-menu nil)
527 (defvar c-java-menu nil)
528 (defvar c-pike-menu nil)
530 (defun c-mode-menu (modestr)
532 '(["Comment Out Region" comment-region (c-region-is-active-p)]
534 (comment-region (region-beginning) (region-end) '(4))
535 (c-region-is-active-p)]
536 ["Fill Comment Paragraph" c-fill-paragraph t]
538 ["Indent Expression" c-indent-exp
539 (memq (char-after) '(?\( ?\[ ?\{))]
540 ["Indent Line or Region" c-indent-line-or-region t]
541 ["Up Conditional" c-up-conditional t]
542 ["Backward Conditional" c-backward-conditional t]
543 ["Forward Conditional" c-forward-conditional t]
544 ["Backward Statement" c-beginning-of-statement t]
545 ["Forward Statement" c-end-of-statement t]
547 ["Macro Expand Region" c-macro-expand (c-region-is-active-p)]
548 ["Backslashify" c-backslash-region (c-region-is-active-p)]
556 (defvar c-mode-abbrev-table nil
557 "Abbreviation table used in c-mode buffers.")
558 (define-abbrev-table 'c-mode-abbrev-table ())
560 (defvar c-mode-map ()
561 "Keymap used in c-mode buffers.")
564 (setq c-mode-map (c-make-inherited-keymap))
565 ;; add bindings which are only useful for C
566 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand)
570 (defvar c-mode-syntax-table nil
571 "Syntax table used in c-mode buffers.")
572 (if c-mode-syntax-table
574 (setq c-mode-syntax-table (make-syntax-table))
575 (c-populate-syntax-table c-mode-syntax-table))
577 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
583 (defvar c++-mode-abbrev-table nil
584 "Abbreviation table used in c++-mode buffers.")
585 (define-abbrev-table 'c++-mode-abbrev-table ())
587 (defvar c++-mode-map ()
588 "Keymap used in c++-mode buffers.")
591 (setq c++-mode-map (c-make-inherited-keymap))
592 ;; add bindings which are only useful for C++
593 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
594 (define-key c++-mode-map "\C-c:" 'c-scope-operator)
595 (define-key c++-mode-map "<" 'c-electric-lt-gt)
596 (define-key c++-mode-map ">" 'c-electric-lt-gt))
599 (defvar c++-mode-syntax-table nil
600 "Syntax table used in c++-mode buffers.")
601 (if c++-mode-syntax-table
603 (setq c++-mode-syntax-table (make-syntax-table))
604 (c-populate-syntax-table c++-mode-syntax-table)
605 ;; TBD: does it make sense for colon to be symbol class in C++?
606 ;; I'm not so sure, since c-label-key is busted on lines like:
608 ;; maybe c-label-key should be fixed instead of commenting this out,
609 ;; but it also bothers me that this only seems appropriate for C++
611 ;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
614 (defvar c++-template-syntax-table nil
615 "A variant of `c++-mode-syntax-table' that defines `<' and `>' as
616 parenthesis characters. Used temporarily when template argument lists
618 (if c++-template-syntax-table
620 (setq c++-template-syntax-table
621 (copy-syntax-table c++-mode-syntax-table))
622 (modify-syntax-entry ?< "(>" c++-template-syntax-table)
623 (modify-syntax-entry ?> ")<" c++-template-syntax-table))
625 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
629 ;; Support for Objective-C
631 (defvar objc-mode-abbrev-table nil
632 "Abbreviation table used in objc-mode buffers.")
633 (define-abbrev-table 'objc-mode-abbrev-table ())
635 (defvar objc-mode-map ()
636 "Keymap used in objc-mode buffers.")
639 (setq objc-mode-map (c-make-inherited-keymap))
640 ;; add bindings which are only useful for Objective-C
641 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))
644 (defvar objc-mode-syntax-table nil
645 "Syntax table used in objc-mode buffers.")
646 (if objc-mode-syntax-table
648 (setq objc-mode-syntax-table (make-syntax-table))
649 (c-populate-syntax-table objc-mode-syntax-table)
650 ;; add extra Objective-C only syntax
651 (modify-syntax-entry ?@ "_" objc-mode-syntax-table))
653 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
654 (c-mode-menu "ObjC"))
659 (defvar java-mode-abbrev-table nil
660 "Abbreviation table used in java-mode buffers.")
661 (define-abbrev-table 'java-mode-abbrev-table ())
663 (defvar java-mode-map ()
664 "Keymap used in java-mode buffers.")
667 (setq java-mode-map (c-make-inherited-keymap))
668 ;; add bindings which are only useful for Java
672 (defvar java-mode-syntax-table nil
673 "Syntax table used in java-mode buffers.")
674 (if java-mode-syntax-table
676 (setq java-mode-syntax-table (make-syntax-table))
677 (c-populate-syntax-table java-mode-syntax-table))
679 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
680 (c-mode-menu "Java"))
683 ;; Support for CORBA's IDL language
685 (defvar idl-mode-abbrev-table nil
686 "Abbreviation table used in idl-mode buffers.")
687 (define-abbrev-table 'idl-mode-abbrev-table ())
689 (defvar idl-mode-map ()
690 "Keymap used in idl-mode buffers.")
693 (setq idl-mode-map (c-make-inherited-keymap))
694 ;; add bindings which are only useful for IDL
698 (defvar idl-mode-syntax-table nil
699 "Syntax table used in idl-mode buffers.")
700 (if idl-mode-syntax-table
702 (setq idl-mode-syntax-table (make-syntax-table))
703 (c-populate-syntax-table idl-mode-syntax-table))
705 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
711 (defvar pike-mode-abbrev-table nil
712 "Abbreviation table used in pike-mode buffers.")
713 (define-abbrev-table 'pike-mode-abbrev-table ())
715 (defvar pike-mode-map ()
716 "Keymap used in pike-mode buffers.")
719 (setq pike-mode-map (c-make-inherited-keymap))
720 ;; additional bindings
721 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))
724 (defvar pike-mode-syntax-table nil
725 "Syntax table used in pike-mode buffers.")
726 (if pike-mode-syntax-table
728 (setq pike-mode-syntax-table (make-syntax-table))
729 (c-populate-syntax-table pike-mode-syntax-table)
730 (modify-syntax-entry ?@ "." pike-mode-syntax-table))
732 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
733 (c-mode-menu "Pike"))
738 ;;; cc-langs.el ends here