Mercurial > emacs
annotate lisp/progmodes/cc-mode.el @ 51614:73108f24fe68
(c-mode): Add local variable gud-find-expr.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Wed, 18 Jun 2003 22:34:36 +0000 |
parents | b025ca405045 |
children | a668aa6d6cdc |
rev | line source |
---|---|
18720 | 1 ;;; cc-mode.el --- major mode for editing C, C++, Objective-C, and Java code |
2 | |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 4 |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5 ;; Authors: 2000- Martin Stjernholm |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm |
24282 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: a long, long, time ago. adapted from the original c-mode.el |
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 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
27 ;; along with GNU Emacs; see the file COPYING. If not, write to |
36920 | 28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
31 (defconst c-version "5.29" |
36920 | 32 "CC Mode version number.") |
33 | |
34 ;; NOTE: Read the commentary below for the right way to submit bug reports! | |
35 ;; NOTE: See the accompanying texinfo manual for details on using this mode! | |
36 | |
18720 | 37 ;;; Commentary: |
38 | |
39 ;; This package provides GNU Emacs major modes for editing C, C++, | |
24282 | 40 ;; Objective-C, Java, IDL and Pike code. As of the latest Emacs and |
41 ;; XEmacs releases, it is the default package for editing these | |
42 ;; languages. This package is called "CC Mode", and should be spelled | |
43 ;; exactly this way. | |
44 | |
45 ;; CC Mode supports K&R and ANSI C, ANSI C++, Objective-C, Java, | |
46 ;; CORBA's IDL, and Pike with a consistent indentation model across | |
47 ;; all modes. This indentation model is intuitive and very flexible, | |
48 ;; so that almost any desired style of indentation can be supported. | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
49 ;; Installation, usage, and programming details are contained in an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
50 ;; accompanying texinfo manual. |
18720 | 51 |
52 ;; CC Mode's immediate ancestors were, c++-mode.el, cplus-md.el, and | |
53 ;; cplus-md1.el.. | |
54 | |
55 ;; NOTE: This mode does not perform font-locking (a.k.a syntactic | |
56 ;; coloring, keyword highlighting, etc.) for any of the supported | |
57 ;; modes. Typically this is done by a package called font-lock.el | |
24282 | 58 ;; which we do *not* maintain. You should contact the Emacs or XEmacs |
18720 | 59 ;; maintainers for questions about coloring or highlighting in any |
60 ;; language mode. | |
61 | |
62 ;; To submit bug reports, type "C-c C-b". These will be sent to | |
24282 | 63 ;; bug-gnu-emacs@gnu.org (mirrored as the Usenet newsgroup |
64 ;; gnu.emacs.bug) as well as bug-cc-mode@gnu.org, which directly | |
65 ;; contacts the CC Mode maintainers. Questions can sent to | |
66 ;; help-gnu-emacs@gnu.org (mirrored as gnu.emacs.help) and/or | |
36920 | 67 ;; bug-cc-mode@gnu.org. Please do not send bugs or questions to our |
68 ;; personal accounts; we reserve the right to ignore such email! | |
18720 | 69 |
70 ;; Many, many thanks go out to all the folks on the beta test list. | |
71 ;; Without their patience, testing, insight, code contributions, and | |
72 ;; encouragement CC Mode would be a far inferior package. | |
73 | |
74 ;; You can get the latest version of CC Mode, including PostScript | |
75 ;; documentation and separate individual files from: | |
76 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
77 ;; http://cc-mode.sourceforge.net/ |
18720 | 78 ;; |
24282 | 79 ;; You can join a moderated CC Mode announcement-only mailing list by |
80 ;; visiting | |
81 ;; | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
82 ;; http://lists.sourceforge.net/mailman/listinfo/cc-mode-announce |
18720 | 83 |
84 ;;; Code: | |
85 | |
26817 | 86 (eval-when-compile |
87 (let ((load-path | |
36920 | 88 (if (and (boundp 'byte-compile-dest-file) |
89 (stringp byte-compile-dest-file)) | |
90 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 91 load-path))) |
36920 | 92 (require 'cc-bytecomp))) |
21109
a0eda86dd0be
(c-initialize-cc-mode): Moved require's to top level.
Richard M. Stallman <rms@gnu.org>
parents:
20917
diff
changeset
|
93 |
36920 | 94 (cc-require 'cc-defs) |
95 (cc-require 'cc-menus) | |
96 (cc-require 'cc-vars) | |
97 (cc-require 'cc-langs) | |
98 (cc-require 'cc-styles) | |
99 (cc-require 'cc-engine) | |
100 (cc-require 'cc-cmds) | |
101 (cc-require 'cc-align) | |
102 | |
103 ;; Silence the compiler. | |
104 (cc-bytecomp-defvar comment-line-break-function) ; (X)Emacs 20+ | |
105 (cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs 20+ | |
106 (cc-bytecomp-defun set-keymap-parents) ; XEmacs | |
107 | |
108 ;; Menu support for both XEmacs and Emacs. If you don't have easymenu | |
109 ;; with your version of Emacs, you are incompatible! | |
110 (require 'easymenu) | |
18720 | 111 |
112 | |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
113 ;; 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
|
114 ;; 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
|
115 ;; use: |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
116 ;; |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
117 ;; (require 'cc-mode) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
118 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
119 ;; And in the major mode function: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
120 ;; |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
121 ;; (c-initialize-cc-mode) |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
122 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
123 (defun c-leave-cc-mode-mode () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
124 (setq c-buffer-is-cc-mode nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
125 |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
126 ;;;###autoload |
24282 | 127 (defun c-initialize-cc-mode () |
19299
7cd7373cc021
(c-initialize-cc-mode): Set c-buffer-is-cc-mode to t.
Richard M. Stallman <rms@gnu.org>
parents:
19253
diff
changeset
|
128 (setq c-buffer-is-cc-mode t) |
24282 | 129 (let ((initprop 'cc-mode-is-initialized) |
130 c-initialization-ok) | |
131 (unless (get 'c-initialize-cc-mode initprop) | |
132 (unwind-protect | |
133 (progn | |
26817 | 134 (put 'c-initialize-cc-mode initprop t) |
135 (c-initialize-builtin-style) | |
24282 | 136 (run-hooks 'c-initialization-hook) |
26817 | 137 ;; Fix obsolete variables. |
138 (if (boundp 'c-comment-continuation-stars) | |
139 (setq c-block-comment-prefix c-comment-continuation-stars)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
140 (add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode) |
24282 | 141 (setq c-initialization-ok t)) |
142 ;; Will try initialization hooks again if they failed. | |
26817 | 143 (put 'c-initialize-cc-mode initprop c-initialization-ok))) |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
144 )) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
145 |
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
146 |
36920 | 147 ;; Common routines |
148 (defvar c-mode-base-map () | |
149 "Keymap shared by all CC Mode related modes.") | |
150 | |
151 (defun c-make-inherited-keymap () | |
152 (let ((map (make-sparse-keymap))) | |
153 (cond | |
154 ;; XEmacs 19 & 20 | |
155 ((fboundp 'set-keymap-parents) | |
156 (set-keymap-parents map c-mode-base-map)) | |
157 ;; Emacs 19 | |
158 ((fboundp 'set-keymap-parent) | |
159 (set-keymap-parent map c-mode-base-map)) | |
160 ;; incompatible | |
161 (t (error "CC Mode is incompatible with this version of Emacs"))) | |
162 map)) | |
163 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
164 (defun c-define-abbrev-table (name defs) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
165 ;; Compatibility wrapper for `define-abbrev' which passes a non-nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
166 ;; sixth argument for SYSTEM-FLAG in emacsen that support it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
167 ;; (currently only Emacs 21.2). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
168 (define-abbrev-table name nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
169 (let ((table (symbol-value name))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
170 (while defs |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
171 (condition-case nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
172 (apply 'define-abbrev table (append (car defs) '(t))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
173 (wrong-number-of-arguments |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
174 (apply 'define-abbrev table (car defs)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
175 (setq defs (cdr defs))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
176 |
36920 | 177 (if c-mode-base-map |
178 nil | |
179 ;; TBD: should we even worry about naming this keymap. My vote: no, | |
180 ;; because Emacs and XEmacs do it differently. | |
181 (setq c-mode-base-map (make-sparse-keymap)) | |
182 ;; put standard keybindings into MAP | |
183 ;; the following mappings correspond more or less directly to BOCM | |
184 (define-key c-mode-base-map "{" 'c-electric-brace) | |
185 (define-key c-mode-base-map "}" 'c-electric-brace) | |
186 (define-key c-mode-base-map ";" 'c-electric-semi&comma) | |
187 (define-key c-mode-base-map "#" 'c-electric-pound) | |
188 (define-key c-mode-base-map ":" 'c-electric-colon) | |
189 (define-key c-mode-base-map "(" 'c-electric-paren) | |
190 (define-key c-mode-base-map ")" 'c-electric-paren) | |
191 ;; Separate M-BS from C-M-h. The former should remain | |
192 ;; backward-kill-word. | |
193 (define-key c-mode-base-map [(control meta h)] 'c-mark-function) | |
194 (define-key c-mode-base-map "\e\C-q" 'c-indent-exp) | |
195 (substitute-key-definition 'backward-sentence | |
196 'c-beginning-of-statement | |
197 c-mode-base-map global-map) | |
198 (substitute-key-definition 'forward-sentence | |
199 'c-end-of-statement | |
200 c-mode-base-map global-map) | |
201 (substitute-key-definition 'indent-new-comment-line | |
202 'c-indent-new-comment-line | |
203 c-mode-base-map global-map) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
204 (when (fboundp 'comment-indent-new-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
205 ;; indent-new-comment-line has changed name to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
206 ;; comment-indent-new-line in Emacs 21. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
207 (substitute-key-definition 'comment-indent-new-line |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
208 'c-indent-new-comment-line |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
209 c-mode-base-map global-map)) |
36920 | 210 ;; RMS says don't make these the default. |
211 ;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun) | |
212 ;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun) | |
213 (define-key c-mode-base-map "\C-c\C-n" 'c-forward-conditional) | |
214 (define-key c-mode-base-map "\C-c\C-p" 'c-backward-conditional) | |
215 (define-key c-mode-base-map "\C-c\C-u" 'c-up-conditional) | |
216 (substitute-key-definition 'indent-for-tab-command | |
217 'c-indent-command | |
218 c-mode-base-map global-map) | |
219 ;; It doesn't suffice to put c-fill-paragraph on | |
220 ;; fill-paragraph-function due to the way it works. | |
221 (substitute-key-definition 'fill-paragraph 'c-fill-paragraph | |
222 c-mode-base-map global-map) | |
223 ;; In XEmacs the default fill function is called | |
224 ;; fill-paragraph-or-region. | |
225 (substitute-key-definition 'fill-paragraph-or-region 'c-fill-paragraph | |
226 c-mode-base-map global-map) | |
37563
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
227 ;; Bind the electric deletion functions to C-d and DEL. Emacs 21 |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
228 ;; automatically maps the [delete] and [backspace] keys to these two |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
229 ;; depending on window system and user preferences. (In earlier |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
230 ;; versions it's possible to do the same by using `function-key-map'.) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
231 (define-key c-mode-base-map "\C-d" 'c-electric-delete-forward) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
232 (define-key c-mode-base-map "\177" 'c-electric-backspace) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
233 (when (boundp 'delete-key-deletes-forward) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
234 ;; In XEmacs 20 and later we fix the forward and backward deletion |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
235 ;; behavior by binding the keysyms for the [delete] and |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
236 ;; [backspace] keys directly, and use `delete-forward-p' or |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
237 ;; `delete-key-deletes-forward' to decide what [delete] should do. |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
238 (define-key c-mode-base-map [delete] 'c-electric-delete) |
79039a33283a
Bind c-electric-delete-forward to C-d and c-electric-backspace to DEL.
Eli Zaretskii <eliz@gnu.org>
parents:
36920
diff
changeset
|
239 (define-key c-mode-base-map [backspace] 'c-electric-backspace)) |
36920 | 240 ;; these are new keybindings, with no counterpart to BOCM |
241 (define-key c-mode-base-map "," 'c-electric-semi&comma) | |
242 (define-key c-mode-base-map "*" 'c-electric-star) | |
243 (define-key c-mode-base-map "/" 'c-electric-slash) | |
244 (define-key c-mode-base-map "\C-c\C-q" 'c-indent-defun) | |
245 (define-key c-mode-base-map "\C-c\C-\\" 'c-backslash-region) | |
246 ;; TBD: where if anywhere, to put c-backward|forward-into-nomenclature | |
247 (define-key c-mode-base-map "\C-c\C-a" 'c-toggle-auto-state) | |
248 (define-key c-mode-base-map "\C-c\C-b" 'c-submit-bug-report) | |
249 (define-key c-mode-base-map "\C-c\C-c" 'comment-region) | |
250 (define-key c-mode-base-map "\C-c\C-d" 'c-toggle-hungry-state) | |
251 (define-key c-mode-base-map "\C-c\C-o" 'c-set-offset) | |
252 (define-key c-mode-base-map "\C-c\C-s" 'c-show-syntactic-information) | |
253 (define-key c-mode-base-map "\C-c\C-t" 'c-toggle-auto-hungry-state) | |
254 (define-key c-mode-base-map "\C-c." 'c-set-style) | |
255 ;; conflicts with OOBR | |
256 ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) | |
257 ) | |
258 | |
259 (defvar c-c-menu nil) | |
260 (defvar c-c++-menu nil) | |
261 (defvar c-objc-menu nil) | |
262 (defvar c-java-menu nil) | |
263 (defvar c-pike-menu nil) | |
264 | |
265 (defun c-mode-menu (modestr) | |
266 (let ((m | |
267 '(["Comment Out Region" comment-region (c-fn-region-is-active-p)] | |
268 ["Uncomment Region" | |
269 (comment-region (region-beginning) (region-end) '(4)) | |
270 (c-fn-region-is-active-p)] | |
271 ["Fill Comment Paragraph" c-fill-paragraph t] | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
272 "----" |
36920 | 273 ["Indent Expression" c-indent-exp |
274 (memq (char-after) '(?\( ?\[ ?\{))] | |
275 ["Indent Line or Region" c-indent-line-or-region t] | |
276 ["Up Conditional" c-up-conditional t] | |
277 ["Backward Conditional" c-backward-conditional t] | |
278 ["Forward Conditional" c-forward-conditional t] | |
279 ["Backward Statement" c-beginning-of-statement t] | |
280 ["Forward Statement" c-end-of-statement t] | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
281 "----" |
36920 | 282 ["Macro Expand Region" c-macro-expand (c-fn-region-is-active-p)] |
283 ["Backslashify" c-backslash-region | |
284 (c-fn-region-is-active-p)] | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
285 "----" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
286 ("Toggle..." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
287 ["Syntactic indentation" c-toggle-syntactic-indentation t] |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
288 ["Auto newline" c-toggle-auto-state t] |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
289 ["Hungry delete" c-toggle-hungry-state t]) |
36920 | 290 ))) |
291 (cons modestr m))) | |
292 | |
293 ;; We don't require the outline package, but we configure it a bit anyway. | |
294 (cc-bytecomp-defvar outline-level) | |
295 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
296 (defun c-common-init (mode) |
36920 | 297 ;; Common initializations for all modes. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
298 (setq c-buffer-is-cc-mode mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
299 |
36920 | 300 ;; these variables should always be buffer local; they do not affect |
301 ;; indentation style. | |
302 (make-local-variable 'parse-sexp-ignore-comments) | |
303 (make-local-variable 'indent-line-function) | |
304 (make-local-variable 'indent-region-function) | |
305 (make-local-variable 'outline-regexp) | |
306 (make-local-variable 'outline-level) | |
307 (make-local-variable 'normal-auto-fill-function) | |
308 (make-local-variable 'comment-start) | |
309 (make-local-variable 'comment-end) | |
310 (make-local-variable 'comment-column) | |
311 (make-local-variable 'comment-start-skip) | |
312 (make-local-variable 'comment-multi-line) | |
313 (make-local-variable 'paragraph-start) | |
314 (make-local-variable 'paragraph-separate) | |
315 (make-local-variable 'paragraph-ignore-fill-prefix) | |
316 (make-local-variable 'adaptive-fill-mode) | |
317 (make-local-variable 'adaptive-fill-regexp) | |
318 (make-local-variable 'imenu-generic-expression) ;set in the mode functions | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
319 |
36920 | 320 ;; X/Emacs 20 only |
321 (and (boundp 'comment-line-break-function) | |
322 (progn | |
323 (make-local-variable 'comment-line-break-function) | |
324 (setq comment-line-break-function | |
325 'c-indent-new-comment-line))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
326 |
36920 | 327 ;; now set their values |
49496
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
328 (setq parse-sexp-ignore-comments t |
36920 | 329 indent-line-function 'c-indent-line |
330 indent-region-function 'c-indent-region | |
331 outline-regexp "[^#\n\^M]" | |
332 outline-level 'c-outline-level | |
333 normal-auto-fill-function 'c-do-auto-fill | |
334 comment-column 32 | |
335 comment-start-skip "/\\*+ *\\|//+ *" | |
336 comment-multi-line t) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
337 |
49654
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
338 ;; Install `c-fill-paragraph' on `fill-paragraph-function' so that a |
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
339 ;; direct call to `fill-paragraph' behaves better. This still |
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
340 ;; doesn't work with filladapt but it's better than nothing. |
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
341 (make-local-variable 'fill-paragraph-function) |
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
342 (setq fill-paragraph-function 'c-fill-paragraph) |
b025ca405045
(c-basic-common-init): Install `c-fill-paragraph' on
Martin Stjernholm <mast@lysator.liu.se>
parents:
49496
diff
changeset
|
343 |
49496
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
344 ;; Set `require-final-newline' only if we should. |
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
345 (let ((rfn (assq mode c-require-final-newline))) |
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
346 (when rfn |
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
347 (make-local-variable 'require-final-newline) |
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
348 (setq require-final-newline (cdr rfn)))) |
2c05c557df6c
(c-require-final-newline): Made this variable an alist to specify a value
Martin Stjernholm <mast@lysator.liu.se>
parents:
49470
diff
changeset
|
349 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
350 ;; Fix keyword regexps. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
351 (c-init-language-vars) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
352 |
36920 | 353 ;; now set the mode style based on c-default-style |
354 (let ((style (if (stringp c-default-style) | |
355 c-default-style | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
356 (or (cdr (assq mode c-default-style)) |
36920 | 357 (cdr (assq 'other c-default-style)) |
358 "gnu")))) | |
359 ;; Override style variables if `c-old-style-variable-behavior' is | |
360 ;; set. Also override if we are using global style variables, | |
361 ;; have already initialized a style once, and are switching to a | |
362 ;; different style. (It's doubtful whether this is desirable, but | |
363 ;; the whole situation with nonlocal style variables is a bit | |
364 ;; awkward. It's at least the most compatible way with the old | |
365 ;; style init procedure.) | |
366 (c-set-style style (not (or c-old-style-variable-behavior | |
367 (and (not c-style-variables-are-local-p) | |
368 c-indentation-style | |
369 (not (string-equal c-indentation-style | |
370 style))))))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
371 (c-setup-paragraph-variables) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
372 |
36920 | 373 ;; we have to do something special for c-offsets-alist so that the |
374 ;; buffer local value has its own alist structure. | |
375 (setq c-offsets-alist (copy-alist c-offsets-alist)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
376 |
36920 | 377 ;; setup the comment indent variable in a Emacs version portable way |
378 (make-local-variable 'comment-indent-function) | |
379 (setq comment-indent-function 'c-comment-indent) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
380 |
36920 | 381 ;; add menus to menubar |
382 (easy-menu-add (c-mode-menu mode-name)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
383 |
36920 | 384 ;; put auto-hungry designators onto minor-mode-alist, but only once |
385 (or (assq 'c-auto-hungry-string minor-mode-alist) | |
386 (setq minor-mode-alist | |
387 (cons '(c-auto-hungry-string c-auto-hungry-string) | |
388 minor-mode-alist))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
389 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
390 ;; Install the function that ensures `c-state-cache' doesn't become |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
391 ;; invalid. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
392 (make-local-variable 'after-change-functions) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
393 (add-hook 'after-change-functions 'c-check-state-cache)) |
36920 | 394 |
395 (defun c-postprocess-file-styles () | |
396 "Function that post processes relevant file local variables. | |
397 Currently, this function simply applies any style and offset settings | |
398 found in the file's Local Variable list. It first applies any style | |
399 setting found in `c-file-style', then it applies any offset settings | |
400 it finds in `c-file-offsets'. | |
401 | |
402 Note that the style variables are always made local to the buffer." | |
403 ;; apply file styles and offsets | |
45632
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
404 (when c-buffer-is-cc-mode |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
405 (if (or c-file-style c-file-offsets) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
406 (c-make-styles-buffer-local t)) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
407 (and c-file-style |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
408 (c-set-style c-file-style)) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
409 (and c-file-offsets |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
410 (mapcar |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
411 (lambda (langentry) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
412 (let ((langelem (car langentry)) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
413 (offset (cdr langentry))) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
414 (c-set-offset langelem offset))) |
9d60ac21968f
(c-postprocess-file-styles): Do nothing except in CC modes.
Richard M. Stallman <rms@gnu.org>
parents:
44728
diff
changeset
|
415 c-file-offsets)))) |
36920 | 416 |
417 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles) | |
418 | |
419 | |
420 ;; Support for C | |
421 | |
422 (defvar c-mode-abbrev-table nil | |
423 "Abbreviation table used in c-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
424 (c-define-abbrev-table 'c-mode-abbrev-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
425 '(("else" "else" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
426 ("while" "while" c-electric-continued-statement 0))) |
36920 | 427 |
428 (defvar c-mode-map () | |
429 "Keymap used in c-mode buffers.") | |
430 (if c-mode-map | |
431 nil | |
432 (setq c-mode-map (c-make-inherited-keymap)) | |
433 ;; add bindings which are only useful for C | |
434 (define-key c-mode-map "\C-c\C-e" 'c-macro-expand) | |
435 ) | |
436 | |
437 (easy-menu-define c-c-menu c-mode-map "C Mode Commands" | |
438 (c-mode-menu "C")) | |
439 | |
18720 | 440 ;;;###autoload |
441 (defun c-mode () | |
442 "Major mode for editing K&R and ANSI C code. | |
443 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
444 c-mode buffer. This automatically sets up a mail buffer with version | |
445 information already added. You just need to add a description of the | |
446 problem, including a reproducible test case and send the message. | |
447 | |
448 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
449 | |
450 The hook variable `c-mode-hook' is run with no args, if that value is | |
451 bound and has a non-nil value. Also the hook `c-mode-common-hook' is | |
452 run first. | |
453 | |
454 Key bindings: | |
455 \\{c-mode-map}" | |
456 (interactive) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
457 (kill-all-local-variables) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
458 (c-initialize-cc-mode) |
18720 | 459 (set-syntax-table c-mode-syntax-table) |
460 (setq major-mode 'c-mode | |
461 mode-name "C" | |
36920 | 462 local-abbrev-table c-mode-abbrev-table |
463 abbrev-mode t) | |
18720 | 464 (use-local-map c-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
465 (c-common-init 'c-mode) |
26817 | 466 (cc-imenu-init cc-imenu-c-generic-expression) |
51614
73108f24fe68
(c-mode): Add local variable gud-find-expr.
Nick Roberts <nickrob@snap.net.nz>
parents:
49654
diff
changeset
|
467 (set (make-local-variable 'gud-find-expr) 'gud-find-c-expr) |
18720 | 468 (run-hooks 'c-mode-common-hook) |
469 (run-hooks 'c-mode-hook) | |
470 (c-update-modeline)) | |
471 | |
472 | |
36920 | 473 ;; Support for C++ |
474 | |
475 (defvar c++-mode-abbrev-table nil | |
476 "Abbreviation table used in c++-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
477 (c-define-abbrev-table 'c++-mode-abbrev-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
478 '(("else" "else" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
479 ("while" "while" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
480 ("catch" "catch" c-electric-continued-statement 0))) |
36920 | 481 |
482 (defvar c++-mode-map () | |
483 "Keymap used in c++-mode buffers.") | |
484 (if c++-mode-map | |
485 nil | |
486 (setq c++-mode-map (c-make-inherited-keymap)) | |
487 ;; add bindings which are only useful for C++ | |
488 (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand) | |
489 (define-key c++-mode-map "\C-c:" 'c-scope-operator) | |
490 (define-key c++-mode-map "<" 'c-electric-lt-gt) | |
491 (define-key c++-mode-map ">" 'c-electric-lt-gt)) | |
492 | |
493 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands" | |
494 (c-mode-menu "C++")) | |
495 | |
18720 | 496 ;;;###autoload |
497 (defun c++-mode () | |
498 "Major mode for editing C++ code. | |
499 To submit a problem report, enter `\\[c-submit-bug-report]' from a | |
500 c++-mode buffer. This automatically sets up a mail buffer with | |
501 version information already added. You just need to add a description | |
502 of the problem, including a reproducible test case, and send the | |
503 message. | |
504 | |
505 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
506 | |
507 The hook variable `c++-mode-hook' is run with no args, if that | |
508 variable is bound and has a non-nil value. Also the hook | |
509 `c-mode-common-hook' is run first. | |
510 | |
511 Key bindings: | |
512 \\{c++-mode-map}" | |
513 (interactive) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
514 (kill-all-local-variables) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
515 (c-initialize-cc-mode) |
18720 | 516 (set-syntax-table c++-mode-syntax-table) |
517 (setq major-mode 'c++-mode | |
518 mode-name "C++" | |
36920 | 519 local-abbrev-table c++-mode-abbrev-table |
520 abbrev-mode t) | |
18720 | 521 (use-local-map c++-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
522 (c-common-init 'c++-mode) |
26817 | 523 (cc-imenu-init cc-imenu-c++-generic-expression) |
18720 | 524 (run-hooks 'c-mode-common-hook) |
525 (run-hooks 'c++-mode-hook) | |
526 (c-update-modeline)) | |
527 | |
528 | |
36920 | 529 ;; Support for Objective-C |
530 | |
531 (defvar objc-mode-abbrev-table nil | |
532 "Abbreviation table used in objc-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
533 (c-define-abbrev-table 'objc-mode-abbrev-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
534 '(("else" "else" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
535 ("while" "while" c-electric-continued-statement 0))) |
36920 | 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 | |
543 (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand)) | |
544 | |
545 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands" | |
546 (c-mode-menu "ObjC")) | |
547 | |
18720 | 548 ;;;###autoload |
549 (defun objc-mode () | |
550 "Major mode for editing Objective C code. | |
551 To submit a problem report, enter `\\[c-submit-bug-report]' from an | |
552 objc-mode buffer. This automatically sets up a mail buffer with | |
553 version information already added. You just need to add a description | |
554 of the problem, including a reproducible test case, and send the | |
555 message. | |
556 | |
557 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
558 | |
559 The hook variable `objc-mode-hook' is run with no args, if that value | |
560 is bound and has a non-nil value. Also the hook `c-mode-common-hook' | |
561 is run first. | |
562 | |
563 Key bindings: | |
564 \\{objc-mode-map}" | |
565 (interactive) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
566 (kill-all-local-variables) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
567 (c-initialize-cc-mode) |
18720 | 568 (set-syntax-table objc-mode-syntax-table) |
569 (setq major-mode 'objc-mode | |
570 mode-name "ObjC" | |
36920 | 571 local-abbrev-table objc-mode-abbrev-table |
572 abbrev-mode t) | |
18720 | 573 (use-local-map objc-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
574 (c-common-init 'objc-mode) |
26817 | 575 (cc-imenu-init cc-imenu-objc-generic-expression) |
18720 | 576 (run-hooks 'c-mode-common-hook) |
577 (run-hooks 'objc-mode-hook) | |
578 (c-update-modeline)) | |
579 | |
580 | |
36920 | 581 ;; Support for Java |
582 | |
583 (defvar java-mode-abbrev-table nil | |
584 "Abbreviation table used in java-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
585 (c-define-abbrev-table 'java-mode-abbrev-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
586 '(("else" "else" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
587 ("while" "while" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
588 ("catch" "catch" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
589 ("finally" "finally" c-electric-continued-statement 0))) |
36920 | 590 |
591 (defvar java-mode-map () | |
592 "Keymap used in java-mode buffers.") | |
593 (if java-mode-map | |
594 nil | |
595 (setq java-mode-map (c-make-inherited-keymap)) | |
596 ;; add bindings which are only useful for Java | |
597 ) | |
598 | |
599 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands" | |
600 (c-mode-menu "Java")) | |
601 | |
18720 | 602 ;;;###autoload |
603 (defun java-mode () | |
604 "Major mode for editing Java code. | |
20135
ecb78a6ccd8d
(objc-mode): Bind imenu-create-index-function
Karl Heuer <kwzh@gnu.org>
parents:
19808
diff
changeset
|
605 To submit a problem report, enter `\\[c-submit-bug-report]' from a |
18720 | 606 java-mode buffer. This automatically sets up a mail buffer with |
607 version information already added. You just need to add a description | |
608 of the problem, including a reproducible test case and send the | |
609 message. | |
610 | |
611 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
612 | |
613 The hook variable `java-mode-hook' is run with no args, if that value | |
614 is bound and has a non-nil value. Also the common hook | |
615 `c-mode-common-hook' is run first. Note that this mode automatically | |
616 sets the \"java\" style before calling any hooks so be careful if you | |
617 set styles in `c-mode-common-hook'. | |
618 | |
619 Key bindings: | |
620 \\{java-mode-map}" | |
621 (interactive) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
622 (kill-all-local-variables) |
18847
dd7615d21a97
(c-initialize-cc-mode): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
623 (c-initialize-cc-mode) |
18720 | 624 (set-syntax-table java-mode-syntax-table) |
625 (setq major-mode 'java-mode | |
626 mode-name "Java" | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
627 local-abbrev-table java-mode-abbrev-table |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
628 abbrev-mode t) |
18720 | 629 (use-local-map java-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
630 (c-common-init 'java-mode) |
26817 | 631 (cc-imenu-init cc-imenu-java-generic-expression) |
18720 | 632 (run-hooks 'c-mode-common-hook) |
633 (run-hooks 'java-mode-hook) | |
634 (c-update-modeline)) | |
635 | |
636 | |
36920 | 637 ;; Support for CORBA's IDL language |
638 | |
639 (defvar idl-mode-abbrev-table nil | |
640 "Abbreviation table used in idl-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
641 (c-define-abbrev-table 'idl-mode-abbrev-table nil) |
36920 | 642 |
643 (defvar idl-mode-map () | |
644 "Keymap used in idl-mode buffers.") | |
645 (if idl-mode-map | |
646 nil | |
647 (setq idl-mode-map (c-make-inherited-keymap)) | |
648 ;; add bindings which are only useful for IDL | |
649 ) | |
650 | |
651 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands" | |
652 (c-mode-menu "IDL")) | |
653 | |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
654 ;;;###autoload |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
655 (defun idl-mode () |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
656 "Major mode for editing CORBA's IDL code. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
657 To submit a problem report, enter `\\[c-submit-bug-report]' from an |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
658 idl-mode buffer. This automatically sets up a mail buffer with |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
659 version information already added. You just need to add a description |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
660 of the problem, including a reproducible test case, and send the |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
661 message. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
662 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
663 To see what version of CC Mode you are running, enter `\\[c-version]'. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
664 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
665 The hook variable `idl-mode-hook' is run with no args, if that |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
666 variable is bound and has a non-nil value. Also the hook |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
667 `c-mode-common-hook' is run first. |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
668 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
669 Key bindings: |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
670 \\{idl-mode-map}" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
671 (interactive) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
672 (kill-all-local-variables) |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
673 (c-initialize-cc-mode) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
674 (set-syntax-table idl-mode-syntax-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
675 (setq major-mode 'idl-mode |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
676 mode-name "IDL" |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
677 local-abbrev-table idl-mode-abbrev-table) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
678 (use-local-map idl-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
679 (c-common-init 'idl-mode) |
26817 | 680 ;;(cc-imenu-init cc-imenu-idl-generic-expression) ;FIXME |
19253
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
681 (run-hooks 'c-mode-common-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
682 (run-hooks 'idl-mode-hook) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
683 (c-update-modeline)) |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
684 |
2bda7e07f25d
(idl-mode): Support for CORBA's IDL language.
Richard M. Stallman <rms@gnu.org>
parents:
18847
diff
changeset
|
685 |
36920 | 686 ;; Support for Pike |
687 | |
688 (defvar pike-mode-abbrev-table nil | |
689 "Abbreviation table used in pike-mode buffers.") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
690 (c-define-abbrev-table 'pike-mode-abbrev-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
691 '(("else" "else" c-electric-continued-statement 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
692 ("while" "while" c-electric-continued-statement 0))) |
36920 | 693 |
694 (defvar pike-mode-map () | |
695 "Keymap used in pike-mode buffers.") | |
696 (if pike-mode-map | |
697 nil | |
698 (setq pike-mode-map (c-make-inherited-keymap)) | |
699 ;; additional bindings | |
700 (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand)) | |
701 | |
702 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands" | |
703 (c-mode-menu "Pike")) | |
704 | |
24282 | 705 ;;;###autoload |
706 (defun pike-mode () | |
707 "Major mode for editing Pike code. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
708 To submit a problem report, enter `\\[c-submit-bug-report]' from a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
709 pike-mode buffer. This automatically sets up a mail buffer with |
24282 | 710 version information already added. You just need to add a description |
711 of the problem, including a reproducible test case, and send the | |
712 message. | |
713 | |
714 To see what version of CC Mode you are running, enter `\\[c-version]'. | |
715 | |
716 The hook variable `pike-mode-hook' is run with no args, if that value | |
717 is bound and has a non-nil value. Also the common hook | |
718 `c-mode-common-hook' is run first. | |
719 | |
720 Key bindings: | |
721 \\{pike-mode-map}" | |
722 (interactive) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
723 (kill-all-local-variables) |
24282 | 724 (c-initialize-cc-mode) |
725 (set-syntax-table pike-mode-syntax-table) | |
726 (setq major-mode 'pike-mode | |
727 mode-name "Pike" | |
36920 | 728 local-abbrev-table pike-mode-abbrev-table |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
729 abbrev-mode t) |
24282 | 730 (use-local-map pike-mode-map) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
731 (c-common-init 'pike-mode) |
26817 | 732 ;;(cc-imenu-init cc-imenu-pike-generic-expression) ;FIXME |
24282 | 733 (run-hooks 'c-mode-common-hook) |
734 (run-hooks 'pike-mode-hook) | |
735 (c-update-modeline)) | |
736 | |
737 | |
20146 | 738 ;; bug reporting |
18720 | 739 |
740 (defconst c-mode-help-address | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
741 "bug-cc-mode@gnu.org" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
742 "Address(es) for CC Mode bug reports.") |
18720 | 743 |
744 (defun c-version () | |
745 "Echo the current version of CC Mode in the minibuffer." | |
746 (interactive) | |
747 (message "Using CC Mode version %s" c-version) | |
748 (c-keep-region-active)) | |
749 | |
36920 | 750 (defvar c-prepare-bug-report-hooks nil) |
751 | |
752 ;; Dynamic variables used by reporter. | |
753 (defvar reporter-prompt-for-summary-p) | |
754 (defvar reporter-dont-compact-list) | |
755 | |
18720 | 756 (defun c-submit-bug-report () |
757 "Submit via mail a bug report on CC Mode." | |
758 (interactive) | |
20917
c6e2c4d9a305
(c-mode, c++-mode, objc-mode, java-mode): Set
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
759 (require 'reporter) |
18720 | 760 ;; load in reporter |
761 (let ((reporter-prompt-for-summary-p t) | |
762 (reporter-dont-compact-list '(c-offsets-alist)) | |
763 (style c-indentation-style) | |
764 (c-features c-emacs-features)) | |
765 (and | |
766 (if (y-or-n-p "Do you want to submit a report on CC Mode? ") | |
767 t (message "") nil) | |
768 (require 'reporter) | |
769 (reporter-submit-bug-report | |
770 c-mode-help-address | |
771 (concat "CC Mode " c-version " (" | |
772 (cond ((eq major-mode 'c++-mode) "C++") | |
773 ((eq major-mode 'c-mode) "C") | |
774 ((eq major-mode 'objc-mode) "ObjC") | |
775 ((eq major-mode 'java-mode) "Java") | |
26817 | 776 ((eq major-mode 'idl-mode) "IDL") |
24282 | 777 ((eq major-mode 'pike-mode) "Pike") |
18720 | 778 ) |
779 ")") | |
26817 | 780 (let ((vars (append |
18720 | 781 ;; report only the vars that affect indentation |
26817 | 782 c-style-variables |
783 '(c-delete-function | |
784 c-electric-pound-behavior | |
785 c-indent-comments-syntactically-p | |
786 c-tab-always-indent | |
787 defun-prompt-regexp | |
788 tab-width | |
789 comment-column | |
790 parse-sexp-ignore-comments | |
791 ;; A brain-damaged XEmacs only variable that, if | |
792 ;; set to nil can cause all kinds of chaos. | |
793 signal-error-on-buffer-boundary | |
794 ;; Variables that affect line breaking and comments. | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
795 auto-fill-function |
26817 | 796 filladapt-mode |
797 comment-multi-line | |
798 comment-start-skip | |
799 fill-prefix | |
800 paragraph-start | |
801 adaptive-fill-mode | |
802 adaptive-fill-regexp) | |
803 nil))) | |
804 (delq 'c-special-indent-hook vars) | |
30401
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
805 (mapcar (lambda (var) (unless (boundp var) (delq var vars))) |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
806 '(signal-error-on-buffer-boundary |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
807 filladapt-mode |
b85ee58b24ec
(c-initialize-cc-mode): Handling of obsolete
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
808 defun-prompt-regexp)) |
26817 | 809 vars) |
41592
b89d0c514129
(c-submit-bug-report): Make sure that the arguments to `insert' are strings.
Sam Steingold <sds@gnu.org>
parents:
37563
diff
changeset
|
810 (lambda () |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
811 (run-hooks 'c-prepare-bug-report-hooks) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
812 (insert (format "Buffer Style: %s\n\nc-emacs-features: %s\n" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
42390
diff
changeset
|
813 style c-features))))))) |
18720 | 814 |
815 | |
36920 | 816 (cc-provide 'cc-mode) |
18720 | 817 ;;; cc-mode.el ends here |