annotate lisp/progmodes/cc-menus.el @ 108749:48378bcd6c35

Fix bug #6237. w32.c (sys_write): Break writes into chunks smaller than 32MB.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 22 May 2010 22:09:51 +0300
parents 1d1d5d9bd884
children 280c8ae2476d 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; cc-menus.el --- imenu support for CC Mode
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
74372
cf3e4c6cd4c3 Fix Copyright format.
Glenn Morris <rgm@gnu.org>
parents: 69140
diff changeset
3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106184
diff changeset
4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74372
diff changeset
5 ;; Free Software Foundation, Inc.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
101112
0685234e527d Comment (minor header format fixes).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
9 ;; 1987 Dave Detlefs
0685234e527d Comment (minor header format fixes).
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
10 ;; 1987 Stewart Clamen
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; 1985 Richard M. Stallman
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
12 ;; Maintainer: bug-cc-mode@gnu.org
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; 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
14 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; This file is part of GNU Emacs.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
19 ;; GNU Emacs is free software: you can redistribute it and/or modify
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; it under the terms of the GNU General Public License as published by
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; the Free Software Foundation, either version 3 of the License, or
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; (at your option) any later version.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; You should have received a copy of the GNU General Public License
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
30 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
32 ;;; Commentary:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
33
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
34 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
35
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
36 (eval-when-compile
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
37 (let ((load-path
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
38 (if (and (boundp 'byte-compile-dest-file)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
39 (stringp byte-compile-dest-file))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
40 (cons (file-name-directory byte-compile-dest-file) load-path)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
41 load-path)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
42 (load "cc-bytecomp" nil t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
43
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
44 (cc-require 'cc-defs)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
45
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
46 ;; The things referenced in imenu, which we don't require.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
47 (cc-bytecomp-defvar imenu-case-fold-search)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
48 (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
49 (cc-bytecomp-defvar imenu-create-index-function)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
50
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; imenu integration
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
53 (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
54 "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
55
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
56 For example:
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 #ifdef __STDC__
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
59 #define _P(x) x
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
60 #else
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
61 #define _P(x) /*nothing*/
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
62 #endif
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
63
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
64 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
65
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
66 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
67
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defvar cc-imenu-c++-generic-expression
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
69 `(
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
70 ;; 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
71 ;; 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
72 ;; 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
73 (nil
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
74 ,(concat
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
75 "^\\<.*"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
76 "[^" 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
77 ; (note: this can be `\n')
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
78 "\\("
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
79 "\\([" c-alnum "_:<>~]*::\\)?" ; match an operator
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
80 "operator\\>[ \t]*"
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
81 "\\(()\\|[^(]*\\)" ; special case for `()' operator
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
82 "\\)"
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
83
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
84 "[ \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
85 ; require something other than
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
86 ; a `;' after the (...) to
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
87 ; avoid prototypes. Can't
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
88 ; catch cases with () inside
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
89 ; the parentheses surrounding
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
90 ; the parameters. e.g.:
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
91 ; `int foo(int a=bar()) {...}'
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
92 ) 1)
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
93 ;; 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
94 ;; 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
95 (nil
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
96 ,(concat
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
97 "^"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
98 "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
99 "[ \t]*(" ; see above, BUT
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
100 "[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
101 "[ \t]*[^ \t;(]" ; with an asterisk or parentheses
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
102 ) 1)
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
103 ;; General function name regexp
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
104 (nil
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
105 ,(concat
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
106 "^\\<" ; 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
107 ;; \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
108 ;; 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
109 "[^()\n]*" ; no parentheses before
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
110 "[^" 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
111 "\\([" 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
112 "\\([ \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
113 "\\([ \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
114 "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
115 ) 1)
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
116 ;; 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
117 ;; `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
118 ;; 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
119 ;; Only supported in c-code, so no `:<>~' chars in function name!
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
120 ,@(if cc-imenu-c-prototype-macro-regexp
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
121 `((nil
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
122 ,(concat
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
123 "^\\<.*" ; 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
124 "[^" 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
125 "\\([" 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
126 "[ \t]*" ; whitespace before macro name
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
127 cc-imenu-c-prototype-macro-regexp
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
128 "[ \t]*(" ; ws followed by first paren.
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
129 "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
130 ) 1)))
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
131 ;; Class definitions
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
132 ("Class"
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
133 ,(concat
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
134 "^" ; beginning of line is required
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
135 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
136 "\\(class\\|struct\\)[ \t]+"
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
137 "\\(" ; 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
138 "[" c-alnum "_]+" ; class name
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
139 "\\(<[^>]+>\\)?" ; possibly explicitly specialized
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
140 "\\)"
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
141 "\\([ \t\n]\\|\\\\\n\\)*[:{]"
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
142 ) 3))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
144
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (defvar cc-imenu-c-generic-expression
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 cc-imenu-c++-generic-expression
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defvar cc-imenu-java-generic-expression
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
150 `((nil
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
151 ,(concat
106105
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
152 "[" c-alpha "_][\]\[." c-alnum "_<> ]+[ \t\n\r]+" ; type spec
106184
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
153 "\\([" c-alpha "_][" c-alnum "_]*\\)" ; method name
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
154 "[ \t\n\r]*"
106105
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
155 ;; An argument list htat is either empty or contains any number
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
156 ;; of arguments. An argument is any number of annotations
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
157 ;; followed by a type spec followed by a word. A word is an
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
158 ;; identifier. A type spec is an identifier, possibly followed
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
159 ;; by < typespec > possibly followed by [].
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
160 (concat "("
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
161 "\\("
106184
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
162 "[ \t\n\r]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
163 "\\("
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
164 "@"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
165 "[" c-alpha "_]"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
166 "[" c-alnum "._]""*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
167 "[ \t\n\r]+"
106105
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
168 "\\)*"
106184
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
169 "\\("
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
170 "[" c-alpha "_]"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
171 "[\]\[" c-alnum "_.]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
172 "\\("
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
173
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
174 "<"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
175 "[ \t\n\r]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
176 "[\]\[.," c-alnum "_<> \t\n\r]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
177 ">"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
178 "\\)?"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
179 "\\(\\[\\]\\)?"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
180 "[ \t\n\r]+"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
181 "\\)"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
182 "[" c-alpha "_]"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
183 "[" c-alnum "_]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
184 "[ \t\n\r,]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
185 "\\)*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
186 ")"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
187 "[.," c-alnum " \t\n\r]*"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
188 "{"
0579465d2619 (cc-imenu-java-generic-expression): A corrected version of the patch from
Alan Mackenzie <acm@muc.de>
parents: 106105
diff changeset
189 )) 1))
106105
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
190 "Imenu generic expression for Java mode. See
7e681be660d6 (cc-imenu-java-generic-expression): A new, more accurate version of the
Alan Mackenzie <acm@muc.de>
parents: 102100
diff changeset
191 `imenu-generic-expression'.")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
193 ;; *Warning for cc-mode developers*
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
194 ;;
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
195 ;; `cc-imenu-objc-generic-expression' elements depend on
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
196 ;; `cc-imenu-c++-generic-expression'. So if you change this
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
197 ;; expression, you need to change following variables,
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
198 ;; `cc-imenu-objc-generic-expression-*-index',
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
199 ;; too. `cc-imenu-objc-function' uses these *-index variables, in
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
200 ;; order to know where the each regexp *group \\(foobar\\)* elements
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
201 ;; are started.
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
202 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
203 ;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
204 ;; being initialized.
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
205 ;;
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
206
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
207 ;; Internal variables
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
208 (defvar cc-imenu-objc-generic-expression-noreturn-index nil)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
209 (defvar cc-imenu-objc-generic-expression-general-func-index nil)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
210 (defvar cc-imenu-objc-generic-expression-proto-index nil)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
211 (defvar cc-imenu-objc-generic-expression-objc-base-index nil)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
212
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
213 (defvar cc-imenu-objc-generic-expression
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
214 (concat
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
215 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
216 ;; For C
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
217 ;;
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
218 ;; > Special case to match a line like `main() {}'
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
219 ;; > 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
220 ;; Pick a token by (match-string 1)
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
221 (car (cdr (nth 1 cc-imenu-c++-generic-expression))) ; -> index += 2
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
222 (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
223 "\\|"
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
224 ;; > General function name regexp
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
225 ;; 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
226 (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
227 (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
228 ;; > 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
229 ;; > `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
230 ;; Pick a token by (match-string 8)
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
231 (if cc-imenu-c-prototype-macro-regexp
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
232 (concat
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
233 "\\|"
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
234 (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
235 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
236 )
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
237 (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "")
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
238 "") ; -> index += 0
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
239 (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
240 ;;
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
241 ;; For Objective-C
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
242 ;; 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
243 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
244 "\\|\\("
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
245 "^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
246 "\\|"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
247 "^@interface[\t ]+[" c-alnum "_]+[\t ]*:"
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
248 "\\|"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
249 "^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
250 "\\|"
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
251 ;; 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
252 "^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$"
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
253 "\\|"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
254 "^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
255 "\\|"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
256 "^@implementation[\t ]+[" c-alnum "_]+"
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
257 "\\|"
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
258 "^@protocol[\t ]+[" c-alnum "_]+" "\\)")
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
259 "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
260
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
261
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
262 ;; 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
263 (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
264 "Return the objc selector style string of METHOD.
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
265 Example:
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
266 - 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
267 =>
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
268 -perform:withObject:withObject:withObject: /* selector */"
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
269 (let ((return "") ; String to be returned
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
270 (p 0) ; Current scanning position in METHOD
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
271 (pmax (length method)) ;
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
272 char ; Current scanning target
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
273 (betweenparen 0) ; CHAR is in parentheses.
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
274 argreq ; An argument is required.
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
275 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
276 (while (< p pmax)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
277 (setq char (aref method p)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
278 p (1+ p))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
279 (cond
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
280 ;; 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
281 ((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
282 (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
283 (or (and (<= ?a char) (<= char ?z))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
284 (and (<= ?A char) (<= char ?Z))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
285 (and (<= ?0 char) (<= char ?9))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
286 (= ?_ char)))
102069
b6ec92c16c1d * progmodes/cc-menus.el (cc-imenu-objc-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 101115
diff changeset
287 (if argreq
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
288 (setq inargvar t
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
289 argreq nil)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
290 (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
291 ;; Or a white space?
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
292 ((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
293 (setq inargvar nil)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
294 ;; Or a method separator?
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
295 ;; If a method separator, the next token will be an argument variable.
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
296 ((eq ?: char)
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
297 (setq argreq t
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
298 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
299 ;; Or an open parentheses?
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
300 ((eq ?\( char)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
301 (setq betweenparen (1+ betweenparen)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
302 ;; Or a close parentheses?
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
303 ((eq ?\) char)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
304 (setq betweenparen (1- betweenparen)))))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
305 return))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
306
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
307 (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
308 "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
309 (let ((return "")
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
310 (p 0)
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
311 (max (length str))
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
312 char)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
313 (while (< p max)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
314 (setq char (aref str p))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
315 (setq p (1+ p))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
316 (if (or (= char ?\ ) (= char ?\t))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
317 ()
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
318 (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
319 return))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
320
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
321 (defun cc-imenu-objc-function ()
102069
b6ec92c16c1d * progmodes/cc-menus.el (cc-imenu-objc-function): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 101115
diff changeset
322 "Imenu support for Objective C mode."
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
323 (let (methodlist
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
324 clist
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
325 ;;
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
326 ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
327 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
328 ;; *Warning for developers*
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
329 ;; 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
330 ;;
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
331 (OBJC cc-imenu-objc-generic-expression-objc-base-index)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
332 ;; Special case to match a line like `main() {}'
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
333 (Cnoreturn cc-imenu-objc-generic-expression-noreturn-index)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
334 ;; General function name regexp
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
335 (Cgeneralfunc cc-imenu-objc-generic-expression-general-func-index)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
336 ;; Special case for definitions using phony prototype macros like:
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
337 (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
338 langnum
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
339 ;;
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
340 (classcount 0)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
341 toplist
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
342 str
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
343 str2
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
344 (intflen (length "@interface"))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
345 (implen (length "@implementation"))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
346 (prtlen (length "@protocol"))
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
347 (func
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
348 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
349 ;; Does this emacs have buffer-substring-no-properties?
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
350 ;;
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
351 (if (fboundp 'buffer-substring-no-properties)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
352 'buffer-substring-no-properties
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
353 'buffer-substring)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
354 (goto-char (point-max))
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
355 ;;
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
356 (while (re-search-backward cc-imenu-objc-generic-expression nil t)
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
357 (setq langnum (if (match-beginning OBJC)
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
358 OBJC
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
359 (cond
20916
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
360 ((match-beginning Cproto) Cproto)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
361 ((match-beginning Cgeneralfunc) Cgeneralfunc)
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
362 ((match-beginning Cnoreturn) Cnoreturn))))
704b7ccba694 Imenu support changed.
Richard M. Stallman <rms@gnu.org>
parents: 20507
diff changeset
363 (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
364 ;;
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
365 (cond
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
366 ;;
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
367 ;; C
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
368 ;;
20145
cfd9922ca72b Patches to Imenu support given by
Karl Heuer <kwzh@gnu.org>
parents: 20134
diff changeset
369 ((not (eq langnum OBJC))
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
370 (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
371 ;;
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
372 ;; ObjC
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
373 ;;
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
374 ;; An instance Method
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
375 ((eq (aref str 0) ?-)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
376 (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
377 (setq methodlist (cons (cons str
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
378 (match-beginning langnum))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
379 methodlist)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
380 ;; A factory Method
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
381 ((eq (aref str 0) ?+)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
382 (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
383 (setq methodlist (cons (cons str
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
384 (match-beginning langnum))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
385 methodlist)))
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
386 ;; Interface or implementation or protocol
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
387 ((eq (aref str 0) ?@)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
388 (setq classcount (1+ classcount))
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
389 (cond
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
390 ((and (> (length str) implen)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
391 (string= (substring str 0 implen) "@implementation"))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
392 (setq str (substring str implen)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
393 str2 "@implementation"))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
394 ((string= (substring str 0 intflen) "@interface")
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
395 (setq str (substring str intflen)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
396 str2 "@interface"))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
397 ((string= (substring str 0 prtlen) "@protocol")
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
398 (setq str (substring str prtlen)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
399 str2 "@protocol")))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
400 (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
401 (setq methodlist (cons (cons str2
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
402 (match-beginning langnum))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
403 methodlist))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
404 (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
405 methodlist) toplist))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
406 methodlist nil))))
101115
16cdb5713076 Fix comment typo, and some trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 101112
diff changeset
407 ;;
20134
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
408 (if (eq (car toplist) nil)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
409 (setq toplist (cdr toplist)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
410
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
411 ;; 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
412 (if (< classcount 2)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
413 (let ((classname (car (car toplist)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
414 (p (cdr (car (cdr (car toplist)))))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
415 last)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
416 (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
417 ;; Add C lang token
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
418 (if clist
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
419 (progn
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
420 (setq last toplist)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
421 (while (cdr last)
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
422 (setq last (cdr last)))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
423 (setcdr last clist))))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
424 ;; 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
425 (if clist
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
426 (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
427 ;;
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
428 toplist
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
429 ))
7eb314cf3574 (cc-imenu-c-prototype-macro-regexp): New var.
Karl Heuer <kwzh@gnu.org>
parents: 19809
diff changeset
430
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
431 ;(defvar cc-imenu-pike-generic-expression
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
432 ; ())
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
433 ; FIXME: Please contribute one!
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 23855
diff changeset
434
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
435 (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
436 &optional mode-create-index-function)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
437 (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
438 imenu-case-fold-search nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
439 (when mode-create-index-function
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 49598
diff changeset
440 (setq imenu-create-index-function mode-create-index-function)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 24783
diff changeset
441
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
443 (cc-provide 'cc-menus)
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
444
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79717
diff changeset
445 ;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 ;;; cc-menus.el ends here