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