Mercurial > emacs
annotate lisp/progmodes/cc-mode.el @ 19221:d125603385f7
(cyrillic-language-alist): Fix punctuation.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 08 Aug 1997 06:40:52 +0000 |
parents | dd7615d21a97 |
children | 2bda7e07f25d |
rev | line source |
---|---|
18720 | 1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code |
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: a long, long, time ago. adapted from the original c-mode.el | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
10 ;; Version: 5.13 |
18720 | 11 ;; Keywords: c languages oop |
12 | |
13 ;; NOTE: Read the commentary below for the right way to submit bug reports! | |
14 ;; NOTE: See the accompanying texinfo manual for details on using this mode! | |
15 | |
16 ;; This file is part of GNU Emacs. | |
17 | |
18 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
19 ;; it under the terms of the GNU General Public License as published by | |
20 ;; the Free Software Foundation; either version 2, or (at your option) | |
21 ;; any later version. | |
22 | |
23 ;; GNU Emacs is distributed in the hope that it will be useful, | |
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 ;; GNU General Public License for more details. | |
27 | |
28 ;; You should have received a copy of the GNU General Public License | |
29 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
30 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
31 ;; Boston, MA 02111-1307, USA. | |
32 | |
33 ;;; Commentary: | |
34 | |
35 ;; This package provides GNU Emacs major modes for editing C, C++, | |
36 ;; Objective-C, and Java code. As of the latest Emacs and XEmacs | |
37 ;; releases, it is the default package for editing these languages. | |
38 ;; This package is called "CC Mode", and should be spelled exactly | |
39 ;; this way. It supports K&R and ANSI C, ANSI C++, Objective-C, and | |
40 ;; Java, with a consistent indentation model across all modes. This | |
41 ;; indentation model is intuitive and very flexible, so that almost | |
42 ;; any desired style of indentation can be supported. Installation, | |
43 ;; usage, and programming details are contained in an accompanying | |
44 ;; texinfo manual. | |
45 | |
46 ;; CC Mode's immediate ancestors were, c++-mode.el, cplus-md.el, and | |
47 ;; cplus-md1.el.. | |
48 | |
49 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic | |
50 ;; coloring, keyword highlighting, etc.) for any of the supported | |
51 ;; modes. Typically this is done by a package called font-lock.el | |
52 ;; which I do *not* maintain. You should contact the Emacs | |
53 ;; maintainers for questions about coloring or highlighting in any | |
54 ;; language mode. | |
55 | |
56 ;; To submit bug reports, type "C-c C-b". These will be sent to | |
57 ;; bug-gnu-emacs@prep.ai.mit.edu as well as cc-mode-help@python.org, | |
58 ;; and I'll read about them there (the former is mirrored as the | |
59 ;; Usenet newsgroup gnu.emacs.bug). Questions can sent to | |
60 ;; help-gnu-emacs@prep.ai.mit.edu (mirrored as gnu.emacs.help) and/or | |
61 ;; cc-mode-help@python.org. Please do not send bugs or questions to | |
62 ;; my personal account. | |
63 | |
64 ;; YOU CAN IGNORE ALL BYTE-COMPILER WARNINGS. They are the result of | |
65 ;; the cross-Emacsen support. GNU Emacs 19 (from the FSF), GNU XEmacs | |
66 ;; 19 (formerly Lucid Emacs), and GNU Emacs 18 all do things | |
67 ;; differently and there's no way to shut the byte-compiler up at the | |
68 ;; necessary granularity. Let me say this again: YOU CAN IGNORE ALL | |
69 ;; BYTE-COMPILER WARNINGS (you'd be surprised at how many people don't | |
70 ;; follow this advice :-). | |
71 | |
72 ;; Many, many thanks go out to all the folks on the beta test list. | |
73 ;; Without their patience, testing, insight, code contributions, and | |
74 ;; encouragement CC Mode would be a far inferior package. | |
75 | |
76 ;; You can get the latest version of CC Mode, including PostScript | |
77 ;; documentation and separate individual files from: | |
78 ;; | |
79 ;; http://www.python.org/ftp/emacs/ | |
80 | |
81 ;; Or if you don't have access to the World Wide Web, through | |
82 ;; anonymous ftp from: | |
83 ;; | |
84 ;; ftp://ftp.python.org/pub/emacs | |
85 | |
86 ;;; Code: | |
87 | |
88 (eval-when-compile | |
89 (require 'cc-menus)) | |
90 (require 'cc-defs) | |
91 | |
92 | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
93 ;; Other modes and packages which depend on CC Mode should do the |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
94 ;; following to make sure everything is loaded and available for their |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
95 ;; use: |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
96 ;; |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
97 ;; (require 'cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
98 ;; (c-initialize-cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
99 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
100 (defun c-initialize-cc-mode () |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
101 ;; make sure all necessary components of CC Mode are loaded in. |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
102 (require 'cc-vars) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
103 (require 'cc-engine) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
104 (require 'cc-langs) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
105 (require 'cc-menus) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
106 (require 'cc-align) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
107 (require 'cc-styles) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
108 (require 'cc-cmds)) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
109 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
110 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
111 |
18720 | 112 ;;;###autoload |
113 (defun c-mode () | |
114 "Major mode for editing K&R and ANSI C code. | |
115 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
116 c-mode buffer. This automatically sets up a mail buffer with version | |
117 information already added. You just need to add a description of the | |
118 problem, including a reproducible test case and send the message. | |
119 | |
120 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
121 | |
122 The hook variable `c-mode-hook' is run with no args, if that value is | |
123 bound and has a non-nil value. Also the hook `c-mode-common-hook' is | |
124 run first. | |
125 | |
126 Key bindings: | |
127 \\{c-mode-map}" | |
128 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
129 (c-initialize-cc-mode) |
18720 | 130 (kill-all-local-variables) |
131 (set-syntax-table c-mode-syntax-table) | |
132 (setq major-mode 'c-mode | |
133 mode-name "C" | |
134 local-abbrev-table c-mode-abbrev-table) | |
135 (use-local-map c-mode-map) | |
136 (c-common-init) | |
137 (setq comment-start "/* " | |
138 comment-end " */" | |
139 comment-multi-line t | |
140 c-conditional-key c-C-conditional-key | |
141 c-class-key c-C-class-key | |
142 c-baseclass-key nil | |
143 c-comment-start-regexp c-C-comment-start-regexp | |
144 imenu-generic-expression cc-imenu-c-generic-expression) | |
145 (run-hooks 'c-mode-common-hook) | |
146 (run-hooks 'c-mode-hook) | |
147 (c-update-modeline)) | |
148 | |
149 | |
150 ;;;###autoload | |
151 (defun c++-mode () | |
152 "Major mode for editing C++ code. | |
153 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
154 c++-mode buffer. This automatically sets up a mail buffer with | |
155 version information already added. You just need to add a description | |
156 of the problem, including a reproducible test case, and send the | |
157 message. | |
158 | |
159 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
160 | |
161 The hook variable `c++-mode-hook' is run with no args, if that | |
162 variable is bound and has a non-nil value. Also the hook | |
163 `c-mode-common-hook' is run first. | |
164 | |
165 Key bindings: | |
166 \\{c++-mode-map}" | |
167 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
168 (c-initialize-cc-mode) |
18720 | 169 (kill-all-local-variables) |
170 (set-syntax-table c++-mode-syntax-table) | |
171 (setq major-mode 'c++-mode | |
172 mode-name "C++" | |
173 local-abbrev-table c++-mode-abbrev-table) | |
174 (use-local-map c++-mode-map) | |
175 (c-common-init) | |
176 (setq comment-start "// " | |
177 comment-end "" | |
178 comment-multi-line nil | |
179 c-conditional-key c-C++-conditional-key | |
180 c-comment-start-regexp c-C++-comment-start-regexp | |
181 c-class-key c-C++-class-key | |
182 c-access-key c-C++-access-key | |
183 c-double-slash-is-comments-p t | |
184 c-recognize-knr-p nil | |
185 imenu-generic-expression cc-imenu-c++-generic-expression) | |
186 (run-hooks 'c-mode-common-hook) | |
187 (run-hooks 'c++-mode-hook) | |
188 (c-update-modeline)) | |
189 | |
190 | |
191 ;;;###autoload | |
192 (defun objc-mode () | |
193 "Major mode for editing Objective C code. | |
194 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
195 objc-mode buffer. This automatically sets up a mail buffer with | |
196 version information already added. You just need to add a description | |
197 of the problem, including a reproducible test case, and send the | |
198 message. | |
199 | |
200 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
201 | |
202 The hook variable `objc-mode-hook' is run with no args, if that value | |
203 is bound and has a non-nil value. Also the hook `c-mode-common-hook' | |
204 is run first. | |
205 | |
206 Key bindings: | |
207 \\{objc-mode-map}" | |
208 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
209 (c-initialize-cc-mode) |
18720 | 210 (kill-all-local-variables) |
211 (set-syntax-table objc-mode-syntax-table) | |
212 (setq major-mode 'objc-mode | |
213 mode-name "ObjC" | |
214 local-abbrev-table objc-mode-abbrev-table) | |
215 (use-local-map objc-mode-map) | |
216 (c-common-init) | |
217 (setq comment-start "// " | |
218 comment-end "" | |
219 comment-multi-line nil | |
220 c-conditional-key c-C-conditional-key | |
221 c-comment-start-regexp c-C++-comment-start-regexp | |
222 c-class-key c-ObjC-class-key | |
223 c-baseclass-key nil | |
224 c-access-key c-ObjC-access-key | |
225 c-double-slash-is-comments-p t | |
226 c-method-key c-ObjC-method-key) | |
227 (run-hooks 'c-mode-common-hook) | |
228 (run-hooks 'objc-mode-hook) | |
229 (c-update-modeline)) | |
230 | |
231 | |
232 ;;;###autoload | |
233 (defun java-mode () | |
234 "Major mode for editing Java code. | |
235 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
236 java-mode buffer. This automatically sets up a mail buffer with | |
237 version information already added. You just need to add a description | |
238 of the problem, including a reproducible test case and send the | |
239 message. | |
240 | |
241 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
242 | |
243 The hook variable `java-mode-hook' is run with no args, if that value | |
244 is bound and has a non-nil value. Also the common hook | |
245 `c-mode-common-hook' is run first. Note that this mode automatically | |
246 sets the \"java\" style before calling any hooks so be careful if you | |
247 set styles in `c-mode-common-hook'. | |
248 | |
249 Key bindings: | |
250 \\{java-mode-map}" | |
251 (interactive) | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
252 (c-initialize-cc-mode) |
18720 | 253 (kill-all-local-variables) |
254 (set-syntax-table java-mode-syntax-table) | |
255 (setq major-mode 'java-mode | |
256 mode-name "Java" | |
257 local-abbrev-table java-mode-abbrev-table) | |
258 (use-local-map java-mode-map) | |
259 (c-common-init) | |
260 (setq comment-start "// " | |
261 comment-end "" | |
262 comment-multi-line nil | |
263 c-conditional-key c-Java-conditional-key | |
264 c-comment-start-regexp c-Java-comment-start-regexp | |
265 c-class-key c-Java-class-key | |
266 c-method-key c-Java-method-key | |
267 c-double-slash-is-comments-p t | |
268 c-baseclass-key nil | |
269 c-recognize-knr-p nil | |
270 c-access-key c-Java-access-key | |
271 ;defun-prompt-regexp c-Java-defun-prompt-regexp | |
272 imenu-generic-expression cc-imenu-java-generic-expression | |
273 ) | |
274 (c-set-style "java") | |
275 (run-hooks 'c-mode-common-hook) | |
276 (run-hooks 'java-mode-hook) | |
277 (c-update-modeline)) | |
278 | |
279 | |
280 ;; defuns for submitting bug reports | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
281 (defconst c-version "5.13" |
18720 | 282 "CC Mode version number.") |
283 | |
284 (defconst c-mode-help-address | |
285 "bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org" | |
286 "Address for CC Mode bug reports.") | |
287 | |
288 (defun c-version () | |
289 "Echo the current version of CC Mode in the minibuffer." | |
290 (interactive) | |
291 (message "Using CC Mode version %s" c-version) | |
292 (c-keep-region-active)) | |
293 | |
294 ;; Get reporter-submit-bug-report when byte-compiling | |
295 (eval-when-compile | |
296 (require 'reporter)) | |
297 | |
298 (defun c-submit-bug-report () | |
299 "Submit via mail a bug report on CC Mode." | |
300 (interactive) | |
301 (require 'cc-vars) | |
302 ;; load in reporter | |
303 (let ((reporter-prompt-for-summary-p t) | |
304 (reporter-dont-compact-list '(c-offsets-alist)) | |
305 (style c-indentation-style) | |
306 (hook c-special-indent-hook) | |
307 (c-features c-emacs-features)) | |
308 (and | |
309 (if (y-or-n-p "Do you want to submit a report on CC Mode? ") | |
310 t (message "") nil) | |
311 (require 'reporter) | |
312 (reporter-submit-bug-report | |
313 c-mode-help-address | |
314 (concat "CC Mode " c-version " (" | |
315 (cond ((eq major-mode 'c++-mode) "C++") | |
316 ((eq major-mode 'c-mode) "C") | |
317 ((eq major-mode 'objc-mode) "ObjC") | |
318 ((eq major-mode 'java-mode) "Java") | |
319 ) | |
320 ")") | |
321 (let ((vars (list | |
322 ;; report only the vars that affect indentation | |
323 'c-basic-offset | |
324 'c-offsets-alist | |
325 'c-cleanup-list | |
326 'c-comment-only-line-offset | |
327 'c-backslash-column | |
328 'c-delete-function | |
329 'c-electric-pound-behavior | |
330 'c-hanging-braces-alist | |
331 'c-hanging-colons-alist | |
332 'c-hanging-comment-starter-p | |
333 'c-hanging-comment-ender-p | |
334 'c-indent-comments-syntactically-p | |
335 'c-tab-always-indent | |
336 'c-recognize-knr-p | |
337 'c-label-minimum-indentation | |
338 'defun-prompt-regexp | |
339 'tab-width | |
340 ))) | |
341 (if (not (boundp 'defun-prompt-regexp)) | |
342 (delq 'defun-prompt-regexp vars) | |
343 vars)) | |
344 (function | |
345 (lambda () | |
346 (insert | |
347 "Buffer Style: " style "\n\n" | |
348 (if hook | |
349 (concat "\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n" | |
350 "c-special-indent-hook is set to '" | |
351 (format "%s" hook) | |
352 ".\nPerhaps this is your problem?\n" | |
353 "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n") | |
354 "\n") | |
355 (format "c-emacs-features: %s\n" c-features) | |
356 ))) | |
357 nil | |
358 "Dear Barry," | |
359 )))) | |
360 | |
361 | |
362 (provide 'cc-mode) | |
363 ;;; cc-mode.el ends here |