Spelling fixes.
[bpt/emacs.git] / lisp / progmodes / cc-menus.el
index 87b8802..942303b 100644 (file)
@@ -1,17 +1,16 @@
 ;;; cc-menus.el --- imenu support for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2011  Free Software Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
-;;             1987 Dave Detlefs and Stewart Clamen
+;;             1987 Dave Detlefs
+;;             1987 Stewart Clamen
 ;;             1985 Richard M. Stallman
 ;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
-;; Version:    See cc-mode.el
-;; Keywords:   c languages oop
+;; Keywords:   c languages
+;; Package:    cc-mode
 
 ;; This file is part of GNU Emacs.
 
@@ -46,7 +45,6 @@
 (cc-bytecomp-defvar imenu-case-fold-search)
 (cc-bytecomp-defvar imenu-generic-expression)
 (cc-bytecomp-defvar imenu-create-index-function)
-(cc-bytecomp-defun imenu-progress-message)
 
 \f
 ;; imenu integration
@@ -68,7 +66,7 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 (defvar cc-imenu-c++-generic-expression
   `(
     ;; Try to match ::operator definitions first. Otherwise `X::operator new ()'
-    ;; will be incorrectly recognised as function `new ()' because the regexps
+    ;; will be incorrectly recognized as function `new ()' because the regexps
     ;; work by backtracking from the end of the definition.
     (nil
      ,(concat
@@ -110,8 +108,11 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
        "[^" c-alnum "_:<>~]"                  ; match any non-identifier char
        "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
        "\\([ \t\n]\\|\\\\\n\\)*("            ; see above, BUT the arg list
-       "\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start
-       "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]"    ; with an asterisk or parentheses
+       "\\([ \t\n]\\|\\\\\n\\)*"             ; must not start
+       "\\([^ \t\n(*]"                       ; with an asterisk or parentheses
+       "[^()]*\\(([^()]*)[^()]*\\)*"         ; Maybe function pointer arguments
+       "\\)?)"
+       "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]"
        ) 1)
     ;; Special case for definitions using phony prototype macros like:
     ;; `int main _PROTO( (int argc,char *argv[]) )'.
@@ -129,7 +130,7 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
                    "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
                    ) 1)))
     ;; Class definitions
-    ("Class" 
+    ("Class"
      ,(concat
          "^"                                  ; beginning of line is required
          "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
@@ -141,7 +142,7 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
          "\\([ \t\n]\\|\\\\\n\\)*[:{]"
          ) 3))
   "Imenu generic expression for C++ mode.  See `imenu-generic-expression'.")
+
 (defvar cc-imenu-c-generic-expression
   cc-imenu-c++-generic-expression
   "Imenu generic expression for C mode.  See `imenu-generic-expression'.")
@@ -149,24 +150,48 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 (defvar cc-imenu-java-generic-expression
   `((nil
      ,(concat
-       "[" c-alpha "_][\]\[." c-alnum "_]+[ \t\n\r]+" ; type spec
-       "\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name
+       "[" c-alpha "_][\]\[." c-alnum "_<> ]+[ \t\n\r]+" ; type spec
+       "\\([" c-alpha "_][" c-alnum "_]*\\)" ; method name
        "[ \t\n\r]*"
-       ;; An argument list that is either empty or contains at least
-       ;; two identifiers with only space between them.  This avoids
-       ;; matching e.g. "else if (foo)".
-       (concat "([ \t\n\r]*"
-              "\\([\]\[.," c-alnum "_]+"
-              "[ \t\n\r]+"
-              "[\]\[.," c-alnum "_]"
-              "[\]\[.," c-alnum "_ \t\n\r]*"
-              "\\)?)")
-       "[.," c-alnum "_ \t\n\r]*"
-       "{"
-       ) 1))
-  "Imenu generic expression for Java mode.  See `imenu-generic-expression'.")
-
-;;                        *Warning for cc-mode developers* 
+       ;; An argument list htat is either empty or contains any number
+       ;; of arguments.  An argument is any number of annotations
+       ;; followed by a type spec followed by a word.  A word is an
+       ;; identifier.  A type spec is an identifier, possibly followed
+       ;; by < typespec > possibly followed by [].
+       (concat "("
+               "\\("
+               "[ \t\n\r]*"
+               "\\("
+               "@"
+               "[" c-alpha "_]"
+               "[" c-alnum "._]""*"
+               "[ \t\n\r]+"
+               "\\)*"
+               "\\("
+               "[" c-alpha "_]"
+               "[\]\[" c-alnum "_.]*"
+               "\\("
+
+               "<"
+               "[ \t\n\r]*"
+               "[\]\[.," c-alnum "_<> \t\n\r]*"
+               ">"
+               "\\)?"
+               "\\(\\[\\]\\)?"
+               "[ \t\n\r]+"
+               "\\)"
+               "[" c-alpha "_]"
+               "[" c-alnum "_]*"
+               "[ \t\n\r,]*"
+               "\\)*"
+               ")"
+               "[.," c-alnum " \t\n\r]*"
+               "{"
+               )) 1))
+  "Imenu generic expression for Java mode.  See
+`imenu-generic-expression'.")
+
+;;                        *Warning for cc-mode developers*
 ;;
 ;; `cc-imenu-objc-generic-expression' elements depend on
 ;; `cc-imenu-c++-generic-expression'. So if you change this
@@ -176,8 +201,8 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 ;; order to know where the each regexp *group \\(foobar\\)* elements
 ;; are started.
 ;;
-;; *-index variables are initialized during `cc-imenu-objc-generic-expression' 
-;; being initialized. 
+;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
+;; being initialized.
 ;;
 
 ;; Internal variables
@@ -186,10 +211,10 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 (defvar cc-imenu-objc-generic-expression-proto-index nil)
 (defvar cc-imenu-objc-generic-expression-objc-base-index nil)
 
-(defvar cc-imenu-objc-generic-expression 
-  (concat 
+(defvar cc-imenu-objc-generic-expression
+  (concat
    ;;
-   ;; For C 
+   ;; For C
    ;;
    ;; > Special case to match a line like `main() {}'
    ;; > e.g. no return type, not even on the previous line.
@@ -205,7 +230,7 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
    ;; > `int main _PROTO( (int argc,char *argv[]) )'.
    ;; Pick a token by  (match-string 8)
    (if cc-imenu-c-prototype-macro-regexp
-       (concat    
+       (concat
        "\\|"
        (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
        (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
@@ -217,20 +242,20 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
    ;; For Objective-C
    ;; Pick a token by (match-string 8 or 9)
    ;;
-   "\\|\\("                                         
+   "\\|\\("
    "^[-+][:" c-alnum "()*_<>\n\t ]*[;{]"        ; Methods
-   "\\|" 
+   "\\|"
    "^@interface[\t ]+[" c-alnum "_]+[\t ]*:"
-   "\\|" 
+   "\\|"
    "^@interface[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
-   "\\|" 
+   "\\|"
    ;; For NSObject, NSProxy and Object... They don't have super class.
    "^@interface[\t ]+[" c-alnum "_]+[\t ]*.*$"
-   "\\|" 
+   "\\|"
    "^@implementation[\t ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
-   "\\|" 
+   "\\|"
    "^@implementation[\t ]+[" c-alnum "_]+"
-   "\\|" 
+   "\\|"
    "^@protocol[\t ]+[" c-alnum "_]+" "\\)")
   "Imenu generic expression for ObjC mode.  See `imenu-generic-expression'.")
 
@@ -238,13 +263,13 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 ;; Imenu support for objective-c uses functions.
 (defsubst cc-imenu-objc-method-to-selector (method)
   "Return the objc selector style string of METHOD.
-Example: 
+Example:
 - perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */
 =>
 -perform:withObject:withObject:withObject: /* selector */"
   (let ((return "")                    ; String to be returned
-       (p 0)                           ; Current scanning position in METHOD  
-       (pmax (length method))          ; 
+       (p 0)                           ; Current scanning position in METHOD
+       (pmax (length method))          ;
        char                            ; Current scanning target
        (betweenparen 0)                ; CHAR is in parentheses.
        argreq                          ; An argument is required.
@@ -260,17 +285,17 @@ Example:
                 (and (<= ?A char) (<= char ?Z))
                 (and (<= ?0 char) (<= char ?9))
                 (= ?_ char)))
-       (if argreq      
+       (if argreq
            (setq inargvar t
                  argreq nil)
          (setq return (concat return (char-to-string char)))))
        ;; Or a white space?
-       ((and inargvar (or (eq ?\  char) (eq ?\n char)) 
+       ((and inargvar (or (eq ?\  char) (eq ?\n char))
             (setq inargvar nil)))
        ;; Or a method separator?
        ;; If a method separator, the next token will be an argument variable.
-       ((eq ?: char)                   
-       (setq argreq t                  
+       ((eq ?: char)
+       (setq argreq t
              return (concat return (char-to-string char))))
        ;; Or an open parentheses?
        ((eq ?\( char)
@@ -284,7 +309,7 @@ Example:
   "Remove all spaces and tabs from STR."
   (let ((return "")
        (p 0)
-       (max (length str)) 
+       (max (length str))
        char)
     (while (< p max)
       (setq char (aref str p))
@@ -295,13 +320,13 @@ Example:
     return))
 
 (defun cc-imenu-objc-function ()
-  "imenu supports for objc-mode."
+  "Imenu support for Objective C mode."
   (let (methodlist
        clist
        ;;
        ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
        ;;
-       ;;                  *Warning for developers* 
+       ;;                  *Warning for developers*
        ;; These constants depend on `cc-imenu-c++-generic-expression'.
        ;;
        (OBJC cc-imenu-objc-generic-expression-objc-base-index)
@@ -315,25 +340,22 @@ Example:
        ;;
        (classcount 0)
        toplist
-       stupid
        str
-       str2 
+       str2
        (intflen (length "@interface"))
        (implen  (length "@implementation"))
        (prtlen  (length "@protocol"))
        (func
         ;;
-        ;; Does this emacs has buffer-substring-no-properties? 
+        ;; Does this emacs have buffer-substring-no-properties?
         ;;
         (if (fboundp 'buffer-substring-no-properties)
             'buffer-substring-no-properties
           'buffer-substring)))
     (goto-char (point-max))
-    (imenu-progress-message stupid 0)
     ;;
     (while (re-search-backward cc-imenu-objc-generic-expression nil t)
-      (imenu-progress-message stupid)
-      (setq langnum (if (match-beginning OBJC) 
+      (setq langnum (if (match-beginning OBJC)
                        OBJC
                      (cond
                       ((match-beginning Cproto) Cproto)
@@ -341,7 +363,7 @@ Example:
                       ((match-beginning Cnoreturn) Cnoreturn))))
       (setq str (funcall func (match-beginning langnum) (match-end langnum)))
       ;;
-      (cond 
+      (cond
        ;;
        ;; C
        ;;
@@ -349,7 +371,7 @@ Example:
        (setq clist (cons (cons str (match-beginning langnum)) clist)))
        ;;
        ;; ObjC
-       ;; 
+       ;;
        ;; An instance Method
        ((eq (aref str 0) ?-)
        (setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
@@ -362,10 +384,10 @@ Example:
        (setq methodlist (cons (cons str
                              (match-beginning langnum))
                        methodlist)))
-       ;; Interface or implementation or protocol 
+       ;; Interface or implementation or protocol
        ((eq (aref str 0) ?@)
        (setq classcount (1+ classcount))
-       (cond 
+       (cond
         ((and (> (length str) implen)
               (string= (substring  str 0 implen) "@implementation"))
          (setq str (substring str implen)
@@ -383,8 +405,7 @@ Example:
        (setq toplist (cons nil (cons (cons str
                                          methodlist) toplist))
              methodlist nil))))
-    ;; 
-    (imenu-progress-message stupid 100)
+    ;;
     (if (eq (car toplist) nil)
        (setq toplist (cdr toplist)))
 
@@ -422,5 +443,4 @@ Example:
 \f
 (cc-provide 'cc-menus)
 
-;; arch-tag: f6b60933-91f0-4145-ab44-70ca6d1b919b
 ;;; cc-menus.el ends here