/[emacs]/emacs/lisp/progmodes/cc-menus.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/cc-menus.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by rms, Wed Dec 4 11:48:12 2002 UTC revision 1.24 by lektu, Tue Feb 4 13:24:34 2003 UTC
# Line 125  A sample value might look like: `\\(_P\\ Line 125  A sample value might look like: `\\(_P\\
125                     "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above                     "[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
126                     ) 1)))                     ) 1)))
127      ;; Class definitions      ;; Class definitions
128      ("Class"      ("Class"
129       ,(concat       ,(concat
130           "^"                                  ; beginning of line is required           "^"                                  ; beginning of line is required
131           "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'           "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
# Line 137  A sample value might look like: `\\(_P\\ Line 137  A sample value might look like: `\\(_P\\
137           "\\([ \t\n]\\|\\\\\n\\)*[:{]"           "\\([ \t\n]\\|\\\\\n\\)*[:{]"
138           ) 3))           ) 3))
139    "Imenu generic expression for C++ mode.  See `imenu-generic-expression'.")    "Imenu generic expression for C++ mode.  See `imenu-generic-expression'.")
140    
141  (defvar cc-imenu-c-generic-expression  (defvar cc-imenu-c-generic-expression
142    cc-imenu-c++-generic-expression    cc-imenu-c++-generic-expression
143    "Imenu generic expression for C mode.  See `imenu-generic-expression'.")    "Imenu generic expression for C mode.  See `imenu-generic-expression'.")
# Line 155  A sample value might look like: `\\(_P\\ Line 155  A sample value might look like: `\\(_P\\
155         "[][a-zA-Z,_1-9\n \t]*"                ; arguments         "[][a-zA-Z,_1-9\n \t]*"                ; arguments
156         ")[ \t]*"         ")[ \t]*"
157  ;       "[^;(]"  ;       "[^;(]"
158         "[,a-zA-Z_1-9\n \t]*{"                       "[,a-zA-Z_1-9\n \t]*{"
159         ) 6))         ) 6))
160    "Imenu generic expression for Java mode.  See `imenu-generic-expression'.")    "Imenu generic expression for Java mode.  See `imenu-generic-expression'.")
161    
162  ;;                        *Warning for cc-mode developers*  ;;                        *Warning for cc-mode developers*
163  ;;  ;;
164  ;; `cc-imenu-objc-generic-expression' elements depend on  ;; `cc-imenu-objc-generic-expression' elements depend on
165  ;; `cc-imenu-c++-generic-expression'. So if you change this  ;; `cc-imenu-c++-generic-expression'. So if you change this
# Line 169  A sample value might look like: `\\(_P\\ Line 169  A sample value might look like: `\\(_P\\
169  ;; order to know where the each regexp *group \\(foobar\\)* elements  ;; order to know where the each regexp *group \\(foobar\\)* elements
170  ;; are started.  ;; are started.
171  ;;  ;;
172  ;; *-index variables are initialized during `cc-imenu-objc-generic-expression'  ;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
173  ;; being initialized.  ;; being initialized.
174  ;;  ;;
175    
176  ;; Internal variables  ;; Internal variables
# Line 179  A sample value might look like: `\\(_P\\ Line 179  A sample value might look like: `\\(_P\\
179  (defvar cc-imenu-objc-generic-expression-proto-index nil)  (defvar cc-imenu-objc-generic-expression-proto-index nil)
180  (defvar cc-imenu-objc-generic-expression-objc-base-index nil)  (defvar cc-imenu-objc-generic-expression-objc-base-index nil)
181    
182  (defvar cc-imenu-objc-generic-expression  (defvar cc-imenu-objc-generic-expression
183    (concat    (concat
184     ;;     ;;
185     ;; For C     ;; For C
186     ;;     ;;
187     ;; > Special case to match a line like `main() {}'     ;; > Special case to match a line like `main() {}'
188     ;; > e.g. no return type, not even on the previous line.     ;; > e.g. no return type, not even on the previous line.
# Line 198  A sample value might look like: `\\(_P\\ Line 198  A sample value might look like: `\\(_P\\
198     ;; > `int main _PROTO( (int argc,char *argv[]) )'.     ;; > `int main _PROTO( (int argc,char *argv[]) )'.
199     ;; Pick a token by  (match-string 5)     ;; Pick a token by  (match-string 5)
200     (if cc-imenu-c-prototype-macro-regexp     (if cc-imenu-c-prototype-macro-regexp
201         (concat             (concat
202          "\\|"          "\\|"
203          (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1          (car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
204          (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 6) "")          (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 6) "")
# Line 210  A sample value might look like: `\\(_P\\ Line 210  A sample value might look like: `\\(_P\\
210     ;; For Objective-C     ;; For Objective-C
211     ;; Pick a token by (match-string 5 or 6)     ;; Pick a token by (match-string 5 or 6)
212     ;;     ;;
213     "\\|\\("                                               "\\|\\("
214     "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]"        ; Methods     "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]"        ; Methods
215     "\\|"     "\\|"
216     "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*:"       "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*:"
217     "\\|"     "\\|"
218     "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"     "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"
219     "\\|"     "\\|"
220     ;; For NSObject, NSProxy and Object... They don't have super class.     ;; For NSObject, NSProxy and Object... They don't have super class.
221     "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*.*$"     "^@interface[\t ]+[a-zA-Z0-9_]+[\t ]*.*$"
222     "\\|"     "\\|"
223     "^@implementation[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"     "^@implementation[\t ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"
224     "\\|"     "\\|"
225     "^@implementation[\t ]+[a-zA-Z0-9_]+"     "^@implementation[\t ]+[a-zA-Z0-9_]+"
226     "\\|"     "\\|"
227     "^@protocol[\t ]+[a-zA-Z0-9_]+" "\\)")     "^@protocol[\t ]+[a-zA-Z0-9_]+" "\\)")
228    "Imenu generic expression for ObjC mode.  See `imenu-generic-expression'.")    "Imenu generic expression for ObjC mode.  See `imenu-generic-expression'.")
229    
# Line 231  A sample value might look like: `\\(_P\\ Line 231  A sample value might look like: `\\(_P\\
231  ;; Imenu support for objective-c uses functions.  ;; Imenu support for objective-c uses functions.
232  (defsubst cc-imenu-objc-method-to-selector (method)  (defsubst cc-imenu-objc-method-to-selector (method)
233    "Return the objc selector style string of METHOD.    "Return the objc selector style string of METHOD.
234  Example:  Example:
235  - perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */  - perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD */
236  =>  =>
237  -perform:withObject:withObject:withObject: /* selector */"  -perform:withObject:withObject:withObject: /* selector */"
238    (let ((return "")                     ; String to be returned    (let ((return "")                     ; String to be returned
239          (p 0)                           ; Current scanning position in METHOD            (p 0)                           ; Current scanning position in METHOD
240          (pmax (length method))          ;          (pmax (length method))          ;
241          char                            ; Current scanning target          char                            ; Current scanning target
242          (betweenparen 0)                ; CHAR is in parentheses.          (betweenparen 0)                ; CHAR is in parentheses.
243          argreq                          ; An argument is required.          argreq                          ; An argument is required.
# Line 253  Example: Line 253  Example:
253                   (and (<= ?A char) (<= char ?Z))                   (and (<= ?A char) (<= char ?Z))
254                   (and (<= ?0 char) (<= char ?9))                   (and (<= ?0 char) (<= char ?9))
255                   (= ?_ char)))                   (= ?_ char)))
256          (if argreq                (if argreq
257              (setq inargvar t              (setq inargvar t
258                    argreq nil)                    argreq nil)
259            (setq return (concat return (char-to-string char)))))            (setq return (concat return (char-to-string char)))))
260         ;; Or a white space?         ;; Or a white space?
261         ((and inargvar (or (eq ?\  char) (eq ?\n char))         ((and inargvar (or (eq ?\  char) (eq ?\n char))
262               (setq inargvar nil)))               (setq inargvar nil)))
263         ;; Or a method separator?         ;; Or a method separator?
264         ;; If a method separator, the next token will be an argument variable.         ;; If a method separator, the next token will be an argument variable.
265         ((eq ?: char)                             ((eq ?: char)
266          (setq argreq t                            (setq argreq t
267                return (concat return (char-to-string char))))                return (concat return (char-to-string char))))
268         ;; Or an open parentheses?         ;; Or an open parentheses?
269         ((eq ?\( char)         ((eq ?\( char)
# Line 277  Example: Line 277  Example:
277    "Remove all spaces and tabs from STR."    "Remove all spaces and tabs from STR."
278    (let ((return "")    (let ((return "")
279          (p 0)          (p 0)
280          (max (length str))          (max (length str))
281          char)          char)
282      (while (< p max)      (while (< p max)
283        (setq char (aref str p))        (setq char (aref str p))
# Line 294  Example: Line 294  Example:
294          ;;          ;;
295          ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.          ;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
296          ;;          ;;
297          ;;                  *Warning for developers*          ;;                  *Warning for developers*
298          ;; These constants depend on `cc-imenu-c++-generic-expression'.          ;; These constants depend on `cc-imenu-c++-generic-expression'.
299          ;;          ;;
300          (OBJC cc-imenu-objc-generic-expression-objc-base-index)          (OBJC cc-imenu-objc-generic-expression-objc-base-index)
# Line 310  Example: Line 310  Example:
310          toplist          toplist
311          stupid          stupid
312          str          str
313          str2          str2
314          (intflen (length "@interface"))          (intflen (length "@interface"))
315          (implen  (length "@implementation"))          (implen  (length "@implementation"))
316          (prtlen  (length "@protocol"))          (prtlen  (length "@protocol"))
317          (func          (func
318           ;;           ;;
319           ;; Does this emacs has buffer-substring-no-properties?           ;; Does this emacs has buffer-substring-no-properties?
320           ;;           ;;
321           (if (fboundp 'buffer-substring-no-properties)           (if (fboundp 'buffer-substring-no-properties)
322               'buffer-substring-no-properties               'buffer-substring-no-properties
# Line 326  Example: Line 326  Example:
326      ;;      ;;
327      (while (re-search-backward cc-imenu-objc-generic-expression nil t)      (while (re-search-backward cc-imenu-objc-generic-expression nil t)
328        (imenu-progress-message stupid)        (imenu-progress-message stupid)
329        (setq langnum (if (match-beginning OBJC)        (setq langnum (if (match-beginning OBJC)
330                          OBJC                          OBJC
331                        (cond                        (cond
332                         ((match-beginning Cproto) Cproto)                         ((match-beginning Cproto) Cproto)
# Line 334  Example: Line 334  Example:
334                         ((match-beginning Cnoreturn) Cnoreturn))))                         ((match-beginning Cnoreturn) Cnoreturn))))
335        (setq str (funcall func (match-beginning langnum) (match-end langnum)))        (setq str (funcall func (match-beginning langnum) (match-end langnum)))
336        ;;        ;;
337        (cond        (cond
338         ;;         ;;
339         ;; C         ;; C
340         ;;         ;;
# Line 342  Example: Line 342  Example:
342          (setq clist (cons (cons str (match-beginning langnum)) clist)))          (setq clist (cons (cons str (match-beginning langnum)) clist)))
343         ;;         ;;
344         ;; ObjC         ;; ObjC
345         ;;         ;;
346         ;; An instance Method         ;; An instance Method
347         ((eq (aref str 0) ?-)         ((eq (aref str 0) ?-)
348          (setq str (concat "-" (cc-imenu-objc-method-to-selector str)))          (setq str (concat "-" (cc-imenu-objc-method-to-selector str)))
# Line 355  Example: Line 355  Example:
355          (setq methodlist (cons (cons str          (setq methodlist (cons (cons str
356                                (match-beginning langnum))                                (match-beginning langnum))
357                          methodlist)))                          methodlist)))
358         ;; Interface or implementation or protocol         ;; Interface or implementation or protocol
359         ((eq (aref str 0) ?@)         ((eq (aref str 0) ?@)
360          (setq classcount (1+ classcount))          (setq classcount (1+ classcount))
361          (cond          (cond
362           ((and (> (length str) implen)           ((and (> (length str) implen)
363                 (string= (substring  str 0 implen) "@implementation"))                 (string= (substring  str 0 implen) "@implementation"))
364            (setq str (substring str implen)            (setq str (substring str implen)
# Line 376  Example: Line 376  Example:
376          (setq toplist (cons nil (cons (cons str          (setq toplist (cons nil (cons (cons str
377                                            methodlist) toplist))                                            methodlist) toplist))
378                methodlist nil))))                methodlist nil))))
379      ;;      ;;
380      (imenu-progress-message stupid 100)      (imenu-progress-message stupid 100)
381      (if (eq (car toplist) nil)      (if (eq (car toplist) nil)
382          (setq toplist (cdr toplist)))          (setq toplist (cdr toplist)))

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26