aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-10-23 07:49:06 +0000
committerKarl Heuer1997-10-23 07:49:06 +0000
commit8729df595475691f05fb483017bfe9500f7f3ee8 (patch)
treecb3c25bd5474398faab2688ab62d78e1f383bac1
parent541aeedfa64b68ab735a6b18ad15e8e10dc77d9b (diff)
downloademacs-8729df595475691f05fb483017bfe9500f7f3ee8.tar.gz
emacs-8729df595475691f05fb483017bfe9500f7f3ee8.zip
Patches to Imenu support given by
"Masatake (jet) YAMATO" <masata-y@is.aist-nara.ac.jp>.
-rw-r--r--lisp/progmodes/cc-menus.el76
1 files changed, 58 insertions, 18 deletions
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el
index d758d0707f8..bccede45582 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -7,7 +7,7 @@
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: 22-Apr-1997 (split from cc-mode.el) 9;; Created: 22-Apr-1997 (split from cc-mode.el)
10;; Version: 5.18 10;; Version: See cc-mode.el
11;; Keywords: c languages oop 11;; Keywords: c languages oop
12 12
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -80,6 +80,17 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
80 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name 80 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
81 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above 81 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above
82 )) 1) 82 )) 1)
83 ;; General function name regexp
84 (nil
85 (,
86 (concat
87 "^\\<.*" ; line MUST start with word char
88 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
89 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
90 "[ \t]*(" ; see above, BUT
91 "[ \t]*[^ \t(][^)]*)[ \t]*[^ \t;]" ; the argument list must not start
92 ; with a parentheses
93 )) 1)
83 ;; Special case for definitions using phony prototype macros like: 94 ;; Special case for definitions using phony prototype macros like:
84 ;; `int main _PROTO( (int argc,char *argv[]) )'. 95 ;; `int main _PROTO( (int argc,char *argv[]) )'.
85 ;; This case is only included if cc-imenu-c-prototype-macro-regexp is set. 96 ;; This case is only included if cc-imenu-c-prototype-macro-regexp is set.
@@ -94,17 +105,8 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
94 "[ \t]*" ; whitespace before macro name 105 "[ \t]*" ; whitespace before macro name
95 cc-imenu-c-prototype-macro-regexp 106 cc-imenu-c-prototype-macro-regexp
96 "[ \t]*(" ; ws followed by first paren. 107 "[ \t]*(" ; ws followed by first paren.
97 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above 108 "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
98 )) 1))))) 109 )) 1)))))
99 ;; General function name regexp
100 (nil
101 (,
102 (concat
103 "^\\<.*" ; line MUST start with word char
104 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
105 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
106 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above
107 )) 1)
108 ;; Class definitions 110 ;; Class definitions
109 ("Class" 111 ("Class"
110 (, (concat 112 (, (concat
@@ -141,11 +143,31 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
141 143
142(defvar cc-imenu-objc-generic-expression 144(defvar cc-imenu-objc-generic-expression
143 (concat 145 (concat
146 ;;
144 ;; For C 147 ;; For C
145 ;; Pick a token by (match-string 6) 148 ;; *Warning for developers*
146 (car (cdr (car cc-imenu-c++-generic-expression))) 149 ;; This expression elements depend on `cc-imenu-c++-generic-expression'.
150 ;;
151 ;; > Special case to match a line like `main() {}'
152 ;; > e.g. no return type, not even on the previous line.
153 ;; Pick a token by (match-string 1)
154 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ;
155 "\\|"
156 ;; > General function name regexp
157 ;; Pick a token by (match-string 2)
158 (car (cdr (nth 2 cc-imenu-c++-generic-expression)))
159 ;; > Special case for definitions using phony prototype macros like:
160 ;; > `int main _PROTO( (int argc,char *argv[]) )'.
161 ;; Pick a token by (match-string 3)
162 (if cc-imenu-c-prototype-macro-regexp
163 (concat
164 "\\|"
165 (car (cdr (nth 3 cc-imenu-c++-generic-expression))))
166 "")
167 ;;
147 ;; For Objective-C 168 ;; For Objective-C
148 ;; Pick a token by (match-string 8) 169 ;; Pick a token by (match-string 3 or 4)
170 ;;
149 "\\|\\(" 171 "\\|\\("
150 "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods 172 "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods
151 "\\|" 173 "\\|"
@@ -227,9 +249,22 @@ Example:
227 "imenu supports for objc-mode." 249 "imenu supports for objc-mode."
228 (let (methodlist 250 (let (methodlist
229 clist 251 clist
230 (C 6) 252 ;;
231 (OBJC 8) 253 ;; OBJC, C1, C2, C3 are constants.
254 ;;
255 ;; *Warning for developers*
256 ;; These constants depend on `cc-imenu-c++-generic-expression'.
257 ;;
258 (OBJC
259 (if cc-imenu-c-prototype-macro-regexp 4 3))
260 (C1 ; > Special case to match a line like `main() {}'
261 1)
262 (C2 ; > General function name regexp
263 2)
264 (C3 ; > Special case for definitions using phony prototype macros like:
265 3)
232 langnum 266 langnum
267 ;;
233 (classcount 0) 268 (classcount 0)
234 toplist 269 toplist
235 stupid 270 stupid
@@ -250,14 +285,19 @@ Example:
250 ;; 285 ;;
251 (while (re-search-backward cc-imenu-objc-generic-expression nil t) 286 (while (re-search-backward cc-imenu-objc-generic-expression nil t)
252 (imenu-progress-message stupid) 287 (imenu-progress-message stupid)
253 (setq langnum (if (match-beginning C) C OBJC)) 288 (setq langnum (if (match-beginning OBJC)
289 OBJC
290 (cond
291 ((match-beginning C3) C3)
292 ((match-beginning C2) C2)
293 ((match-beginning C1) C1))))
254 (setq str (bufsubst-fun (match-beginning langnum) (match-end langnum))) 294 (setq str (bufsubst-fun (match-beginning langnum) (match-end langnum)))
255 ;; 295 ;;
256 (cond 296 (cond
257 ;; 297 ;;
258 ;; C 298 ;; C
259 ;; 299 ;;
260 ((eq langnum C) 300 ((not (eq langnum OBJC))
261 (setq clist (cons (cons str (match-beginning langnum)) clist))) 301 (setq clist (cons (cons str (match-beginning langnum)) clist)))
262 ;; 302 ;;
263 ;; ObjC 303 ;; ObjC