comparison lisp/cc-mode/cc-menus.el @ 165:5a88923fcbfe r20-3b9

Import from CVS: tag r20-3b9
author cvs
date Mon, 13 Aug 2007 09:44:42 +0200
parents
children 929b76928fce
comparison
equal deleted inserted replaced
164:4e0740e5aab2 165:5a88923fcbfe
1 ;;; cc-menus.el --- menu and imenu support for CC Mode
2
3 ;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc.
4
5 ;; Authors: 1992-1997 Barry A. Warsaw
6 ;; 1987 Dave Detlefs and Stewart Clamen
7 ;; 1985 Richard M. Stallman
8 ;; Maintainer: cc-mode-help@python.org
9 ;; Created: 22-Apr-1997 (split from cc-mode.el)
10 ;; Version: 5.11
11 ;; Keywords: c languages oop
12
13 ;; This file is part of GNU Emacs.
14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
16 ;; it under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; any later version.
19
20 ;; GNU Emacs is distributed in the hope that it will be useful,
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;; GNU General Public License for more details.
24
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 ;; Boston, MA 02111-1307, USA.
29
30
31 ;; imenu integration
32 (defvar cc-imenu-c++-generic-expression
33 (`
34 ((nil
35 (,
36 (concat
37 "^" ; beginning of line is required
38 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
39 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
40 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
41
42 "\\(" ; last type spec including */&
43 "[a-zA-Z0-9_:]+"
44 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either ptr/ref sign or ws
45 "\\)?" ; if there is a last type spec
46 "\\(" ; name, take into the imenu entry
47 "[a-zA-Z0-9_:~]+" ; member func, ctor or dtor...
48 ; (may not contain * because then
49 ; "a::operator char*" would
50 ; become "char*"!)
51 "\\|"
52 "\\([a-zA-Z0-9_:~]*::\\)?operator"
53 "[^a-zA-Z1-9_][^(]*" ; ...or operator
54 " \\)"
55 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than
56 ; a `;' after the (...) to
57 ; avoid prototypes. Can't
58 ; catch cases with () inside
59 ; the parentheses surrounding
60 ; the parameters. e.g.:
61 ; "int foo(int a=bar()) {...}"
62
63 )) 6)
64 ("Class"
65 (, (concat
66 "^" ; beginning of line is required
67 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
68 "class[ \t]+"
69 "\\([a-zA-Z0-9_]+\\)" ; the string we want to get
70 "[ \t]*[:{]"
71 )) 2)))
72 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
73
74 (defvar cc-imenu-c-generic-expression
75 cc-imenu-c++-generic-expression
76 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
77
78 ;(defvar cc-imenu-objc-generic-expression
79 ; ())
80 ; Please contribute one!
81
82 (defvar cc-imenu-java-generic-expression
83 (`
84 ((nil
85 (,
86 (concat
87 "^\\([ \t]\\)*"
88 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; type specs; there can be
89 "\\([A-Za-z0-9_-]+[ \t]+\\)?" ; more than 3 tokens, right?
90 "\\([A-Za-z0-9_-]+[ \t]*[[]?[]]?\\)"
91 "\\([ \t]\\)"
92 "\\([A-Za-z0-9_-]+\\)" ; the string we want to get
93 "\\([ \t]*\\)+("
94 "\\([a-zA-Z,_1-9\n \t]*[[]?[]]?\\)*" ; arguments
95 ")[ \t]*"
96 "[^;(]"
97 "[,a-zA-Z_1-9\n \t]*{"
98 )) 6)))
99 "Imenu generic expression for Java mode. See `imenu-generic-expression'.")
100
101
102 ;; menu support for both XEmacs and Emacs. If you don't have easymenu
103 ;; with your version of Emacs, you are incompatible!
104 (require 'easymenu)
105
106 (defvar c-c-menu nil)
107 (defvar c-c++-menu nil)
108 (defvar c-objc-menu nil)
109 (defvar c-java-menu nil)
110
111 (defun c-mode-menu (modestr)
112 (let ((m
113 '(["Comment Out Region" comment-region (mark)]
114 ["Macro Expand Region" c-macro-expand (mark)]
115 ["Backslashify" c-backslash-region (mark)]
116 ["Indent Expression" c-indent-exp
117 (memq (following-char) '(?\( ?\[ ?\{))]
118 ["Indent Line" c-indent-command t]
119 ["Fill Comment Paragraph" c-fill-paragraph t]
120 ["Up Conditional" c-up-conditional t]
121 ["Backward Conditional" c-backward-conditional t]
122 ["Forward Conditional" c-forward-conditional t]
123 ["Backward Statement" c-beginning-of-statement t]
124 ["Forward Statement" c-end-of-statement t]
125 )))
126 (cons modestr m)))
127
128 (eval-when-compile
129 (load-file "./cc-langs.el"))
130
131 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
132 (c-mode-menu "C"))
133 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
134 (c-mode-menu "C++"))
135 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
136 (c-mode-menu "ObjC"))
137 (easy-menu-define c-java-menu java-mode-map "Java Mode Commands"
138 (c-mode-menu "Java"))
139
140
141 (provide 'cc-menus)
142 ;;; cc-menus.el ends here