diff options
| author | Karl Heuer | 1995-07-28 00:30:18 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-07-28 00:30:18 +0000 |
| commit | d6209f58ef2c9f2b28231f88f71b0c21e64ba103 (patch) | |
| tree | 24da44d31c44218949f71a20f067f7b3a3750442 /lisp | |
| parent | 82af06af7845bcbe9117ba326debfc1bed807e50 (diff) | |
| download | emacs-d6209f58ef2c9f2b28231f88f71b0c21e64ba103.tar.gz emacs-d6209f58ef2c9f2b28231f88f71b0c21e64ba103.zip | |
(c++-imenu-generic-expression): Var defined.
(c++-mode): Set imenu-generic-expression.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/cplus-md.el | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/lisp/progmodes/cplus-md.el b/lisp/progmodes/cplus-md.el index 8c93118d91b..e02a8068d1d 100644 --- a/lisp/progmodes/cplus-md.el +++ b/lisp/progmodes/cplus-md.el | |||
| @@ -143,6 +143,101 @@ with the colon on the first line.") | |||
| 143 | "*Indicates how far to indent an line following an empty argument | 143 | "*Indicates how far to indent an line following an empty argument |
| 144 | list. Nil indicates to just after the paren.") | 144 | list. Nil indicates to just after the paren.") |
| 145 | 145 | ||
| 146 | (defvar c++-imenu-generic-expression | ||
| 147 | (` | ||
| 148 | ((nil | ||
| 149 | (, | ||
| 150 | (concat | ||
| 151 | "^" ; beginning of line is required | ||
| 152 | "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | ||
| 153 | "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no | ||
| 154 | "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? | ||
| 155 | |||
| 156 | "\\(" ; last type spec including */& | ||
| 157 | "[a-zA-Z0-9_:]+" | ||
| 158 | "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace | ||
| 159 | "\\)?" ; if there is a last type spec | ||
| 160 | "\\(" ; name; take that into the imenu entry | ||
| 161 | "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... | ||
| 162 | ; (may not contain * because then | ||
| 163 | ; "a::operator char*" would become "char*"!) | ||
| 164 | "\\|" | ||
| 165 | "\\([a-zA-Z0-9_:~]*::\\)?operator" | ||
| 166 | "[^a-zA-Z1-9_][^(]*" ; ...or operator | ||
| 167 | " \\)" | ||
| 168 | "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after | ||
| 169 | ; the (...) to avoid prototypes. Can't | ||
| 170 | ; catch cases with () inside the parentheses | ||
| 171 | ; surrounding the parameters | ||
| 172 | ; (like "int foo(int a=bar()) {...}" | ||
| 173 | |||
| 174 | )) 6) | ||
| 175 | ("Class" | ||
| 176 | (, (concat | ||
| 177 | "^" ; beginning of line is required | ||
| 178 | "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | ||
| 179 | "class[ \t]+" | ||
| 180 | "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | ||
| 181 | "[ \t]*[:{]" | ||
| 182 | )) 2) | ||
| 183 | ;; Example of generic expression for finding prototypes, structs, unions, enums. | ||
| 184 | ;; Uncomment if you want to find these too. It will be a bit slower gathering | ||
| 185 | ;; the indexes. | ||
| 186 | ; ("Prototypes" | ||
| 187 | ; (, | ||
| 188 | ; (concat | ||
| 189 | ; "^" ; beginning of line is required | ||
| 190 | ; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | ||
| 191 | ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no | ||
| 192 | ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? | ||
| 193 | |||
| 194 | ; "\\(" ; last type spec including */& | ||
| 195 | ; "[a-zA-Z0-9_:]+" | ||
| 196 | ; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace | ||
| 197 | ; "\\)?" ; if there is a last type spec | ||
| 198 | ; "\\(" ; name; take that into the imenu entry | ||
| 199 | ; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... | ||
| 200 | ; ; (may not contain * because then | ||
| 201 | ; ; "a::operator char*" would become "char*"!) | ||
| 202 | ; "\\|" | ||
| 203 | ; "\\([a-zA-Z0-9_:~]*::\\)?operator" | ||
| 204 | ; "[^a-zA-Z1-9_][^(]*" ; ...or operator | ||
| 205 | ; " \\)" | ||
| 206 | ; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after | ||
| 207 | ; ; the (...) Can't | ||
| 208 | ; ; catch cases with () inside the parentheses | ||
| 209 | ; ; surrounding the parameters | ||
| 210 | ; ; (like "int foo(int a=bar());" | ||
| 211 | ; )) 6) | ||
| 212 | ; ("Struct" | ||
| 213 | ; (, (concat | ||
| 214 | ; "^" ; beginning of line is required | ||
| 215 | ; "\\(static[ \t]+\\)?" ; there may be static or const. | ||
| 216 | ; "\\(const[ \t]+\\)?" | ||
| 217 | ; "struct[ \t]+" | ||
| 218 | ; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | ||
| 219 | ; "[ \t]*[{]" | ||
| 220 | ; )) 3) | ||
| 221 | ; ("Enum" | ||
| 222 | ; (, (concat | ||
| 223 | ; "^" ; beginning of line is required | ||
| 224 | ; "\\(static[ \t]+\\)?" ; there may be static or const. | ||
| 225 | ; "\\(const[ \t]+\\)?" | ||
| 226 | ; "enum[ \t]+" | ||
| 227 | ; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | ||
| 228 | ; "[ \t]*[{]" | ||
| 229 | ; )) 3) | ||
| 230 | ; ("Union" | ||
| 231 | ; (, (concat | ||
| 232 | ; "^" ; beginning of line is required | ||
| 233 | ; "\\(static[ \t]+\\)?" ; there may be static or const. | ||
| 234 | ; "\\(const[ \t]+\\)?" | ||
| 235 | ; "union[ \t]+" | ||
| 236 | ; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | ||
| 237 | ; "[ \t]*[{]" | ||
| 238 | ; )) 3) | ||
| 239 | )) | ||
| 240 | "Imenu generic expression for C++ mode. See `imenu-generic-expression'.") | ||
| 146 | 241 | ||
| 147 | ;;;###autoload | 242 | ;;;###autoload |
| 148 | (defun c++-mode () | 243 | (defun c++-mode () |
| @@ -228,6 +323,8 @@ no args if that value is non-nil." | |||
| 228 | (set (make-local-variable 'paragraph-ignore-fill-prefix) t) | 323 | (set (make-local-variable 'paragraph-ignore-fill-prefix) t) |
| 229 | (set (make-local-variable 'require-final-newline) t) | 324 | (set (make-local-variable 'require-final-newline) t) |
| 230 | (set (make-local-variable 'parse-sexp-ignore-comments) t) | 325 | (set (make-local-variable 'parse-sexp-ignore-comments) t) |
| 326 | (make-local-variable 'imenu-generic-expression) | ||
| 327 | (setq imenu-generic-expression c++-imenu-generic-expression) | ||
| 231 | (run-hooks 'c++-mode-hook) | 328 | (run-hooks 'c++-mode-hook) |
| 232 | (if c++-electric-colon | 329 | (if c++-electric-colon |
| 233 | (define-key c++-mode-map ":" 'electric-c++-terminator))) | 330 | (define-key c++-mode-map ":" 'electric-c++-terminator))) |