Mercurial > emacs
annotate lisp/progmodes/cc-menus.el @ 79377:dc27351d0e7f
(menu-bar-help-menu):
Move "About Emacs" and "About GNU" to the end of the Help menu.
Move "Emacs Psychotherapist" after "Send Bug Report...".
Move "External Packages" after "Find Emacs Packages".
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Sun, 11 Nov 2007 20:23:41 +0000 |
parents | 5a26fd1686ae |
children | a1342e6e097a 1251cabc40b7 |
rev | line source |
---|---|
18720 | 1 ;;; cc-menus.el --- imenu support for CC Mode |
2 | |
74372 | 3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
75347 | 4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
5 ;; Free Software Foundation, Inc. | |
18720 | 6 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
7 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
8 ;; 1992-1999 Barry A. Warsaw |
18720 | 9 ;; 1987 Dave Detlefs and Stewart Clamen |
10 ;; 1985 Richard M. Stallman | |
24282 | 11 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 12 ;; 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
|
13 ;; Version: See cc-mode.el |
18720 | 14 ;; Keywords: c languages oop |
15 | |
16 ;; This file is part of GNU Emacs. | |
17 | |
18 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
19 ;; it under the terms of the GNU General Public License as published by | |
78234
c1ec1c8a8d2e
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
20 ;; the Free Software Foundation; either version 3, or (at your option) |
18720 | 21 ;; any later version. |
22 | |
23 ;; GNU Emacs is distributed in the hope that it will be useful, | |
24 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
26 ;; GNU General Public License for more details. | |
27 | |
28 ;; You should have received a copy of the GNU General Public License | |
67252
04d2abb755d9
Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
64699
diff
changeset
|
29 ;; along with this program; see the file COPYING. If not, write to |
64085 | 30 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
31 ;; Boston, MA 02110-1301, USA. | |
18720 | 32 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
34 |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
35 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
36 |
24282 | 37 (eval-when-compile |
26817 | 38 (let ((load-path |
36920 | 39 (if (and (boundp 'byte-compile-dest-file) |
40 (stringp byte-compile-dest-file)) | |
41 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 42 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
43 (load "cc-bytecomp" nil t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
44 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
45 (cc-require 'cc-defs) |
26817 | 46 |
36920 | 47 ;; The things referenced in imenu, which we don't require. |
48 (cc-bytecomp-defvar imenu-case-fold-search) | |
49 (cc-bytecomp-defvar imenu-generic-expression) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
50 (cc-bytecomp-defvar imenu-create-index-function) |
36920 | 51 (cc-bytecomp-defun imenu-progress-message) |
24282 | 52 |
18720 | 53 |
54 ;; imenu integration | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
55 (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
|
56 "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
|
57 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
58 For example: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
59 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
60 #ifdef __STDC__ |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
61 #define _P(x) x |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
62 #else |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
63 #define _P(x) /*nothing*/ |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
64 #endif |
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 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
|
67 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
68 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
|
69 |
18720 | 70 (defvar cc-imenu-c++-generic-expression |
26817 | 71 `( |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
72 ;; 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
|
73 ;; 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
|
74 ;; 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
|
75 (nil |
26817 | 76 ,(concat |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
77 "^\\<.*" |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
78 "[^" c-alnum "_:<>~]" ; match any non-identifier char |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
79 ; (note: this can be `\n') |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
80 "\\(" |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
81 "\\([" c-alnum "_:<>~]*::\\)?" ; match an operator |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
82 "operator\\>[ \t]*" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
83 "\\(()\\|[^(]*\\)" ; special case for `()' operator |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
84 "\\)" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
85 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
86 "[ \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
|
87 ; require something other than |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
88 ; a `;' after the (...) to |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
89 ; avoid prototypes. Can't |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
90 ; catch cases with () inside |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
91 ; the parentheses surrounding |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
92 ; the parameters. e.g.: |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
93 ; `int foo(int a=bar()) {...}' |
26817 | 94 ) 1) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
95 ;; 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
|
96 ;; 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
|
97 (nil |
26817 | 98 ,(concat |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
99 "^" |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
100 "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name |
20916 | 101 "[ \t]*(" ; see above, BUT |
102 "[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start | |
103 "[ \t]*[^ \t;(]" ; with an asterisk or parentheses | |
26817 | 104 ) 1) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
105 ;; General function name regexp |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
106 (nil |
26817 | 107 ,(concat |
108 "^\\<" ; line MUST start with word char | |
79114
5a26fd1686ae
(cc-imenu-c++-generic-expression): Tweak regexp to avoid overflow.
Glenn Morris <rgm@gnu.org>
parents:
78234
diff
changeset
|
109 ;; \n added to prevent overflow in regexp matcher. |
5a26fd1686ae
(cc-imenu-c++-generic-expression): Tweak regexp to avoid overflow.
Glenn Morris <rgm@gnu.org>
parents:
78234
diff
changeset
|
110 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-02/msg00021.html |
5a26fd1686ae
(cc-imenu-c++-generic-expression): Tweak regexp to avoid overflow.
Glenn Morris <rgm@gnu.org>
parents:
78234
diff
changeset
|
111 "[^()\n]*" ; no parentheses before |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
112 "[^" c-alnum "_:<>~]" ; match any non-identifier char |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
113 "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
114 "\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
115 "\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
116 "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses |
26817 | 117 ) 1) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
118 ;; 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
|
119 ;; `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
|
120 ;; 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
|
121 ;; Only supported in c-code, so no `:<>~' chars in function name! |
26817 | 122 ,@(if cc-imenu-c-prototype-macro-regexp |
123 `((nil | |
124 ,(concat | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
125 "^\\<.*" ; line MUST start with word char |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
126 "[^" c-alnum "_]" ; match any non-identifier char |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
127 "\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
128 "[ \t]*" ; whitespace before macro name |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
129 cc-imenu-c-prototype-macro-regexp |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
130 "[ \t]*(" ; ws followed by first paren. |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
131 "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above |
26817 | 132 ) 1))) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
133 ;; Class definitions |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
134 ("Class" |
26817 | 135 ,(concat |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
136 "^" ; beginning of line is required |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
137 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>' |
36920 | 138 "\\(class\\|struct\\)[ \t]+" |
24282 | 139 "\\(" ; the string we want to get |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
140 "[" c-alnum "_]+" ; class name |
36920 | 141 "\\(<[^>]+>\\)?" ; possibly explicitly specialized |
24282 | 142 "\\)" |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
143 "\\([ \t\n]\\|\\\\\n\\)*[:{]" |
36920 | 144 ) 3)) |
18720 | 145 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
146 |
18720 | 147 (defvar cc-imenu-c-generic-expression |
148 cc-imenu-c++-generic-expression | |
149 "Imenu generic expression for C mode. See `imenu-generic-expression'.") | |
150 | |
151 (defvar cc-imenu-java-generic-expression | |
26817 | 152 `((nil |
153 ,(concat | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
154 "[" c-alpha "_][\]\[." c-alnum "_]+[ \t\n\r]+" ; type spec |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
155 "\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
156 "[ \t\n\r]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
157 ;; An argument list that is either empty or contains at least |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
158 ;; two identifiers with only space between them. This avoids |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
159 ;; matching e.g. "else if (foo)". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
160 (concat "([ \t\n\r]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
161 "\\([\]\[.," c-alnum "_]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
162 "[ \t\n\r]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
163 "[\]\[.," c-alnum "_]" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
164 "[\]\[.," c-alnum "_ \t\n\r]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
165 "\\)?)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
166 "[.," c-alnum "_ \t\n\r]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
167 "{" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
168 ) 1)) |
18720 | 169 "Imenu generic expression for Java mode. See `imenu-generic-expression'.") |
170 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
171 ;; *Warning for cc-mode developers* |
20916 | 172 ;; |
173 ;; `cc-imenu-objc-generic-expression' elements depend on | |
174 ;; `cc-imenu-c++-generic-expression'. So if you change this | |
175 ;; expression, you need to change following variables, | |
176 ;; `cc-imenu-objc-generic-expression-*-index', | |
177 ;; too. `cc-imenu-objc-function' uses these *-index variables, in | |
178 ;; order to know where the each regexp *group \\(foobar\\)* elements | |
179 ;; are started. | |
180 ;; | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
181 ;; *-index variables are initialized during `cc-imenu-objc-generic-expression' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
182 ;; being initialized. |
20916 | 183 ;; |
184 | |
185 ;; Internal variables | |
186 (defvar cc-imenu-objc-generic-expression-noreturn-index nil) | |
187 (defvar cc-imenu-objc-generic-expression-general-func-index nil) | |
188 (defvar cc-imenu-objc-generic-expression-proto-index nil) | |
189 (defvar cc-imenu-objc-generic-expression-objc-base-index nil) | |
190 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
191 (defvar cc-imenu-objc-generic-expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
192 (concat |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
193 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
194 ;; For C |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
195 ;; |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
196 ;; > Special case to match a line like `main() {}' |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
197 ;; > 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
|
198 ;; Pick a token by (match-string 1) |
20916 | 199 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2 |
200 (prog2 (setq cc-imenu-objc-generic-expression-noreturn-index 1) "") | |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
201 "\\|" |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
202 ;; > General function name regexp |
20916 | 203 ;; Pick a token by (match-string 3) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
204 (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5 |
20916 | 205 (prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "") |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
206 ;; > 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
|
207 ;; > `int main _PROTO( (int argc,char *argv[]) )'. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
208 ;; Pick a token by (match-string 8) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
209 (if cc-imenu-c-prototype-macro-regexp |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
210 (concat |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
211 "\\|" |
20916 | 212 (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
213 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "") |
20916 | 214 ) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
215 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "") |
20916 | 216 "") ; -> index += 0 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
217 (prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "") |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
218 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
219 ;; For Objective-C |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
220 ;; Pick a token by (match-string 8 or 9) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
221 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
222 "\\|\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
223 "^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
224 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
225 "^@interface[\t ]+[" c-alnum "_]+[\t ]*:" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
226 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
227 "^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
228 "\\|" |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
229 ;; For NSObject, NSProxy and Object... They don't have super class. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
230 "^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
231 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
232 "^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
233 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
234 "^@implementation[\t ]+[" c-alnum "_]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
235 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
236 "^@protocol[\t ]+[" c-alnum "_]+" "\\)") |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
237 "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
|
238 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
239 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
240 ;; 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
|
241 (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
|
242 "Return the objc selector style string of METHOD. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
243 Example: |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
244 - 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
|
245 => |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
246 -perform:withObject:withObject:withObject: /* selector */" |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
247 (let ((return "") ; String to be returned |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
248 (p 0) ; Current scanning position in METHOD |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
249 (pmax (length method)) ; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
250 char ; Current scanning target |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
251 (betweenparen 0) ; CHAR is in parentheses. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
252 argreq ; An argument is required. |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
253 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
|
254 (while (< p pmax) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
255 (setq char (aref method p) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
256 p (1+ p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
257 (cond |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
258 ;; 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
|
259 ((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
|
260 (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
|
261 (or (and (<= ?a char) (<= char ?z)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
262 (and (<= ?A char) (<= char ?Z)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
263 (and (<= ?0 char) (<= char ?9)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
264 (= ?_ char))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
265 (if argreq |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
266 (setq inargvar t |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
267 argreq nil) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
268 (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
|
269 ;; Or a white space? |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
270 ((and inargvar (or (eq ?\ char) (eq ?\n char)) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
271 (setq inargvar nil))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
272 ;; Or a method separator? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
273 ;; If a method separator, the next token will be an argument variable. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
274 ((eq ?: char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
275 (setq argreq t |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
276 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
|
277 ;; Or an open parentheses? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
278 ((eq ?\( char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
279 (setq betweenparen (1+ betweenparen))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
280 ;; Or a close parentheses? |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
281 ((eq ?\) char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
282 (setq betweenparen (1- betweenparen))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
283 return)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
284 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
285 (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
|
286 "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
|
287 (let ((return "") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
288 (p 0) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
289 (max (length str)) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
290 char) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
291 (while (< p max) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
292 (setq char (aref str p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
293 (setq p (1+ p)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
294 (if (or (= char ?\ ) (= char ?\t)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
295 () |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
296 (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
|
297 return)) |
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 (defun cc-imenu-objc-function () |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
300 "imenu supports for objc-mode." |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
301 (let (methodlist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
302 clist |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
303 ;; |
20916 | 304 ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants. |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
305 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
306 ;; *Warning for developers* |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
307 ;; 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
|
308 ;; |
20916 | 309 (OBJC cc-imenu-objc-generic-expression-objc-base-index) |
310 ;; Special case to match a line like `main() {}' | |
311 (Cnoreturn cc-imenu-objc-generic-expression-noreturn-index) | |
312 ;; General function name regexp | |
313 (Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index) | |
314 ;; Special case for definitions using phony prototype macros like: | |
315 (Cproto cc-imenu-objc-generic-expression-proto-index) | |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
316 langnum |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
317 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
318 (classcount 0) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
319 toplist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
320 stupid |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
321 str |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
322 str2 |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
323 (intflen (length "@interface")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
324 (implen (length "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
325 (prtlen (length "@protocol")) |
20916 | 326 (func |
327 ;; | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
328 ;; Does this emacs has buffer-substring-no-properties? |
20916 | 329 ;; |
330 (if (fboundp 'buffer-substring-no-properties) | |
331 'buffer-substring-no-properties | |
332 'buffer-substring))) | |
24282 | 333 (goto-char (point-max)) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
334 (imenu-progress-message stupid 0) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
335 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
336 (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
|
337 (imenu-progress-message stupid) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
338 (setq langnum (if (match-beginning OBJC) |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
339 OBJC |
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
340 (cond |
20916 | 341 ((match-beginning Cproto) Cproto) |
342 ((match-beginning Cgeneralfunc) Cgeneralfunc) | |
343 ((match-beginning Cnoreturn) Cnoreturn)))) | |
344 (setq str (funcall func (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
|
345 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
346 (cond |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
347 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
348 ;; C |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
349 ;; |
20145
cfd9922ca72b
Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents:
20134
diff
changeset
|
350 ((not (eq langnum OBJC)) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
351 (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
|
352 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
353 ;; ObjC |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
354 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
355 ;; An instance Method |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
356 ((eq (aref str 0) ?-) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
357 (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
|
358 (setq methodlist (cons (cons str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
359 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
360 methodlist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
361 ;; A factory Method |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
362 ((eq (aref str 0) ?+) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
363 (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
|
364 (setq methodlist (cons (cons str |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
365 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
366 methodlist))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
367 ;; Interface or implementation or protocol |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
368 ((eq (aref str 0) ?@) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
369 (setq classcount (1+ classcount)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
370 (cond |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
371 ((and (> (length str) implen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
372 (string= (substring str 0 implen) "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
373 (setq str (substring str implen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
374 str2 "@implementation")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
375 ((string= (substring str 0 intflen) "@interface") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
376 (setq str (substring str intflen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
377 str2 "@interface")) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
378 ((string= (substring str 0 prtlen) "@protocol") |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
379 (setq str (substring str prtlen) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
380 str2 "@protocol"))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
381 (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
|
382 (setq methodlist (cons (cons str2 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
383 (match-beginning langnum)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
384 methodlist)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
385 (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
|
386 methodlist) toplist)) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
387 methodlist nil)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
388 ;; |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
389 (imenu-progress-message stupid 100) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
390 (if (eq (car toplist) nil) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
391 (setq toplist (cdr toplist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
392 |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
393 ;; 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
|
394 (if (< classcount 2) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
395 (let ((classname (car (car toplist))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
396 (p (cdr (car (cdr (car toplist))))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
397 last) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
398 (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
|
399 ;; Add C lang token |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
400 (if clist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
401 (progn |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
402 (setq last toplist) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
403 (while (cdr last) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
404 (setq last (cdr last))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
405 (setcdr last clist)))) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
406 ;; Add C lang tokens as a sub menu |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
407 (if clist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
408 (setq toplist (cons (cons "C" clist) toplist)))) |
20134
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
409 ;; |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
410 toplist |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
411 )) |
7eb314cf3574
(cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents:
19809
diff
changeset
|
412 |
24282 | 413 ;(defvar cc-imenu-pike-generic-expression |
414 ; ()) | |
415 ; FIXME: Please contribute one! | |
416 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
417 (defun cc-imenu-init (mode-generic-expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
418 &optional mode-create-index-function) |
26817 | 419 (setq imenu-generic-expression mode-generic-expression |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
420 imenu-case-fold-search nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
421 (when mode-create-index-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
422 (setq imenu-create-index-function mode-create-index-function))) |
26817 | 423 |
18720 | 424 |
36920 | 425 (cc-provide 'cc-menus) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
426 |
52401 | 427 ;;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b |
18720 | 428 ;;; cc-menus.el ends here |