Mercurial > emacs
annotate lisp/progmodes/cc-menus.el @ 20507:07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 22 Dec 1997 07:10:19 +0000 |
parents | ac6d8d01e311 |
children | 704b7ccba694 |
rev | line source |
---|---|
18720 | 1 ;;; cc-menus.el --- imenu support for CC Mode |
2 | |
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc. | |
4 | |
5 ;; Authors: 1992-1997 Barry A. Warsaw | |
6 ;; 1987 Dave Detlefs and Stewart Clamen | |
7 ;; 1985 Richard M. Stallman | |
8 ;; Maintainer: cc-mode-help@python.org | |
9 ;; Created: 22-Apr-1997 (split from cc-mode.el) | |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
10 ;; Version: See cc-mode.el |
18720 | 11 ;; Keywords: c languages oop |
12 | |
13 ;; This file is part of GNU Emacs. | |
14 | |
15 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
16 ;; it under the terms of the GNU General Public License as published by | |
17 ;; the Free Software Foundation; either version 2, or (at your option) | |
18 ;; any later version. | |
19 | |
20 ;; GNU Emacs is distributed in the hope that it will be useful, | |
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 ;; GNU General Public License for more details. | |
24 | |
25 ;; You should have received a copy of the GNU General Public License | |
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
28 ;; Boston, MA 02111-1307, USA. | |
29 | |
30 | |
31 ;; imenu integration | |
20407 | 32 (require 'imenu) |
33 | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
34 (defvar cc-imenu-c-prototype-macro-regexp nil |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
35 "RE matching macro names used to conditionally specify function prototypes. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
36 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
37 For example: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
38 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
39 #ifdef __STDC__ |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
40 #define _P(x) x |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
41 #else |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
42 #define _P(x) /*nothing*/ |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
43 #endif |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
44 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
45 int main _P( (int argc, char *argv[]) ) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
46 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
47 A sample value might look like: `\\(_P\\|_PROTO\\)'.") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
48 |
18720 | 49 (defvar cc-imenu-c++-generic-expression |
50 (` | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
51 ( |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
52 ;; Try to match ::operator definitions first. Otherwise `X::operator new ()' |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
53 ;; will be incorrectly recognised as function `new ()' because the regexps |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
54 ;; work by backtracking from the end of the definition. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
55 (nil |
18720 | 56 (, |
57 (concat | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
58 "^\\<.*" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
59 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
60 ; (note: this can be `\n') |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
61 "\\(" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
62 "\\([a-zA-Z0-9_:<>~]*::\\)?" ; match an operator |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
63 "operator\\>[ \t]*" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
64 "\\(()\\|[^(]*\\)" ; special case for `()' operator |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
65 "\\)" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
66 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
67 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; followed by ws, arg list, |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
68 ; require something other than |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
69 ; a `;' after the (...) to |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
70 ; avoid prototypes. Can't |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
71 ; catch cases with () inside |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
72 ; the parentheses surrounding |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
73 ; the parameters. e.g.: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
74 ; `int foo(int a=bar()) {...}' |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
75 )) 1) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
76 ;; Special case to match a line like `main() {}' |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
77 ;; e.g. no return type, not even on the previous line. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
78 (nil |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
79 (, |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
80 (concat |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
81 "^" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
82 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
83 "[ \t]*([^)]*)[ \t]*[^ \t;]" ; see above |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
84 )) 1) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
85 ;; General function name regexp |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
86 (nil |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
87 (, |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
88 (concat |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
89 "^\\<.*" ; line MUST start with word char |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
90 "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
91 "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
92 "[ \t]*(" ; see above, BUT |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
93 "[ \t]*[^ \t(][^)]*)[ \t]*[^ \t;]" ; the argument list must not start |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
94 ; with a parentheses |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
95 )) 1) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
96 ;; Special case for definitions using phony prototype macros like: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
97 ;; `int main _PROTO( (int argc,char *argv[]) )'. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
98 ;; This case is only included if cc-imenu-c-prototype-macro-regexp is set. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
99 ;; Only supported in c-code, so no `:<>~' chars in function name! |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
100 (,@ (if cc-imenu-c-prototype-macro-regexp |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
101 (` ((nil |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
102 (, |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
103 (concat |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
104 "^\\<.*" ; line MUST start with word char |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
105 "[^a-zA-Z0-9_]" ; match any non-identifier char |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
106 "\\([a-zA-Z_][a-zA-Z0-9_]*\\)" ; match function name |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
107 "[ \t]*" ; whitespace before macro name |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
108 cc-imenu-c-prototype-macro-regexp |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
109 "[ \t]*(" ; ws followed by first paren. |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
110 "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
111 )) 1))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
112 ;; Class definitions |
18720 | 113 ("Class" |
114 (, (concat | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
115 "^" ; beginning of line is required |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
116 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>' |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
117 "class[ \t]+" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
118 "\\([a-zA-Z0-9_]+\\)" ; the string we want to get |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
119 "[ \t]*[:{]" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
120 )) 2))) |
18720 | 121 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") |
122 | |
123 (defvar cc-imenu-c-generic-expression | |
124 cc-imenu-c++-generic-expression | |
125 "Imenu generic expression for C mode. See `imenu-generic-expression'.") | |
126 | |
127 (defvar cc-imenu-java-generic-expression | |
128 (` | |
129 ((nil | |
130 (, | |
131 (concat | |
132 "^\\([ \t]\\)*" | |
133 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; type specs; there can be | |
134 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; more than 3 tokens, right? | |
135 "\\([A-Za-z0-9_-]+[ \t]*[[]?[]]?\\)" | |
136 "\\([ \t]\\)" | |
137 "\\([A-Za-z0-9_-]+\\)" ; the string we want to get | |
138 "\\([ \t]*\\)+(" | |
139 "\\([a-zA-Z,_1-9\n \t]*[[]?[]]?\\)*" ; arguments | |
140 ")[ \t]*" | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
141 ; "[^;(]" |
18720 | 142 "[,a-zA-Z_1-9\n \t]*{" |
143 )) 6))) | |
144 "Imenu generic expression for Java mode. See `imenu-generic-expression'.") | |
145 | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
146 (defvar cc-imenu-objc-generic-expression |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
147 (concat |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
148 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
149 ;; For C |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
150 ;; *Warning for developers* |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
151 ;; This expression elements depend on `cc-imenu-c++-generic-expression'. |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
152 ;; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
153 ;; > Special case to match a line like `main() {}' |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
154 ;; > e.g. no return type, not even on the previous line. |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
155 ;; Pick a token by (match-string 1) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
156 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
157 "\\|" |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
158 ;; > General function name regexp |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
159 ;; Pick a token by (match-string 2) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
160 (car (cdr (nth 2 cc-imenu-c++-generic-expression))) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
161 ;; > Special case for definitions using phony prototype macros like: |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
162 ;; > `int main _PROTO( (int argc,char *argv[]) )'. |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
163 ;; Pick a token by (match-string 3) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
164 (if cc-imenu-c-prototype-macro-regexp |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
165 (concat |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
166 "\\|" |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
167 (car (cdr (nth 3 cc-imenu-c++-generic-expression)))) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
168 "") |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
169 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
170 ;; For Objective-C |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
171 ;; Pick a token by (match-string 3 or 4) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
172 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
173 "\\|\\(" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
174 "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
175 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
176 "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*:" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
177 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
178 "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
179 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
180 ;; For NSObject, NSProxy and Object... They don't have super class. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
181 "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*.*$" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
182 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
183 "^@implementation[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
184 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
185 "^@implementation[\t ]+[a-zA-Z0-9_]+" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
186 "\\|" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
187 "^@protocol[\t ]+[a-zA-Z0-9_]+" "\\)") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
188 "Imenu generic expression for ObjC mode. See `imenu-generic-expression'.") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
189 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
190 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
191 ;; Imenu support for objective-c uses functions. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
192 (defsubst cc-imenu-objc-method-to-selector (method) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
193 "Return the objc selector style string of METHOD. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
194 Example: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
195 - perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */ |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
196 => |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
197 -perform:withObject:withObject:withObject: /* selector */" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
198 (let ((return "") ; String to be returned |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
199 (p 0) ; Current scanning position in METHOD |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
200 (pmax (length method)) ; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
201 char ; Current scanning target |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
202 (betweenparen 0) ; CHAR is in parentheses. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
203 argreq ; An argument is required. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
204 inargvar) ; position of CHAR is in an argument variable. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
205 (while (< p pmax) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
206 (setq char (aref method p) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
207 p (1+ p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
208 (cond |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
209 ;; Is CHAR part of a objc token? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
210 ((and (not inargvar) ; Ignore if CHAR is part of an argument variable. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
211 (eq 0 betweenparen) ; Ignore if CHAR is in parentheses. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
212 (or (and (<= ?a char) (<= char ?z)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
213 (and (<= ?A char) (<= char ?Z)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
214 (and (<= ?0 char) (<= char ?9)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
215 (= ?_ char))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
216 (if argreq |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
217 (setq inargvar t |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
218 argreq nil) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
219 (setq return (concat return (char-to-string char))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
220 ;; Or a white space? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
221 ((and inargvar (or (eq ?\ char) (eq ?\n char)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
222 (setq inargvar nil))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
223 ;; Or a method separator? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
224 ;; If a method separator, the next token will be an argument variable. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
225 ((eq ?: char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
226 (setq argreq t |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
227 return (concat return (char-to-string char)))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
228 ;; Or an open parentheses? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
229 ((eq ?\( char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
230 (setq betweenparen (1+ betweenparen))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
231 ;; Or a close parentheses? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
232 ((eq ?\) char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
233 (setq betweenparen (1- betweenparen))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
234 return)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
235 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
236 (defun cc-imenu-objc-remove-white-space (str) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
237 "Remove all spaces and tabs from STR." |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
238 (let ((return "") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
239 (p 0) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
240 (max (length str)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
241 char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
242 (while (< p max) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
243 (setq char (aref str p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
244 (setq p (1+ p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
245 (if (or (= char ?\ ) (= char ?\t)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
246 () |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
247 (setq return (concat return (char-to-string char))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
248 return)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
249 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
250 (defun cc-imenu-objc-function () |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
251 "imenu supports for objc-mode." |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
252 (let (methodlist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
253 clist |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
254 ;; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
255 ;; OBJC, C1, C2, C3 are constants. |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
256 ;; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
257 ;; *Warning for developers* |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
258 ;; These constants depend on `cc-imenu-c++-generic-expression'. |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
259 ;; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
260 (OBJC |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
261 (if cc-imenu-c-prototype-macro-regexp 4 3)) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
262 (C1 ; > Special case to match a line like `main() {}' |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
263 1) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
264 (C2 ; > General function name regexp |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
265 2) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
266 (C3 ; > Special case for definitions using phony prototype macros like: |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
267 3) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
268 langnum |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
269 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
270 (classcount 0) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
271 toplist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
272 stupid |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
273 str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
274 str2 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
275 (intflen (length "@interface")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
276 (implen (length "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
277 (prtlen (length "@protocol")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
278 bufsubst-fun) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
279 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
280 ;; Does this emacs has buffer-substring-no-properties? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
281 ;; |
20507
07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
Richard M. Stallman <rms@gnu.org>
parents:
20407
diff
changeset
|
282 (setq bufsubst-fun (if (fboundp 'buffer-substring-no-properties) |
07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
Richard M. Stallman <rms@gnu.org>
parents:
20407
diff
changeset
|
283 (symbol-function 'buffer-substring-no-properties) |
07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
Richard M. Stallman <rms@gnu.org>
parents:
20407
diff
changeset
|
284 (symbol-function 'buffer-substring))) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
285 (goto-char (point-max)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
286 (imenu-progress-message stupid 0) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
287 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
288 (while (re-search-backward cc-imenu-objc-generic-expression nil t) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
289 (imenu-progress-message stupid) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
290 (setq langnum (if (match-beginning OBJC) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
291 OBJC |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
292 (cond |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
293 ((match-beginning C3) C3) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
294 ((match-beginning C2) C2) |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
295 ((match-beginning C1) C1)))) |
20507
07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
Richard M. Stallman <rms@gnu.org>
parents:
20407
diff
changeset
|
296 (setq str (funcall bufsubst-fun |
07a8c7f7cfe8
(cc-imenu-objc-function): Use bufsubst-fun as a variable, not as a function.
Richard M. Stallman <rms@gnu.org>
parents:
20407
diff
changeset
|
297 (match-beginning langnum) (match-end langnum))) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
298 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
299 (cond |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
300 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
301 ;; C |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
302 ;; |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
303 ((not (eq langnum OBJC)) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
304 (setq clist (cons (cons str (match-beginning langnum)) clist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
305 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
306 ;; ObjC |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
307 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
308 ;; An instance Method |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
309 ((eq (aref str 0) ?-) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
310 (setq str (concat "-" (cc-imenu-objc-method-to-selector str))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
311 (setq methodlist (cons (cons str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
312 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
313 methodlist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
314 ;; A factory Method |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
315 ((eq (aref str 0) ?+) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
316 (setq str (concat "+" (cc-imenu-objc-method-to-selector str))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
317 (setq methodlist (cons (cons str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
318 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
319 methodlist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
320 ;; Interface or implementation or protocol |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
321 ((eq (aref str 0) ?@) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
322 (setq classcount (1+ classcount)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
323 (cond |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
324 ((and (> (length str) implen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
325 (string= (substring str 0 implen) "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
326 (setq str (substring str implen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
327 str2 "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
328 ((string= (substring str 0 intflen) "@interface") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
329 (setq str (substring str intflen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
330 str2 "@interface")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
331 ((string= (substring str 0 prtlen) "@protocol") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
332 (setq str (substring str prtlen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
333 str2 "@protocol"))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
334 (setq str (cc-imenu-objc-remove-white-space str)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
335 (setq methodlist (cons (cons str2 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
336 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
337 methodlist)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
338 (setq toplist (cons nil (cons (cons str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
339 methodlist) toplist)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
340 methodlist nil)))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
341 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
342 (imenu-progress-message stupid 100) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
343 (if (eq (car toplist) nil) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
344 (setq toplist (cdr toplist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
345 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
346 ;; In this buffer, there is only one or zero @{interface|implementation|protocol}. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
347 (if (< classcount 2) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
348 (let ((classname (car (car toplist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
349 (p (cdr (car (cdr (car toplist))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
350 last) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
351 (setq toplist (cons (cons classname p) (cdr (cdr (car toplist))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
352 ;; Add C lang token |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
353 (if clist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
354 (progn |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
355 (setq last toplist) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
356 (while (cdr last) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
357 (setq last (cdr last))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
358 (setcdr last clist)))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
359 ;; Add C lang tokens as a sub menu |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
360 (setq toplist (cons (cons "C" clist) toplist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
361 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
362 toplist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
363 )) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
364 |
18720 | 365 |
366 (provide 'cc-menus) | |
367 ;;; cc-menus.el ends here |