aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1995-07-28 00:28:28 +0000
committerKarl Heuer1995-07-28 00:28:28 +0000
commit82af06af7845bcbe9117ba326debfc1bed807e50 (patch)
tree1f30b8f6aa361bde6ec0223589d6e9523d11d91f
parent0fb4f2457b212d9a369076dac2daf0297708887d (diff)
downloademacs-82af06af7845bcbe9117ba326debfc1bed807e50.tar.gz
emacs-82af06af7845bcbe9117ba326debfc1bed807e50.zip
(c-imenu-generic-expression): Var defined.
(c-mode): Set imenu-generic-expression.
-rw-r--r--lisp/progmodes/c-mode.el98
1 files changed, 98 insertions, 0 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el
index 942f18cbc5b..44c92ddea06 100644
--- a/lisp/progmodes/c-mode.el
+++ b/lisp/progmodes/c-mode.el
@@ -179,6 +179,102 @@ regardless of where in the line point is when the TAB command is used.")
179;;; statements. 179;;; statements.
180(defconst c-switch-label-regexp "case[ \t'/(]\\|default[ \t]*:") 180(defconst c-switch-label-regexp "case[ \t'/(]\\|default[ \t]*:")
181 181
182;; This is actually the expression for C++ mode, but it's used for C too.
183(defvar c-imenu-generic-expression
184 (`
185 ((nil
186 (,
187 (concat
188 "^" ; beginning of line is required
189 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
190 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
191 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
192
193 "\\(" ; last type spec including */&
194 "[a-zA-Z0-9_:]+"
195 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
196 "\\)?" ; if there is a last type spec
197 "\\(" ; name; take that into the imenu entry
198 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
199 ; (may not contain * because then
200 ; "a::operator char*" would become "char*"!)
201 "\\|"
202 "\\([a-zA-Z0-9_:~]*::\\)?operator"
203 "[^a-zA-Z1-9_][^(]*" ; ...or operator
204 " \\)"
205 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after
206 ; the (...) to avoid prototypes. Can't
207 ; catch cases with () inside the parentheses
208 ; surrounding the parameters
209 ; (like "int foo(int a=bar()) {...}"
210
211 )) 6)
212 ("Class"
213 (, (concat
214 "^" ; beginning of line is required
215 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
216 "class[ \t]+"
217 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
218 "[ \t]*[:{]"
219 )) 2)
220;; Example of generic expression for finding prototypes, structs, unions, enums.
221;; Uncomment if you want to find these too. It will be a bit slower gathering
222;; the indexes.
223; ("Prototypes"
224; (,
225; (concat
226; "^" ; beginning of line is required
227; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
228; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
229; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
230
231; "\\(" ; last type spec including */&
232; "[a-zA-Z0-9_:]+"
233; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
234; "\\)?" ; if there is a last type spec
235; "\\(" ; name; take that into the imenu entry
236; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
237; ; (may not contain * because then
238; ; "a::operator char*" would become "char*"!)
239; "\\|"
240; "\\([a-zA-Z0-9_:~]*::\\)?operator"
241; "[^a-zA-Z1-9_][^(]*" ; ...or operator
242; " \\)"
243; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after
244; ; the (...) Can't
245; ; catch cases with () inside the parentheses
246; ; surrounding the parameters
247; ; (like "int foo(int a=bar());"
248; )) 6)
249; ("Struct"
250; (, (concat
251; "^" ; beginning of line is required
252; "\\(static[ \t]+\\)?" ; there may be static or const.
253; "\\(const[ \t]+\\)?"
254; "struct[ \t]+"
255; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
256; "[ \t]*[{]"
257; )) 3)
258; ("Enum"
259; (, (concat
260; "^" ; beginning of line is required
261; "\\(static[ \t]+\\)?" ; there may be static or const.
262; "\\(const[ \t]+\\)?"
263; "enum[ \t]+"
264; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
265; "[ \t]*[{]"
266; )) 3)
267; ("Union"
268; (, (concat
269; "^" ; beginning of line is required
270; "\\(static[ \t]+\\)?" ; there may be static or const.
271; "\\(const[ \t]+\\)?"
272; "union[ \t]+"
273; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
274; "[ \t]*[{]"
275; )) 3)
276 ))
277 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
182 278
183(defun c-mode () 279(defun c-mode ()
184 "Major mode for editing C code. 280 "Major mode for editing C code.
@@ -263,6 +359,8 @@ if that value is non-nil."
263 (setq comment-multi-line t) 359 (setq comment-multi-line t)
264 (make-local-variable 'parse-sexp-ignore-comments) 360 (make-local-variable 'parse-sexp-ignore-comments)
265 (setq parse-sexp-ignore-comments t) 361 (setq parse-sexp-ignore-comments t)
362 (make-local-variable 'imenu-generic-expression)
363 (setq imenu-generic-expression c-imenu-generic-expression)
266 (run-hooks 'c-mode-hook)) 364 (run-hooks 'c-mode-hook))
267 365
268(defun c-outline-level () 366(defun c-outline-level ()