mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-17 17:58:46 +00:00
Patches to Imenu support given by
"Masatake (jet) YAMATO" <masata-y@is.aist-nara.ac.jp>.
This commit is contained in:
parent
541aeedfa6
commit
8729df5954
@ -7,7 +7,7 @@
|
||||
;; 1985 Richard M. Stallman
|
||||
;; Maintainer: cc-mode-help@python.org
|
||||
;; Created: 22-Apr-1997 (split from cc-mode.el)
|
||||
;; Version: 5.18
|
||||
;; Version: See cc-mode.el
|
||||
;; Keywords: c languages oop
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
@ -80,6 +80,17 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
||||
"\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
|
||||
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above
|
||||
)) 1)
|
||||
;; General function name regexp
|
||||
(nil
|
||||
(,
|
||||
(concat
|
||||
"^\\<.*" ; line MUST start with word char
|
||||
"[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
|
||||
"\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
|
||||
"[ \t]*(" ; see above, BUT
|
||||
"[ \t]*[^ \t(][^)]*)[ \t]*[^ \t;]" ; the argument list must not start
|
||||
; with a parentheses
|
||||
)) 1)
|
||||
;; Special case for definitions using phony prototype macros like:
|
||||
;; `int main _PROTO( (int argc,char *argv[]) )'.
|
||||
;; 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\\)'.")
|
||||
"[ \t]*" ; whitespace before macro name
|
||||
cc-imenu-c-prototype-macro-regexp
|
||||
"[ \t]*(" ; ws followed by first paren.
|
||||
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above
|
||||
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
|
||||
)) 1)))))
|
||||
;; General function name regexp
|
||||
(nil
|
||||
(,
|
||||
(concat
|
||||
"^\\<.*" ; line MUST start with word char
|
||||
"[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
|
||||
"\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
|
||||
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above
|
||||
)) 1)
|
||||
;; Class definitions
|
||||
("Class"
|
||||
(, (concat
|
||||
@ -141,11 +143,31 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
||||
|
||||
(defvar cc-imenu-objc-generic-expression
|
||||
(concat
|
||||
;;
|
||||
;; For C
|
||||
;; Pick a token by (match-string 6)
|
||||
(car (cdr (car cc-imenu-c++-generic-expression)))
|
||||
;; *Warning for developers*
|
||||
;; This expression elements depend on `cc-imenu-c++-generic-expression'.
|
||||
;;
|
||||
;; > Special case to match a line like `main() {}'
|
||||
;; > e.g. no return type, not even on the previous line.
|
||||
;; Pick a token by (match-string 1)
|
||||
(car (cdr (nth 1 cc-imenu-c++-generic-expression))) ;
|
||||
"\\|"
|
||||
;; > General function name regexp
|
||||
;; Pick a token by (match-string 2)
|
||||
(car (cdr (nth 2 cc-imenu-c++-generic-expression)))
|
||||
;; > Special case for definitions using phony prototype macros like:
|
||||
;; > `int main _PROTO( (int argc,char *argv[]) )'.
|
||||
;; Pick a token by (match-string 3)
|
||||
(if cc-imenu-c-prototype-macro-regexp
|
||||
(concat
|
||||
"\\|"
|
||||
(car (cdr (nth 3 cc-imenu-c++-generic-expression))))
|
||||
"")
|
||||
;;
|
||||
;; For Objective-C
|
||||
;; Pick a token by (match-string 8)
|
||||
;; Pick a token by (match-string 3 or 4)
|
||||
;;
|
||||
"\\|\\("
|
||||
"^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods
|
||||
"\\|"
|
||||
@ -227,9 +249,22 @@ Example:
|
||||
"imenu supports for objc-mode."
|
||||
(let (methodlist
|
||||
clist
|
||||
(C 6)
|
||||
(OBJC 8)
|
||||
;;
|
||||
;; OBJC, C1, C2, C3 are constants.
|
||||
;;
|
||||
;; *Warning for developers*
|
||||
;; These constants depend on `cc-imenu-c++-generic-expression'.
|
||||
;;
|
||||
(OBJC
|
||||
(if cc-imenu-c-prototype-macro-regexp 4 3))
|
||||
(C1 ; > Special case to match a line like `main() {}'
|
||||
1)
|
||||
(C2 ; > General function name regexp
|
||||
2)
|
||||
(C3 ; > Special case for definitions using phony prototype macros like:
|
||||
3)
|
||||
langnum
|
||||
;;
|
||||
(classcount 0)
|
||||
toplist
|
||||
stupid
|
||||
@ -250,14 +285,19 @@ Example:
|
||||
;;
|
||||
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
|
||||
(imenu-progress-message stupid)
|
||||
(setq langnum (if (match-beginning C) C OBJC))
|
||||
(setq langnum (if (match-beginning OBJC)
|
||||
OBJC
|
||||
(cond
|
||||
((match-beginning C3) C3)
|
||||
((match-beginning C2) C2)
|
||||
((match-beginning C1) C1))))
|
||||
(setq str (bufsubst-fun (match-beginning langnum) (match-end langnum)))
|
||||
;;
|
||||
(cond
|
||||
;;
|
||||
;; C
|
||||
;;
|
||||
((eq langnum C)
|
||||
((not (eq langnum OBJC))
|
||||
(setq clist (cons (cons str (match-beginning langnum)) clist)))
|
||||
;;
|
||||
;; ObjC
|
||||
|
Loading…
Reference in New Issue
Block a user