Mercurial > emacs
annotate lisp/progmodes/cc-langs.el @ 25774:ccc7f2d178dd
("turkish-latin-3-alt-postfix"): Renamed from
turkish-postfix.
("turkish-postfix"): New Turkish input method which inserts
Latin-5 characters.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 20 Sep 1999 02:11:10 +0000 |
parents | 5b0864259a4b |
children | 03befb219d03 |
rev | line source |
---|---|
18720 | 1 ;;; cc-langs.el --- specific language support for CC Mode |
2 | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc. |
18720 | 4 |
24282 | 5 ;; Authors: 1998 Barry A. Warsaw and Martin Stjernholm |
6 ;; 1992-1997 Barry A. Warsaw | |
18720 | 7 ;; 1987 Dave Detlefs and Stewart Clamen |
8 ;; 1985 Richard M. Stallman | |
24282 | 9 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 10 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20141 | 11 ;; Version: See cc-mode.el |
18720 | 12 ;; Keywords: c languages oop |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 ;; Boston, MA 02111-1307, USA. | |
30 | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
31 |
18720 | 32 |
24282 | 33 (eval-when-compile |
34 (require 'cc-defs)) | |
18772 | 35 |
18720 | 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 | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
42 ;; Regex describing a `symbol' in all languages. We cannot use just |
18720 | 43 ;; `word' syntax class since `_' cannot be in word class. Putting |
44 ;; underscore in word class breaks forward word movement behavior that | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
45 ;; users are familiar with. Besides, this runs counter to Emacs |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
46 ;; convention. |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
47 ;; |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
48 ;; I suspect this definition isn't correct in light of Java's |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
49 ;; definition of a symbol as being Unicode. I know so little about |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
50 ;; I18N (except how to sound cool and say I18N :-) that I'm willing to |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
51 ;; punt on this for now. |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
52 |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
53 (defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*") |
18720 | 54 |
55 | |
56 ;; keywords introducing class definitions. language specific | |
57 (defconst c-C-class-key "\\(struct\\|union\\)") | |
58 (defconst c-C++-class-key "\\(class\\|struct\\|union\\)") | |
24282 | 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\\)") | |
18720 | 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 | |
24282 | 77 "\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass |
18720 | 78 ;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list |
79 )) | |
80 | |
24282 | 81 (defconst c-Pike-class-key "class") |
82 | |
18720 | 83 (defvar c-class-key c-C-class-key) |
84 (make-variable-buffer-local 'c-class-key) | |
85 | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
86 (defvar c-extra-toplevel-key c-C-extra-toplevel-key) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
87 (make-variable-buffer-local 'c-extra-toplevel-key) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
88 |
18720 | 89 |
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) | |
24282 | 96 (defconst c-Pike-access-key nil) |
18720 | 97 |
98 | |
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) | |
24282 | 103 (defconst c-Pike-conditional-key nil) |
18720 | 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) | |
24282 | 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))) | |
18720 | 114 |
115 (defvar c-conditional-key c-C-conditional-key) | |
116 (make-variable-buffer-local 'c-conditional-key) | |
117 | |
118 | |
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 | |
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 "/\\(/\\|[*][*]?\\)") | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
138 (defvar c-comment-start-regexp c-C++-comment-start-regexp) |
18720 | 139 (make-variable-buffer-local 'c-comment-start-regexp) |
140 | |
141 | |
142 | |
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:;.,{}()=]*\\|\\([_$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 | |
21108
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
174 ;; Regexp describing Javadoc markup that always starts paragraphs. |
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
175 (defconst c-Java-javadoc-paragraph-start |
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
176 "@\\(author\\|exception\\|param\\|return\\|see\\|version\\)") |
e3c68a6888f9
(c-Java-javadoc-paragraph-start): New variable for use in c-fill-paragraph.
Richard M. Stallman <rms@gnu.org>
parents:
20915
diff
changeset
|
177 |
24282 | 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 | |
18720 | 202 |
203 | |
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 | |
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) | |
24282 | 243 (make-local-variable 'adaptive-fill-mode) |
18720 | 244 (make-local-variable 'imenu-generic-expression) ;set in the mode functions |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
245 ;; X/Emacs 20 only |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
246 (and (boundp 'comment-line-break-function) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
247 (make-local-variable 'comment-line-break-function)) |
18720 | 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 "/\\*+ *\\|// *" | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
265 comment-multi-line nil |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
266 comment-line-break-function 'c-comment-line-break-function |
24282 | 267 adaptive-fill-regexp nil |
268 adaptive-fill-mode nil) | |
18720 | 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) | |
24282 | 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 | |
18720 | 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 | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
299 it finds in `c-file-offsets'. |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
300 |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
301 Note that the style variables are always made local to the buffer." |
18720 | 302 ;; apply file styles and offsets |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
303 (if (or c-file-style c-file-offsets) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
304 (c-make-styles-buffer-local t)) |
18720 | 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 | |
24282 | 320 (defvar c-mode-base-map () |
321 "Keymap shared by all CC Mode related modes.") | |
322 | |
18720 | 323 ;; Common routines |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
324 (defun c-make-inherited-keymap () |
18720 | 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) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
350 (modify-syntax-entry ?\' "\"" table) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
351 ;; Set up block and line oriented comments. The new C standard |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
352 ;; mandates both comment styles even in C, so since all languages |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
353 ;; now require dual comments, we make this the default. |
18720 | 354 (cond |
355 ;; XEmacs 19 & 20 | |
356 ((memq '8-bit c-emacs-features) | |
357 (modify-syntax-entry ?/ ". 1456" table) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
358 (modify-syntax-entry ?* ". 23" table)) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
359 ;; Emacs 19 & 20 |
18720 | 360 ((memq '1-bit c-emacs-features) |
361 (modify-syntax-entry ?/ ". 124b" table) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
362 (modify-syntax-entry ?* ". 23" table)) |
18720 | 363 ;; incompatible |
364 (t (error "CC Mode is incompatible with this version of Emacs")) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
365 ) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
366 (modify-syntax-entry ?\n "> b" table) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
367 ;; Give CR the same syntax as newline, for selective-display |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
368 (modify-syntax-entry ?\^m "> b" table)) |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
369 |
18720 | 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) | |
24282 | 383 (define-key c-mode-base-map "(" 'c-electric-paren) |
384 (define-key c-mode-base-map ")" 'c-electric-paren) | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
385 ;; Separate M-BS from C-M-h. The former should remain |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
386 ;; backward-kill-word. |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
387 (define-key c-mode-base-map [(control meta h)] 'c-mark-function) |
18720 | 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) | |
20915
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
391 ;; RMS says don't make these the default. |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
392 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun) |
c746c93c9c95
(c-postprocess-file-styles): If a file style or file offsets are set,
Richard M. Stallman <rms@gnu.org>
parents:
20141
diff
changeset
|
393 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun) |
18720 | 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) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
417 (define-key c-mode-base-map "/" 'c-electric-slash) |
18720 | 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) | |
24282 | 441 (defvar c-pike-menu nil) |
18720 | 442 |
443 (defun c-mode-menu (modestr) | |
444 (let ((m | |
24282 | 445 '(["Comment Out Region" comment-region (c-region-is-active-p)] |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
446 ["Uncomment Region" |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
447 (comment-region (region-beginning) (region-end) '(4)) |
24282 | 448 (c-region-is-active-p)] |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
449 ["Fill Comment Paragraph" c-fill-paragraph t] |
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
450 "---" |
18720 | 451 ["Indent Expression" c-indent-exp |
452 (memq (char-after) '(?\( ?\[ ?\{))] | |
24282 | 453 ["Indent Line or Region" c-indent-line-or-region t] |
18720 | 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] | |
18842
72c2475ece1c
Require 'cc-defs for the definition of c-emacs-features.
Richard M. Stallman <rms@gnu.org>
parents:
18772
diff
changeset
|
459 "---" |
24282 | 460 ["Macro Expand Region" c-macro-expand (c-region-is-active-p)] |
461 ["Backslashify" c-backslash-region (c-region-is-active-p)] | |
18720 | 462 ))) |
463 (cons modestr m))) | |
464 | |
465 | |
466 | |
467 ;; Support for C | |
468 | |
469 (defvar c-mode-abbrev-table nil | |
19250 | 470 "Abbreviation table used in c-mode buffers.") |
18720 | 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 | |
19805
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
479 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) |
18720 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
488 (c-populate-syntax-table c-mode-syntax-table)) |
18720 | 489 |
490 (easy-menu-define c-c-menu c-mode-map "C Mode Commands" | |
491 (c-mode-menu "C")) | |
492 | |
493 | |
494 ;; Support for C++ | |
495 | |
496 (defvar c++-mode-abbrev-table nil | |
19250 | 497 "Abbreviation table used in c++-mode buffers.") |
18720 | 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++ | |
19805
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
506 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand) |
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
507 (define-key c++-mode-map "\C-c:" 'c-scope-operator) |
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
508 (define-key c++-mode-map "<" 'c-electric-lt-gt) |
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
509 (define-key c++-mode-map ">" 'c-electric-lt-gt)) |
18720 | 510 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
511 ;;;###autoload |
18720 | 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 | |
531 ;; Support for Objective-C | |
532 | |
533 (defvar objc-mode-abbrev-table nil | |
19250 | 534 "Abbreviation table used in objc-mode buffers.") |
18720 | 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 | |
19805
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
543 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)) |
18720 | 544 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
545 ;;;###autoload |
18720 | 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) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
552 ;; add extra Objective-C only syntax |
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
553 (modify-syntax-entry ?@ "_" objc-mode-syntax-table)) |
18720 | 554 |
555 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" | |
556 (c-mode-menu "ObjC")) | |
557 | |
558 | |
559 ;; Support for Java | |
560 | |
561 (defvar java-mode-abbrev-table nil | |
19250 | 562 "Abbreviation table used in java-mode buffers.") |
18720 | 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 | |
19805
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
571 ) |
18720 | 572 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
573 ;;;###autoload |
18720 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
579 (c-populate-syntax-table java-mode-syntax-table)) |
18720 | 580 |
581 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands" | |
582 (c-mode-menu "Java")) | |
583 | |
584 | |
19250 | 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)) | |
19805
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
596 ;; add bindings which are only useful for IDL |
e804ac04eec1
(c-mode-base-map): Don't define C-c C-e here.
Richard M. Stallman <rms@gnu.org>
parents:
19381
diff
changeset
|
597 ) |
19250 | 598 |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
599 ;;;###autoload |
19250 | 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)) | |
19300
b07fa43938cc
(c-mode-base-map, c++-mode-map):
Richard M. Stallman <rms@gnu.org>
parents:
19250
diff
changeset
|
605 (c-populate-syntax-table idl-mode-syntax-table)) |
19250 | 606 |
607 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" | |
608 (c-mode-menu "IDL")) | |
609 | |
24282 | 610 |
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 | |
19250 | 637 |
638 | |
18720 | 639 (provide 'cc-langs) |
640 ;;; cc-langs.el ends here |