[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-menus.el
From: |
Martin Stjernholm |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/progmodes/cc-menus.el |
Date: |
Thu, 03 Jul 2003 08:31:05 -0400 |
Index: emacs/lisp/progmodes/cc-menus.el
diff -c emacs/lisp/progmodes/cc-menus.el:1.24
emacs/lisp/progmodes/cc-menus.el:1.25
*** emacs/lisp/progmodes/cc-menus.el:1.24 Tue Feb 4 08:24:34 2003
--- emacs/lisp/progmodes/cc-menus.el Thu Jul 3 08:30:59 2003
***************
*** 1,10 ****
;;; cc-menus.el --- imenu support for CC Mode
! ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc.
! ;; Authors: 2000- Martin Stjernholm
! ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm
! ;; 1992-1997 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: address@hidden
--- 1,9 ----
;;; cc-menus.el --- imenu support for CC Mode
! ;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc.
! ;; Authors: 1998- Martin Stjernholm
! ;; 1992-1999 Barry A. Warsaw
;; 1987 Dave Detlefs and Stewart Clamen
;; 1985 Richard M. Stallman
;; Maintainer: address@hidden
***************
*** 39,49 ****
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
! (require 'cc-bytecomp)))
;; The things referenced in imenu, which we don't require.
(cc-bytecomp-defvar imenu-case-fold-search)
(cc-bytecomp-defvar imenu-generic-expression)
(cc-bytecomp-defun imenu-progress-message)
--- 38,51 ----
(stringp byte-compile-dest-file))
(cons (file-name-directory byte-compile-dest-file) load-path)
load-path)))
! (load "cc-bytecomp" nil t)))
!
! (cc-require 'cc-defs)
;; The things referenced in imenu, which we don't require.
(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)
***************
*** 71,80 ****
(nil
,(concat
"^\\<.*"
! "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
; (note: this can be `\n')
"\\("
! "\\([a-zA-Z0-9_:<>~]*::\\)?" ; match an operator
"operator\\>[ \t]*"
"\\(()\\|[^(]*\\)" ; special case for `()' operator
"\\)"
--- 73,82 ----
(nil
,(concat
"^\\<.*"
! "[^" c-alnum "_:<>~]" ; match any non-identifier char
; (note: this can be `\n')
"\\("
! "\\([" c-alnum "_:<>~]*::\\)?" ; match an operator
"operator\\>[ \t]*"
"\\(()\\|[^(]*\\)" ; special case for `()' operator
"\\)"
***************
*** 93,99 ****
(nil
,(concat
"^"
! "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
"[ \t]*(" ; see above, BUT
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
"[ \t]*[^ \t;(]" ; with an asterisk or
parentheses
--- 95,101 ----
(nil
,(concat
"^"
! "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"[ \t]*(" ; see above, BUT
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
"[ \t]*[^ \t;(]" ; with an asterisk or
parentheses
***************
*** 103,110 ****
,(concat
"^\\<" ; line MUST start with word char
"[^()]*" ; no parentheses before
! "[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
! "\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; 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
--- 105,112 ----
,(concat
"^\\<" ; line MUST start with word char
"[^()]*" ; no parentheses before
! "[^" 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
***************
*** 117,143 ****
`((nil
,(concat
"^\\<.*" ; line MUST start with word char
! "[^a-zA-Z0-9_]" ; match any non-identifier char
! "\\([a-zA-Z_][a-zA-Z0-9_]*\\)" ; match function name
"[ \t]*" ; whitespace before macro name
cc-imenu-c-prototype-macro-regexp
"[ \t]*(" ; ws followed by first paren.
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
) 1)))
;; Class definitions
! ("Class"
,(concat
"^" ; beginning of line is required
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template
<...>'
"\\(class\\|struct\\)[ \t]+"
"\\(" ; the string we want to get
! "[a-zA-Z0-9_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly
specialized
"\\)"
"\\([ \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'.")
--- 119,145 ----
`((nil
,(concat
"^\\<.*" ; line MUST start with word char
! "[^" c-alnum "_]" ; match any non-identifier char
! "\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name
"[ \t]*" ; whitespace before macro name
cc-imenu-c-prototype-macro-regexp
"[ \t]*(" ; ws followed by first paren.
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
) 1)))
;; Class definitions
! ("Class"
,(concat
"^" ; beginning of line is required
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template
<...>'
"\\(class\\|struct\\)[ \t]+"
"\\(" ; the string we want to get
! "[" c-alnum "_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly
specialized
"\\)"
"\\([ \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'.")
***************
*** 145,165 ****
(defvar cc-imenu-java-generic-expression
`((nil
,(concat
! "^\\([ \t]\\)*"
! "\\([.A-Za-z0-9_-]+[ \t]+\\)?" ; type specs; there can be
! "\\([.A-Za-z0-9_-]+[ \t]+\\)?" ; more than 3 tokens, right?
! "\\([.A-Za-z0-9_-]+[ \t]*[[]?[]]?\\)"
! "\\([ \t]\\)"
! "\\([A-Za-z0-9_-]+\\)" ; the string we want to get
! "\\([ \t]*\\)+("
! "[][a-zA-Z,_1-9\n \t]*" ; arguments
! ")[ \t]*"
! ; "[^;(]"
! "[,a-zA-Z_1-9\n \t]*{"
! ) 6))
"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
--- 147,170 ----
(defvar cc-imenu-java-generic-expression
`((nil
,(concat
! "[" 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*
;;
;; `cc-imenu-objc-generic-expression' elements depend on
;; `cc-imenu-c++-generic-expression'. So if you change this
***************
*** 169,176 ****
;; order to know where the each regexp *group \\(foobar\\)* elements
;; are started.
;;
! ;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
! ;; being initialized.
;;
;; Internal variables
--- 174,181 ----
;; order to know where the each regexp *group \\(foobar\\)* elements
;; are started.
;;
! ;; *-index variables are initialized during
`cc-imenu-objc-generic-expression'
! ;; being initialized.
;;
;; Internal variables
***************
*** 179,188 ****
(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
;;
! ;; For C
;;
;; > Special case to match a line like `main() {}'
;; > e.g. no return type, not even on the previous line.
--- 184,193 ----
(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
;;
! ;; For C
;;
;; > Special case to match a line like `main() {}'
;; > e.g. no return type, not even on the previous line.
***************
*** 192,243 ****
"\\|"
;; > General function name regexp
;; Pick a token by (match-string 3)
! (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 2
(prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
;; > Special case for definitions using phony prototype macros like:
;; > `int main _PROTO( (int argc,char *argv[]) )'.
! ;; Pick a token by (match-string 5)
(if cc-imenu-c-prototype-macro-regexp
! (concat
"\\|"
(car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
! (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 6) "")
)
! (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 5) "")
"") ; -> index += 0
! (prog2 (setq cc-imenu-objc-generic-expression-proto-index 5) "")
;;
;; For Objective-C
! ;; Pick a token by (match-string 5 or 6)
;;
! "\\|\\("
! "^[-+][:a-zA-Z0-9()*_<>\n\t ]*[;{]" ; Methods
! "\\|"
! "address@hidden ]+[a-zA-Z0-9_]+[\t ]*:"
! "\\|"
! "address@hidden ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"
! "\\|"
;; For NSObject, NSProxy and Object... They don't have super class.
! "address@hidden ]+[a-zA-Z0-9_]+[\t ]*.*$"
! "\\|"
! "address@hidden ]+[a-zA-Z0-9_]+[\t ]*([a-zA-Z0-9_]+)"
! "\\|"
! "address@hidden ]+[a-zA-Z0-9_]+"
! "\\|"
! "address@hidden ]+[a-zA-Z0-9_]+" "\\)")
"Imenu generic expression for ObjC mode. See `imenu-generic-expression'.")
;; Imenu support for objective-c uses functions.
(defsubst cc-imenu-objc-method-to-selector (method)
"Return the objc selector style string of METHOD.
! 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)) ;
char ; Current scanning target
(betweenparen 0) ; CHAR is in parentheses.
argreq ; An argument is required.
--- 197,249 ----
"\\|"
;; > General function name regexp
;; Pick a token by (match-string 3)
! (car (cdr (nth 2 cc-imenu-c++-generic-expression))) ; -> index += 5
(prog2 (setq cc-imenu-objc-generic-expression-general-func-index 3) "")
;; > Special case for definitions using phony prototype macros like:
;; > `int main _PROTO( (int argc,char *argv[]) )'.
! ;; Pick a token by (match-string 8)
(if cc-imenu-c-prototype-macro-regexp
! (concat
"\\|"
(car (cdr (nth 3 cc-imenu-c++-generic-expression))) ; -> index += 1
! (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 9) "")
)
! (prog2 (setq cc-imenu-objc-generic-expression-objc-base-index 8) "")
"") ; -> index += 0
! (prog2 (setq cc-imenu-objc-generic-expression-proto-index 8) "")
;;
;; For Objective-C
! ;; Pick a token by (match-string 8 or 9)
;;
! "\\|\\("
! "^[-+][:" c-alnum "()*_<>\n\t ]*[;{]" ; Methods
! "\\|"
! "address@hidden ]+[" c-alnum "_]+[\t ]*:"
! "\\|"
! "address@hidden ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
! "\\|"
;; For NSObject, NSProxy and Object... They don't have super class.
! "address@hidden ]+[" c-alnum "_]+[\t ]*.*$"
! "\\|"
! "address@hidden ]+[" c-alnum "_]+[\t ]*([" c-alnum "_]+)"
! "\\|"
! "address@hidden ]+[" c-alnum "_]+"
! "\\|"
! "address@hidden ]+[" c-alnum "_]+" "\\)")
"Imenu generic expression for ObjC mode. See `imenu-generic-expression'.")
;; Imenu support for objective-c uses functions.
(defsubst cc-imenu-objc-method-to-selector (method)
"Return the objc selector style string of METHOD.
! Example:
- perform: (SEL)aSelector withObject: object1 withObject: object2; /* METHOD
*/
=>
-perform:withObject:withObject:withObject: /* selector */"
+ ;; This function does not do any hidden buffer changes.
(let ((return "") ; String to be returned
! (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.
***************
*** 253,269 ****
(and (<= ?A char) (<= char ?Z))
(and (<= ?0 char) (<= char ?9))
(= ?_ char)))
! (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))
(setq inargvar nil)))
;; Or a method separator?
;; If a method separator, the next token will be an argument variable.
! ((eq ?: char)
! (setq argreq t
return (concat return (char-to-string char))))
;; Or an open parentheses?
((eq ?\( char)
--- 259,275 ----
(and (<= ?A char) (<= char ?Z))
(and (<= ?0 char) (<= char ?9))
(= ?_ char)))
! (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))
(setq inargvar nil)))
;; Or a method separator?
;; If a method separator, the next token will be an argument variable.
! ((eq ?: char)
! (setq argreq t
return (concat return (char-to-string char))))
;; Or an open parentheses?
((eq ?\( char)
***************
*** 275,283 ****
(defun cc-imenu-objc-remove-white-space (str)
"Remove all spaces and tabs from STR."
(let ((return "")
(p 0)
! (max (length str))
char)
(while (< p max)
(setq char (aref str p))
--- 281,290 ----
(defun cc-imenu-objc-remove-white-space (str)
"Remove all spaces and tabs from STR."
+ ;; This function does not do any hidden buffer changes.
(let ((return "")
(p 0)
! (max (length str))
char)
(while (< p max)
(setq char (aref str p))
***************
*** 289,300 ****
(defun cc-imenu-objc-function ()
"imenu supports for objc-mode."
(let (methodlist
clist
;;
;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
;;
! ;; *Warning for developers*
;; These constants depend on `cc-imenu-c++-generic-expression'.
;;
(OBJC cc-imenu-objc-generic-expression-objc-base-index)
--- 296,308 ----
(defun cc-imenu-objc-function ()
"imenu supports for objc-mode."
+ ;; This function does not do any hidden buffer changes.
(let (methodlist
clist
;;
;; OBJC, Cnoreturn, Cgeneralfunc, Cproto are constants.
;;
! ;; *Warning for developers*
;; These constants depend on `cc-imenu-c++-generic-expression'.
;;
(OBJC cc-imenu-objc-generic-expression-objc-base-index)
***************
*** 310,322 ****
toplist
stupid
str
! str2
(intflen (length "@interface"))
(implen (length "@implementation"))
(prtlen (length "@protocol"))
(func
;;
! ;; Does this emacs has buffer-substring-no-properties?
;;
(if (fboundp 'buffer-substring-no-properties)
'buffer-substring-no-properties
--- 318,330 ----
toplist
stupid
str
! str2
(intflen (length "@interface"))
(implen (length "@implementation"))
(prtlen (length "@protocol"))
(func
;;
! ;; Does this emacs has buffer-substring-no-properties?
;;
(if (fboundp 'buffer-substring-no-properties)
'buffer-substring-no-properties
***************
*** 326,332 ****
;;
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
(imenu-progress-message stupid)
! (setq langnum (if (match-beginning OBJC)
OBJC
(cond
((match-beginning Cproto) Cproto)
--- 334,340 ----
;;
(while (re-search-backward cc-imenu-objc-generic-expression nil t)
(imenu-progress-message stupid)
! (setq langnum (if (match-beginning OBJC)
OBJC
(cond
((match-beginning Cproto) Cproto)
***************
*** 334,340 ****
((match-beginning Cnoreturn) Cnoreturn))))
(setq str (funcall func (match-beginning langnum) (match-end langnum)))
;;
! (cond
;;
;; C
;;
--- 342,348 ----
((match-beginning Cnoreturn) Cnoreturn))))
(setq str (funcall func (match-beginning langnum) (match-end langnum)))
;;
! (cond
;;
;; C
;;
***************
*** 342,348 ****
(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)))
--- 350,356 ----
(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)))
***************
*** 355,364 ****
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
! ;; Interface or implementation or protocol
((eq (aref str 0) ?@)
(setq classcount (1+ classcount))
! (cond
((and (> (length str) implen)
(string= (substring str 0 implen) "@implementation"))
(setq str (substring str implen)
--- 363,372 ----
(setq methodlist (cons (cons str
(match-beginning langnum))
methodlist)))
! ;; Interface or implementation or protocol
((eq (aref str 0) ?@)
(setq classcount (1+ classcount))
! (cond
((and (> (length str) implen)
(string= (substring str 0 implen) "@implementation"))
(setq str (substring str implen)
***************
*** 376,382 ****
(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)))
--- 384,390 ----
(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)))
***************
*** 395,401 ****
(setq last (cdr last)))
(setcdr last clist))))
;; Add C lang tokens as a sub menu
! (setq toplist (cons (cons "C" clist) toplist)))
;;
toplist
))
--- 403,410 ----
(setq last (cdr last)))
(setcdr last clist))))
;; Add C lang tokens as a sub menu
! (if clist
! (setq toplist (cons (cons "C" clist) toplist))))
;;
toplist
))
***************
*** 404,412 ****
; ())
; FIXME: Please contribute one!
! (defun cc-imenu-init (mode-generic-expression)
(setq imenu-generic-expression mode-generic-expression
! imenu-case-fold-search nil))
(cc-provide 'cc-menus)
--- 413,425 ----
; ())
; FIXME: Please contribute one!
! (defun cc-imenu-init (mode-generic-expression
! &optional mode-create-index-function)
! ;; This function does not do any hidden buffer changes.
(setq imenu-generic-expression mode-generic-expression
! imenu-case-fold-search nil)
! (when mode-create-index-function
! (setq imenu-create-index-function mode-create-index-function)))
(cc-provide 'cc-menus)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] Changes to emacs/lisp/progmodes/cc-menus.el,
Martin Stjernholm <=