aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-02-17 07:10:49 +0000
committerRichard M. Stallman1998-02-17 07:10:49 +0000
commitf1063b2f66ea1daf6e0cd8e38855806c3c258b96 (patch)
tree73fa7ece536dbd96cdbe4f9f1b96597b26049f29
parentbb7830ef8a3b5239260b32049f0cb9d829718583 (diff)
downloademacs-f1063b2f66ea1daf6e0cd8e38855806c3c258b96.tar.gz
emacs-f1063b2f66ea1daf6e0cd8e38855806c3c258b96.zip
Imenu support changed.
-rw-r--r--lisp/progmodes/cc-menus.el92
1 files changed, 58 insertions, 34 deletions
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el
index d840b744b42..cc9a9c01c2d 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -1,6 +1,6 @@
1;;; cc-menus.el --- imenu support for CC Mode 1;;; cc-menus.el --- imenu support for CC Mode
2 2
3;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc. 3;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
4 4
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
@@ -80,7 +80,9 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
80 (concat 80 (concat
81 "^" 81 "^"
82 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name 82 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
83 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above 83 "[ \t]*(" ; see above, BUT
84 "[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
85 "[ \t]*[^ \t;(]" ; with an asterisk or parentheses
84 )) 1) 86 )) 1)
85 ;; General function name regexp 87 ;; General function name regexp
86 (nil 88 (nil
@@ -90,8 +92,8 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
90 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char 92 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
91 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name 93 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
92 "[ \t]*(" ; see above, BUT 94 "[ \t]*(" ; see above, BUT
93 "[ \t]*[^ \t(][^)]*)[ \t]*[^ \t;]" ; the argument list must not start 95 "[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
94 ; with a parentheses 96 "[ \t]*[^ \t;(]" ; with an asterisk or parentheses
95 )) 1) 97 )) 1)
96 ;; Special case for definitions using phony prototype macros like: 98 ;; Special case for definitions using phony prototype macros like:
97 ;; `int main _PROTO( (int argc,char *argv[]) )'. 99 ;; `int main _PROTO( (int argc,char *argv[]) )'.
@@ -143,32 +145,56 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
143 )) 6))) 145 )) 6)))
144 "Imenu generic expression for Java mode. See `imenu-generic-expression'.") 146 "Imenu generic expression for Java mode. See `imenu-generic-expression'.")
145 147
148;; *Warning for cc-mode developers*
149;;
150;; `cc-imenu-objc-generic-expression' elements depend on
151;; `cc-imenu-c++-generic-expression'. So if you change this
152;; expression, you need to change following variables,
153;; `cc-imenu-objc-generic-expression-*-index',
154;; too. `cc-imenu-objc-function' uses these *-index variables, in
155;; order to know where the each regexp *group \\(foobar\\)* elements
156;; are started.
157;;
158;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
159;; being initialized.
160;;
161
162;; Internal variables
163(defvar cc-imenu-objc-generic-expression-noreturn-index nil)
164(defvar cc-imenu-objc-generic-expression-general-func-index nil)
165(defvar cc-imenu-objc-generic-expression-proto-index nil)
166(defvar cc-imenu-objc-generic-expression-objc-base-index nil)
167
146(defvar cc-imenu-objc-generic-expression 168(defvar cc-imenu-objc-generic-expression
147 (concat 169 (concat
148 ;; 170 ;;
149 ;; For C 171 ;; For C
150 ;; *Warning for developers*
151 ;; This expression elements depend on `cc-imenu-c++-generic-expression'.
152 ;; 172 ;;
153 ;; > Special case to match a line like `main() {}' 173 ;; > Special case to match a line like `main() {}'
154 ;; > e.g. no return type, not even on the previous line. 174 ;; > e.g. no return type, not even on the previous line.
155 ;; Pick a token by (match-string 1) 175 ;; Pick a token by (match-string 1)
156 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; 176 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2
177 (prog2 (setq cc-imenu-objc-generic-expression-noreturn-index 1) "")
157 "\\|" 178 "\\|"
158 ;; > General function name regexp 179 ;; > General function name regexp
159 ;; Pick a token by (match-string 2) 180 ;; Pick a token by (match-string 3)
160 (car (cdr (nth 2 cc-imenu-c++-generic-expression))) 181 (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 2
182 (prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
161 ;; > Special case for definitions using phony prototype macros like: 183 ;; > Special case for definitions using phony prototype macros like:
162 ;; > `int main _PROTO( (int argc,char *argv[]) )'. 184 ;; > `int main _PROTO( (int argc,char *argv[]) )'.
163 ;; Pick a token by (match-string 3) 185 ;; Pick a token by (match-string 5)
164 (if cc-imenu-c-prototype-macro-regexp 186 (if cc-imenu-c-prototype-macro-regexp
165 (concat 187 (concat
166 "\\|" 188 "\\|"
167 (car (cdr (nth 3 cc-imenu-c++-generic-expression)))) 189 (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
168 "") 190 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 6) "")
191 )
192 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 5) "")
193 "") ; -> index += 0
194 (prog2 (setq cc-imenu-objc-generic-expression-proto-index 5) "")
169 ;; 195 ;;
170 ;; For Objective-C 196 ;; For Objective-C
171 ;; Pick a token by (match-string 3 or 4) 197 ;; Pick a token by (match-string 5 or 6)
172 ;; 198 ;;
173 "\\|\\(" 199 "\\|\\("
174 "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods 200 "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods
@@ -252,19 +278,18 @@ Example:
252 (let (methodlist 278 (let (methodlist
253 clist 279 clist
254 ;; 280 ;;
255 ;; OBJC, C1, C2, C3 are constants. 281 ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
256 ;; 282 ;;
257 ;; *Warning for developers* 283 ;; *Warning for developers*
258 ;; These constants depend on `cc-imenu-c++-generic-expression'. 284 ;; These constants depend on `cc-imenu-c++-generic-expression'.
259 ;; 285 ;;
260 (OBJC 286 (OBJC cc-imenu-objc-generic-expression-objc-base-index)
261 (if cc-imenu-c-prototype-macro-regexp 4 3)) 287 ;; Special case to match a line like `main() {}'
262 (C1 ; > Special case to match a line like `main() {}' 288 (Cnoreturn cc-imenu-objc-generic-expression-noreturn-index)
263 1) 289 ;; General function name regexp
264 (C2 ; > General function name regexp 290 (Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index)
265 2) 291 ;; Special case for definitions using phony prototype macros like:
266 (C3 ; > Special case for definitions using phony prototype macros like: 292 (Cproto cc-imenu-objc-generic-expression-proto-index)
267 3)
268 langnum 293 langnum
269 ;; 294 ;;
270 (classcount 0) 295 (classcount 0)
@@ -275,13 +300,13 @@ Example:
275 (intflen (length "@interface")) 300 (intflen (length "@interface"))
276 (implen (length "@implementation")) 301 (implen (length "@implementation"))
277 (prtlen (length "@protocol")) 302 (prtlen (length "@protocol"))
278 bufsubst-fun) 303 (func
279 ;; 304 ;;
280 ;; Does this emacs has buffer-substring-no-properties? 305 ;; Does this emacs has buffer-substring-no-properties?
281 ;; 306 ;;
282 (setq bufsubst-fun (if (fboundp 'buffer-substring-no-properties) 307 (if (fboundp 'buffer-substring-no-properties)
283 (symbol-function 'buffer-substring-no-properties) 308 'buffer-substring-no-properties
284 (symbol-function 'buffer-substring))) 309 'buffer-substring)))
285 (goto-char (point-max)) 310 (goto-char (point-max))
286 (imenu-progress-message stupid 0) 311 (imenu-progress-message stupid 0)
287 ;; 312 ;;
@@ -290,11 +315,10 @@ Example:
290 (setq langnum (if (match-beginning OBJC) 315 (setq langnum (if (match-beginning OBJC)
291 OBJC 316 OBJC
292 (cond 317 (cond
293 ((match-beginning C3) C3) 318 ((match-beginning Cproto) Cproto)
294 ((match-beginning C2) C2) 319 ((match-beginning Cgeneralfunc) Cgeneralfunc)
295 ((match-beginning C1) C1)))) 320 ((match-beginning Cnoreturn) Cnoreturn))))
296 (setq str (funcall bufsubst-fun 321 (setq str (funcall func (match-beginning langnum) (match-end langnum)))
297 (match-beginning langnum) (match-end langnum)))
298 ;; 322 ;;
299 (cond 323 (cond
300 ;; 324 ;;