aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1995-07-28 00:36:18 +0000
committerKarl Heuer1995-07-28 00:36:18 +0000
commite064a4f982aa3904aa2488a7c1fccf1dd8bfa783 (patch)
tree03f7d801b7b9279131b233912431fc0da40d97d2
parentd6209f58ef2c9f2b28231f88f71b0c21e64ba103 (diff)
downloademacs-e064a4f982aa3904aa2488a7c1fccf1dd8bfa783.tar.gz
emacs-e064a4f982aa3904aa2488a7c1fccf1dd8bfa783.zip
(imenu-generic-lisp-expression)
(imenu-generic-c++-expression, imenu-generic-c-expression) (imenu-generic-ada-expression, imenu-generic-texinfo-expression) (imenu-generic-latex-expression): Vars deleted; now handled by the major modes themselves. (imenu--scanning-method-alist): Var deleted. (imenu-default-create-index-function): Don't use that alist.
-rw-r--r--lisp/imenu.el197
1 files changed, 2 insertions, 195 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 6a652f22789..1426bb3cd96 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -207,7 +207,7 @@ This function is called after the function pointed out by
207;;;; 207;;;;
208;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 208;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
209 209
210;; Return the current/previous sexp and the location of the sexp (it's 210;; Return the current/previous sexp and the location of the sexp (its
211;; beginning) without moving the point. 211;; beginning) without moving the point.
212(defun imenu-example--name-and-position () 212(defun imenu-example--name-and-position ()
213 (save-excursion 213 (save-excursion
@@ -288,128 +288,6 @@ This function is called after the function pointed out by
288 index-alist)) 288 index-alist))
289 index-alist)) 289 index-alist))
290 290
291(defvar imenu-generic-lisp-expression
292 '(
293 (nil
294 "^\\s-*(def\\(un\\|subst\\|macro\\|advice\\)\\s-+\\([-A-Za-z0-9+]+\\)" 2)
295 ("Variables"
296 "^\\s-*(def\\(var\\|const\\)\\s-+\\([-A-Za-z0-9+]+\\)" 2)
297 ("Types"
298 "^\\s-*(def\\(type\\|struct\\|class\\|ine-condition\\)\\s-+\\([-A-Za-z0-9+]+\\)"
299 2))
300
301 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
302
303;;;
304;;; C++
305;;;
306;; Example of an imenu-generic-expression
307;;
308(defvar imenu-generic-c++-expression
309 (`
310 ((nil
311 (,
312 (concat
313 "^" ; beginning of line is required
314 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
315 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
316 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
317
318 "\\(" ; last type spec including */&
319 "[a-zA-Z0-9_:]+"
320 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
321 "\\)?" ; if there is a last type spec
322 "\\(" ; name; take that into the imenu entry
323 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
324 ; (may not contain * because then
325 ; "a::operator char*" would become "char*"!)
326 "\\|"
327 "\\([a-zA-Z0-9_:~]*::\\)?operator"
328 "[^a-zA-Z1-9_][^(]*" ; ...or operator
329 " \\)"
330 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after
331 ; the (...) to avoid prototypes. Can't
332 ; catch cases with () inside the parentheses
333 ; surrounding the parameters
334 ; (like "int foo(int a=bar()) {...}"
335
336 )) 6)
337 ("Class"
338 (, (concat
339 "^" ; beginning of line is required
340 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
341 "class[ \t]+"
342 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
343 "[ \t]*[:{]"
344 )) 2)
345;; Example of generic expression for finding prototypes, structs, unions, enums.
346;; Uncomment if You want to find these too. It will be at bit slower gathering
347;; the indexes.
348; ("Prototypes"
349; (,
350; (concat
351; "^" ; beginning of line is required
352; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>"
353; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no
354; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right?
355
356; "\\(" ; last type spec including */&
357; "[a-zA-Z0-9_:]+"
358; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace
359; "\\)?" ; if there is a last type spec
360; "\\(" ; name; take that into the imenu entry
361; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor...
362; ; (may not contain * because then
363; ; "a::operator char*" would become "char*"!)
364; "\\|"
365; "\\([a-zA-Z0-9_:~]*::\\)?operator"
366; "[^a-zA-Z1-9_][^(]*" ; ...or operator
367; " \\)"
368; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after
369; ; the (...) Can't
370; ; catch cases with () inside the parentheses
371; ; surrounding the parameters
372; ; (like "int foo(int a=bar());"
373; )) 6)
374; ("Struct"
375; (, (concat
376; "^" ; beginning of line is required
377; "\\(static[ \t]+\\)?" ; there may be static or const.
378; "\\(const[ \t]+\\)?"
379; "struct[ \t]+"
380; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
381; "[ \t]*[{]"
382; )) 3)
383; ("Enum"
384; (, (concat
385; "^" ; beginning of line is required
386; "\\(static[ \t]+\\)?" ; there may be static or const.
387; "\\(const[ \t]+\\)?"
388; "enum[ \t]+"
389; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
390; "[ \t]*[{]"
391; )) 3)
392; ("Union"
393; (, (concat
394; "^" ; beginning of line is required
395; "\\(static[ \t]+\\)?" ; there may be static or const.
396; "\\(const[ \t]+\\)?"
397; "union[ \t]+"
398; "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get
399; "[ \t]*[{]"
400; )) 3)
401 ))
402 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
403
404;;;
405;;; C
406;;;
407;;;
408(defvar imenu-generic-c-expression
409 ;; Use the C++ expression above.
410 imenu-generic-c++-expression
411 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
412
413;; Regular expression to find C functions 291;; Regular expression to find C functions
414(defvar imenu-example--function-name-regexp-c 292(defvar imenu-example--function-name-regexp-c
415 (concat 293 (concat
@@ -442,51 +320,6 @@ This function is called after the function pointed out by
442 (nreverse index-alist))) 320 (nreverse index-alist)))
443 321
444 322
445;;
446;; Ada
447;;
448;; Written by Christian Egli <Christian.Egli@hcsd.hac.com>
449;;
450(defvar imenu-generic-ada-expression
451 '((nil "^\\s-*\\(procedure\\|function\\)\\s-+\\([A-Za-z0-9_]+\\)" 2)
452 ("Type Defs" "^\\s-*\\(sub\\)?type\\s-+\\([A-Za-z0-9_]+\\)" 2))
453
454 "Imenu generic expression for Ada mode. See `imenu-generic-expression'.")
455
456;;;
457;;; TexInfo
458;;;
459;; Written by Wolfgang Bangerth <zcg51122@rpool1.rus.uni-stuttgart.de>
460;;
461;;
462(defvar imenu-generic-texinfo-expression
463 '((nil "^@node[ \t]+\\([^,\n]*\\)" 1)
464 ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1))
465
466 "Imenu generic expression for TexInfo mode. See `imenu-generic-expression'.
467
468To overide this example, Either set 'imenu-generic-expression
469or 'imenu-create-index-function")
470
471;;;
472;;; LaTex
473;;;
474;; Written by Wolfgang Bangerth <zcg51122@rpool1.rus.uni-stuttgart.de>
475;;
476;;
477(defvar imenu-generic-latex-expression
478 '(
479 ("Part" "\\\\part{\\([^}]*\\)}" 1)
480 ("Chapter" "\\\\chapter{\\([^}]*\\)}" 1)
481 ("Section" "\\\\[a-zA-Z]*section{\\([^}]*\\)}" 1)
482 ;; i put numbers like 3.15 before my
483 ;; \begin{equation}'s which tell me
484 ;; the number the equation will get when
485 ;; being printed.
486 ("Equations" "%[ \t]*\\([0-9]+\\.[0-9]+\\)[,;]?[ \t]?" 1))
487
488 "Imenu generic expression for LaTex mode. See `imenu-generic-expression'.")
489
490;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 323;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
491;;; 324;;;
492;;; Internal variables 325;;; Internal variables
@@ -505,23 +338,6 @@ or 'imenu-create-index-function")
505;; Making this buffer local caused it not to work! 338;; Making this buffer local caused it not to work!
506(defvar imenu--history-list nil) 339(defvar imenu--history-list nil)
507 340
508(defvar imenu--scanning-method-alist
509 '((emacs-lisp-mode imenu-generic-lisp-expression)
510 (lisp-mode imenu-example--create-lisp-index)
511 (c++-mode imenu-generic-c++-expression)
512 (c-mode imenu-generic-c-expression)
513 (latex-mode imenu-generic-latex-expression)
514 (texinfo-mode imenu-generic-texinfo-expression)
515 (ada-mode imenu-generic-ada-expression))
516
517 "Alist of major mode and imenu scanning methods.
518
519Each item should be a list of the form (MAJOR-MODE
520IMENU-SCANNING-METHOD), where both MAJOR-MODE and IMENU-SCANNING-METHOD
521are symbols. If IMENU-SCANNING-METHOD is a function then it is called
522to create an index. If it is a \"pattern\" (see `imenu-generic-expression')
523it is passed to `imenu--generic-function' to create an index.")
524
525;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 341;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
526;;; 342;;;
527;;; Internal support functions 343;;; Internal support functions
@@ -691,16 +507,7 @@ Their results are gathered into an index alist."
691 index-alist)) 507 index-alist))
692 ;; Use generic expression if possible. 508 ;; Use generic expression if possible.
693 ((and imenu-generic-expression) 509 ((and imenu-generic-expression)
694 (imenu--generic-function imenu-generic-expression)) 510 (imenu--generic-function imenu-generic-expression))
695 ;; Use supplied example functions or expressions
696 ((assq major-mode imenu--scanning-method-alist)
697 (let ((method (cadr (assq major-mode imenu--scanning-method-alist))))
698 ;; is it a function?
699 (if (fboundp method)
700 ;; ... then call it
701 (funcall method)
702 ;; ...otherwise pass the pattern to imenu--generic-function
703 (imenu--generic-function (eval method)))))
704 (t 511 (t
705 (error "The mode \"%s\" does not take full advantage of imenu.el yet." 512 (error "The mode \"%s\" does not take full advantage of imenu.el yet."
706 mode-name)))) 513 mode-name))))