Mercurial > hg > xemacs-beta
comparison lisp/cc-mode/cc-mode.el @ 171:929b76928fce r20-3b12
Import from CVS: tag r20-3b12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:47:52 +0200 |
parents | 5a88923fcbfe |
children | 2d532a89d707 |
comparison
equal
deleted
inserted
replaced
170:98a42ee61975 | 171:929b76928fce |
---|---|
5 ;; Authors: 1992-1997 Barry A. Warsaw | 5 ;; Authors: 1992-1997 Barry A. Warsaw |
6 ;; 1987 Dave Detlefs and Stewart Clamen | 6 ;; 1987 Dave Detlefs and Stewart Clamen |
7 ;; 1985 Richard M. Stallman | 7 ;; 1985 Richard M. Stallman |
8 ;; Maintainer: cc-mode-help@python.org | 8 ;; Maintainer: cc-mode-help@python.org |
9 ;; Created: a long, long, time ago. adapted from the original c-mode.el | 9 ;; Created: a long, long, time ago. adapted from the original c-mode.el |
10 ;; Version: 5.11 | 10 ;; Version: 5.12 |
11 ;; Keywords: c languages oop | 11 ;; Keywords: c languages oop |
12 | 12 |
13 ;; NOTE: Read the commentary below for the right way to submit bug reports! | 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! | 14 ;; NOTE: See the accompanying texinfo manual for details on using this mode! |
15 | 15 |
83 ;; | 83 ;; |
84 ;; ftp://ftp.python.org/pub/emacs | 84 ;; ftp://ftp.python.org/pub/emacs |
85 | 85 |
86 ;;; Code: | 86 ;;; Code: |
87 | 87 |
88 | 88 (eval-when-compile |
89 | 89 (require 'cc-menus)) |
90 ;; Figure out what features this Emacs has | 90 (require 'cc-defs) |
91 (defconst c-emacs-features | 91 |
92 (let ((infodock-p (boundp 'infodock-version)) | 92 |
93 (comments | |
94 ;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags. | |
95 ;; Emacs 19 uses a 1-bit flag. We will have to set up our | |
96 ;; syntax tables differently to handle this. | |
97 (let ((table (copy-syntax-table)) | |
98 entry) | |
99 (modify-syntax-entry ?a ". 12345678" table) | |
100 (cond | |
101 ;; XEmacs 19, and beyond Emacs 19.34 | |
102 ((arrayp table) | |
103 (setq entry (aref table ?a)) | |
104 ;; In Emacs, table entries are cons cells | |
105 (if (consp entry) (setq entry (car entry)))) | |
106 ;; XEmacs 20 | |
107 ((fboundp 'get-char-table) (setq entry (get-char-table ?a table))) | |
108 ;; before and including Emacs 19.34 | |
109 ((and (fboundp 'char-table-p) | |
110 (char-table-p table)) | |
111 (setq entry (car (char-table-range table [?a])))) | |
112 ;; incompatible | |
113 (t (error "CC Mode is incompatible with this version of Emacs"))) | |
114 (if (= (logand (lsh entry -16) 255) 255) | |
115 '8-bit | |
116 '1-bit)))) | |
117 (if infodock-p | |
118 (list comments 'infodock) | |
119 (list comments))) | |
120 "A list of features extant in the Emacs you are using. | |
121 There are many flavors of Emacs out there, each with different | |
122 features supporting those needed by CC Mode. Here's the current | |
123 supported list, along with the values for this variable: | |
124 | |
125 XEmacs 19: (8-bit) | |
126 XEmacs 20: (8-bit) | |
127 Emacs 19: (1-bit) | |
128 | |
129 Infodock (based on XEmacs) has an additional symbol on this list: | |
130 'infodock.") | |
131 | |
132 | |
133 | |
134 ;; important macros and subroutines | |
135 (defsubst c-point (position) | |
136 ;; Returns the value of point at certain commonly referenced POSITIONs. | |
137 ;; POSITION can be one of the following symbols: | |
138 ;; | |
139 ;; bol -- beginning of line | |
140 ;; eol -- end of line | |
141 ;; bod -- beginning of defun | |
142 ;; boi -- back to indentation | |
143 ;; ionl -- indentation of next line | |
144 ;; iopl -- indentation of previous line | |
145 ;; bonl -- beginning of next line | |
146 ;; bopl -- beginning of previous line | |
147 ;; | |
148 ;; This function does not modify point or mark. | |
149 (let ((here (point))) | |
150 (cond | |
151 ((eq position 'bol) (beginning-of-line)) | |
152 ((eq position 'eol) (end-of-line)) | |
153 ((eq position 'bod) | |
154 (beginning-of-defun) | |
155 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at | |
156 ;; the open brace. | |
157 (and defun-prompt-regexp | |
158 (looking-at defun-prompt-regexp) | |
159 (goto-char (match-end 0))) | |
160 ) | |
161 ((eq position 'boi) (back-to-indentation)) | |
162 ((eq position 'bonl) (forward-line 1)) | |
163 ((eq position 'bopl) (forward-line -1)) | |
164 ((eq position 'iopl) | |
165 (forward-line -1) | |
166 (back-to-indentation)) | |
167 ((eq position 'ionl) | |
168 (forward-line 1) | |
169 (back-to-indentation)) | |
170 (t (error "unknown buffer position requested: %s" position)) | |
171 ) | |
172 (prog1 | |
173 (point) | |
174 (goto-char here)))) | |
175 | |
176 (defmacro c-safe (&rest body) | |
177 ;; safely execute BODY, return nil if an error occurred | |
178 (` (condition-case nil | |
179 (progn (,@ body)) | |
180 (error nil)))) | |
181 | |
182 (defsubst c-keep-region-active () | |
183 ;; Do whatever is necessary to keep the region active in XEmacs. | |
184 ;; Ignore byte-compiler warnings you might see. This is not needed | |
185 ;; for Emacs. | |
186 (and (boundp 'zmacs-region-stays) | |
187 (setq zmacs-region-stays t))) | |
188 | |
189 | |
190 | |
191 (defsubst c-load-all () | |
192 ;; make sure all necessary components of CC Mode are loaded in. | |
193 (require 'cc-vars) | |
194 (require 'cc-engine) | |
195 (require 'cc-langs) | |
196 (require 'cc-menus) | |
197 (require 'cc-align) | |
198 (require 'cc-styles) | |
199 (require 'cc-cmds)) | |
200 | |
201 | |
202 ;;;###autoload | 93 ;;;###autoload |
203 (defun c-mode () | 94 (defun c-mode () |
204 "Major mode for editing K&R and ANSI C code. | 95 "Major mode for editing K&R and ANSI C code. |
205 To submit a problem report, enter `\\[c-submit-bug-report]' from a | 96 To submit a problem report, enter `\\[c-submit-bug-report]' from a |
206 c-mode buffer. This automatically sets up a mail buffer with version | 97 c-mode buffer. This automatically sets up a mail buffer with version |
366 (run-hooks 'java-mode-hook) | 257 (run-hooks 'java-mode-hook) |
367 (c-update-modeline)) | 258 (c-update-modeline)) |
368 | 259 |
369 | 260 |
370 ;; defuns for submitting bug reports | 261 ;; defuns for submitting bug reports |
371 (defconst c-version "5.11" | 262 (defconst c-version "5.12" |
372 "CC Mode version number.") | 263 "CC Mode version number.") |
373 | 264 |
374 (defconst c-mode-help-address | 265 (defconst c-mode-help-address |
375 "bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org" | 266 "bug-gnu-emacs@prep.ai.mit.edu, cc-mode-help@python.org" |
376 "Address for CC Mode bug reports.") | 267 "Address for CC Mode bug reports.") |