174 |
:group 'old-c++) |
:group 'old-c++) |
175 |
|
|
176 |
(defvar c++-imenu-generic-expression |
(defvar c++-imenu-generic-expression |
177 |
(` |
`((nil |
178 |
((nil |
,(concat |
179 |
(, |
"^" ; beginning of line is required |
|
(concat |
|
|
"^" ; beginning of line is required |
|
180 |
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
181 |
"\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
"\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
182 |
"\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
"\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
183 |
|
|
184 |
"\\(" ; last type spec including */& |
"\\(" ; last type spec including */& |
185 |
"[a-zA-Z0-9_:]+" |
"[a-zA-Z0-9_:]+" |
186 |
"\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
"\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
187 |
"\\)?" ; if there is a last type spec |
"\\)?" ; if there is a last type spec |
188 |
"\\(" ; name; take that into the imenu entry |
"\\(" ; name; take that into the imenu entry |
189 |
"[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
"[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
190 |
; (may not contain * because then |
; (may not contain * because then |
191 |
; "a::operator char*" would become "char*"!) |
; "a::operator char*" would become "char*"!) |
192 |
"\\|" |
"\\|" |
193 |
"\\([a-zA-Z0-9_:~]*::\\)?operator" |
"\\([a-zA-Z0-9_:~]*::\\)?operator" |
194 |
"[^a-zA-Z1-9_][^(]*" ; ...or operator |
"[^a-zA-Z1-9_][^(]*" ; ...or operator |
195 |
" \\)" |
" \\)" |
196 |
"[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after |
"[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after |
197 |
; the (...) to avoid prototypes. Can't |
; the (...) to avoid prototypes. Can't |
198 |
; catch cases with () inside the parentheses |
; catch cases with () inside the parentheses |
199 |
; surrounding the parameters |
; surrounding the parameters |
200 |
; (like "int foo(int a=bar()) {...}" |
; (like "int foo(int a=bar()) {...}" |
201 |
|
|
202 |
)) 6) |
) 6) |
203 |
("Class" |
("Class" |
204 |
(, (concat |
,(concat |
205 |
"^" ; beginning of line is required |
"^" ; beginning of line is required |
206 |
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
207 |
"class[ \t]+" |
"class[ \t]+" |
208 |
"\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
"\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
209 |
"[ \t]*[:{]" |
"[ \t]*[:{]" |
210 |
)) 2) |
) 2) |
211 |
;; Example of generic expression for finding prototypes, structs, unions, enums. |
;; Example of generic expression for finding prototypes, structs, unions, enums. |
212 |
;; Uncomment if you want to find these too. It will be a bit slower gathering |
;; Uncomment if you want to find these too. It will be a bit slower gathering |
213 |
;; the indexes. |
;; the indexes. |
214 |
; ("Prototypes" |
; ("Prototypes" |
215 |
; (, |
; (, |
216 |
; (concat |
; (concat |
217 |
; "^" ; beginning of line is required |
; "^" ; beginning of line is required |
218 |
; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
219 |
; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
220 |
; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
221 |
|
|
222 |
; "\\(" ; last type spec including */& |
; "\\(" ; last type spec including */& |
223 |
; "[a-zA-Z0-9_:]+" |
; "[a-zA-Z0-9_:]+" |
224 |
; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
225 |
; "\\)?" ; if there is a last type spec |
; "\\)?" ; if there is a last type spec |
226 |
; "\\(" ; name; take that into the imenu entry |
; "\\(" ; name; take that into the imenu entry |
227 |
; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
228 |
; ; (may not contain * because then |
; ; (may not contain * because then |
229 |
; ; "a::operator char*" would become "char*"!) |
; ; "a::operator char*" would become "char*"!) |
230 |
; "\\|" |
; "\\|" |
231 |
; "\\([a-zA-Z0-9_:~]*::\\)?operator" |
; "\\([a-zA-Z0-9_:~]*::\\)?operator" |
232 |
; "[^a-zA-Z1-9_][^(]*" ; ...or operator |
; "[^a-zA-Z1-9_][^(]*" ; ...or operator |
233 |
; " \\)" |
; " \\)" |
234 |
; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after |
; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after |
235 |
; ; the (...) Can't |
; ; the (...) Can't |
236 |
; ; catch cases with () inside the parentheses |
; ; catch cases with () inside the parentheses |
237 |
; ; surrounding the parameters |
; ; surrounding the parameters |
238 |
; ; (like "int foo(int a=bar());" |
; ; (like "int foo(int a=bar());" |
239 |
; )) 6) |
; )) 6) |
240 |
; ("Struct" |
; ("Struct" |
241 |
; (, (concat |
; (, (concat |
242 |
; "^" ; beginning of line is required |
; "^" ; beginning of line is required |
243 |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
244 |
; "\\(const[ \t]+\\)?" |
; "\\(const[ \t]+\\)?" |
245 |
; "struct[ \t]+" |
; "struct[ \t]+" |
246 |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
247 |
; "[ \t]*[{]" |
; "[ \t]*[{]" |
248 |
; )) 3) |
; )) 3) |
249 |
; ("Enum" |
; ("Enum" |
250 |
; (, (concat |
; (, (concat |
251 |
; "^" ; beginning of line is required |
; "^" ; beginning of line is required |
252 |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
253 |
; "\\(const[ \t]+\\)?" |
; "\\(const[ \t]+\\)?" |
254 |
; "enum[ \t]+" |
; "enum[ \t]+" |
255 |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
256 |
; "[ \t]*[{]" |
; "[ \t]*[{]" |
257 |
; )) 3) |
; )) 3) |
258 |
; ("Union" |
; ("Union" |
259 |
; (, (concat |
; (, (concat |
260 |
; "^" ; beginning of line is required |
; "^" ; beginning of line is required |
261 |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
; "\\(static[ \t]+\\)?" ; there may be static or const. |
262 |
; "\\(const[ \t]+\\)?" |
; "\\(const[ \t]+\\)?" |
263 |
; "union[ \t]+" |
; "union[ \t]+" |
264 |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
265 |
; "[ \t]*[{]" |
; "[ \t]*[{]" |
266 |
; )) 3) |
; )) 3) |
267 |
)) |
) |
268 |
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.") |
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.") |
269 |
|
|
270 |
(defun c++-mode () |
(defun c++-mode () |
719 |
(if (eq (preceding-char) ?\)) |
(if (eq (preceding-char) ?\)) |
720 |
(forward-sexp -1)) |
(forward-sexp -1)) |
721 |
;; Get initial indentation of the line we are on. |
;; Get initial indentation of the line we are on. |
722 |
(current-indentation)))))))))) |
(current-indentation))))))))))) |
723 |
|
|
724 |
(defun c++-backward-to-noncomment (lim) |
(defun c++-backward-to-noncomment (lim) |
725 |
(let (opoint stop) |
(let (opoint stop) |
878 |
(point)) t) |
(point)) t) |
879 |
(progn |
(progn |
880 |
(indent-for-comment) |
(indent-for-comment) |
881 |
(beginning-of-line)))))))))) |
(beginning-of-line))))))))))) |
882 |
|
|
883 |
(defun fill-c++-comment () |
(defun fill-c++-comment () |
884 |
"Fill a comment contained in consecutive lines containing point. |
"Fill a comment contained in consecutive lines containing point. |