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