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