summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cplus-md.el
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1995-07-28 00:30:18 +0000
committerKarl Heuer <kwzh@gnu.org>1995-07-28 00:30:18 +0000
commitd6209f58ef2c9f2b28231f88f71b0c21e64ba103 (patch)
tree24da44d31c44218949f71a20f067f7b3a3750442 /lisp/progmodes/cplus-md.el
parent82af06af7845bcbe9117ba326debfc1bed807e50 (diff)
downloademacs-d6209f58ef2c9f2b28231f88f71b0c21e64ba103.tar.gz
emacs-d6209f58ef2c9f2b28231f88f71b0c21e64ba103.tar.bz2
emacs-d6209f58ef2c9f2b28231f88f71b0c21e64ba103.zip
(c++-imenu-generic-expression): Var defined.
(c++-mode): Set imenu-generic-expression.
Diffstat (limited to 'lisp/progmodes/cplus-md.el')
-rw-r--r--lisp/progmodes/cplus-md.el97
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.")
"*Indicates how far to indent an line following an empty argument
list. Nil indicates to just after the paren.")
+(defvar c++-imenu-generic-expression
+ (`
+ ((nil
+ (,
+ (concat
+ "^" ; beginning of line is required
+ "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
+ "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
+ "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
+
+ "\\(" ; last type spec including */&
+ "[a-zA-Z0-9_:]+"
+ "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
+ "\\)?" ; if there is a last type spec
+ "\\(" ; name; take that into the imenu entry
+ "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
+ ; (may not contain * because then
+ ; "a::operator char*" would become "char*"!)
+ "\\|"
+ "\\([a-zA-Z0-9_:~]*::\\)?operator"
+ "[^a-zA-Z1-9_][^(]*" ; ...or operator
+ " \\)"
+ "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after
+ ; the (...) to avoid prototypes. Can't
+ ; catch cases with () inside the parentheses
+ ; surrounding the parameters
+ ; (like "int foo(int a=bar()) {...}"
+
+ )) 6)
+ ("Class"
+ (, (concat
+ "^" ; beginning of line is required
+ "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
+ "class[ \t]+"
+ "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
+ "[ \t]*[:{]"
+ )) 2)
+;; Example of generic expression for finding prototypes, structs, unions, enums.
+;; Uncomment if you want to find these too. It will be a bit slower gathering
+;; the indexes.
+; ("Prototypes"
+; (,
+; (concat
+; "^" ; beginning of line is required
+; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
+; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
+; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
+
+; "\\(" ; last type spec including */&
+; "[a-zA-Z0-9_:]+"
+; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
+; "\\)?" ; if there is a last type spec
+; "\\(" ; name; take that into the imenu entry
+; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
+; ; (may not contain * because then
+; ; "a::operator char*" would become "char*"!)
+; "\\|"
+; "\\([a-zA-Z0-9_:~]*::\\)?operator"
+; "[^a-zA-Z1-9_][^(]*" ; ...or operator
+; " \\)"
+; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after
+; ; the (...) Can't
+; ; catch cases with () inside the parentheses
+; ; surrounding the parameters
+; ; (like "int foo(int a=bar());"
+; )) 6)
+; ("Struct"
+; (, (concat
+; "^" ; beginning of line is required
+; "\\(static[ \t]+\\)?" ; there may be static or const.
+; "\\(const[ \t]+\\)?"
+; "struct[ \t]+"
+; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
+; "[ \t]*[{]"
+; )) 3)
+; ("Enum"
+; (, (concat
+; "^" ; beginning of line is required
+; "\\(static[ \t]+\\)?" ; there may be static or const.
+; "\\(const[ \t]+\\)?"
+; "enum[ \t]+"
+; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
+; "[ \t]*[{]"
+; )) 3)
+; ("Union"
+; (, (concat
+; "^" ; beginning of line is required
+; "\\(static[ \t]+\\)?" ; there may be static or const.
+; "\\(const[ \t]+\\)?"
+; "union[ \t]+"
+; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
+; "[ \t]*[{]"
+; )) 3)
+ ))
+ "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
;;;###autoload
(defun c++-mode ()
@@ -228,6 +323,8 @@ no args if that value is non-nil."
(set (make-local-variable 'paragraph-ignore-fill-prefix) t)
(set (make-local-variable 'require-final-newline) t)
(set (make-local-variable 'parse-sexp-ignore-comments) t)
+ (make-local-variable 'imenu-generic-expression)
+ (setq imenu-generic-expression c++-imenu-generic-expression)
(run-hooks 'c++-mode-hook)
(if c++-electric-colon
(define-key c++-mode-map ":" 'electric-c++-terminator)))