aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-07-25 21:13:10 +0000
committerRichard M. Stallman1995-07-25 21:13:10 +0000
commit6c1bf12bb7a5bbe7bbed21fde8d80c36c4ad5222 (patch)
tree02fda4f2865ade1640b6148f1f92fd2c3ab67713
parentaa681b5110cfd06704ac809714f2516a8a97c992 (diff)
downloademacs-6c1bf12bb7a5bbe7bbed21fde8d80c36c4ad5222.tar.gz
emacs-6c1bf12bb7a5bbe7bbed21fde8d80c36c4ad5222.zip
(imenu--history-list): Don't make this buffer-local.
(imenu): Call imenu-choose-buffer-index from interactive spec. (imenu-generic-expression): Call make-variable-buffer-local. (imenu-create-index-pattern): Variable deleted. Many doc fixes.
-rw-r--r--lisp/imenu.el131
1 files changed, 55 insertions, 76 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 715dcde3773..6a652f22789 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -1,11 +1,10 @@
1;;; imenu.el --- Framework for mode-specific buffer indexes. 1;;; imenu.el --- Framework for mode-specific buffer indexes.
2 2
3;; Copyright (C) 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
4 4
5;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se> 5;; Author: Ake Stenhoff <etxaksf@aom.ericsson.se>
6;; Lars Lindberg <lli@sypro.cap.se> 6;; Lars Lindberg <lli@sypro.cap.se>
7;; Created: 8 Feb 1994 7;; Created: 8 Feb 1994
8;; Version: 1.17
9;; Keywords: tools 8;; Keywords: tools
10;; 9;;
11;; This program is free software; you can redistribute it and/or modify 10;; This program is free software; you can redistribute it and/or modify
@@ -62,16 +61,14 @@
62;;; 61;;;
63;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 62;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64(defvar imenu-use-keymap-menu nil 63(defvar imenu-use-keymap-menu nil
65 "* Set this to non-nil for using a keymap when making 64 "*Non-nil means use a keymap when making the mouse menu.")
66 the mouse menu.")
67 65
68(defvar imenu-auto-rescan nil 66(defvar imenu-auto-rescan nil
69 "* T if we always should rescan the buffers, nil to disable 67 "*Non-nil means Imenu should always rescan the buffers.")
70 automatic rescan.")
71 68
72(defvar imenu-auto-rescan-maxout 60000 69(defvar imenu-auto-rescan-maxout 60000
73 "* auto-rescan is disabled in buffers larger than this. 70 "* auto-rescan is disabled in buffers larger than this.
74 This variable is buffer-local.") 71This variable is buffer-local.")
75 72
76(defvar imenu-always-use-completion-buffer-p nil 73(defvar imenu-always-use-completion-buffer-p nil
77 "*Set this to non-nil for displaying the index in a completion buffer. 74 "*Set this to non-nil for displaying the index in a completion buffer.
@@ -99,7 +96,7 @@ element should come before the second. The arguments are cons cells;
99(defvar imenu-max-items 25 96(defvar imenu-max-items 25
100 "*Maximum number of elements in an index mouse-menu.") 97 "*Maximum number of elements in an index mouse-menu.")
101 98
102(defvar imenu-scanning-message "Scanning buffer for index. (%3d%%)" 99(defvar imenu-scanning-message "Scanning buffer for index (%3d%%)"
103 "*Progress message during the index scanning of the buffer. 100 "*Progress message during the index scanning of the buffer.
104If non-nil, user gets a message during the scanning of the buffer 101If non-nil, user gets a message during the scanning of the buffer
105 102
@@ -133,9 +130,9 @@ MENU-TITLE is a string used as the title for the submenu or nil if the
133entries are not nested. 130entries are not nested.
134 131
135REGEXP is a regexp that should match a construct in the buffer that is 132REGEXP is a regexp that should match a construct in the buffer that is
136to be displayed in the menu i.e. function or variable definitions, 133to be displayed in the menu; i.e., function or variable definitions,
137etc. It contains a substring which is the name to appear in the 134etc. It contains a substring which is the name to appear in the
138menu. See the info section on Regexps for more information. 135menu. See the info section on Regexps for more information.
139 136
140INDEX points to the substring in REGEXP that contains the name (of the 137INDEX points to the substring in REGEXP that contains the name (of the
141function, variable or type) that is to appear in the menu. 138function, variable or type) that is to appear in the menu.
@@ -148,11 +145,7 @@ For emacs-lisp-mode for example PATTERN would look like:
148 145
149The variable is buffer-local.") 146The variable is buffer-local.")
150 147
151;;;###autoload 148(make-variable-buffer-local 'imenu-generic-expression)
152(make-variable-buffer-local 'imenu-create-index-pattern)
153
154;; make sure the default is nil
155(setq-default imenu-create-index-pattern nil)
156 149
157;;;; Hooks 150;;;; Hooks
158 151
@@ -160,8 +153,8 @@ The variable is buffer-local.")
160 "The function to use for creating a buffer index. 153 "The function to use for creating a buffer index.
161 154
162It should be a function that takes no arguments and returns an index 155It should be a function that takes no arguments and returns an index
163of the current buffer as an alist. The elements in the alist look 156of the current buffer as an alist. The elements in the alist look
164like: (INDEX-NAME . INDEX-POSITION). You may also nest index list like 157like: (INDEX-NAME . INDEX-POSITION). You may also nest index list like
165\(INDEX-NAME . INDEX-ALIST). 158\(INDEX-NAME . INDEX-ALIST).
166 159
167This function is called within a `save-excursion'. 160This function is called within a `save-excursion'.
@@ -178,7 +171,7 @@ to a function that will find the next index, looking backwards in the
178file. 171file.
179 172
180The function should leave point at the place to be connected to the 173The function should leave point at the place to be connected to the
181index and it should return nil when it doesn't find another index. ") 174index and it should return nil when it doesn't find another index.")
182(make-variable-buffer-local 'imenu-prev-index-position-function) 175(make-variable-buffer-local 'imenu-prev-index-position-function)
183 176
184(defvar imenu-extract-index-name-function nil 177(defvar imenu-extract-index-name-function nil
@@ -305,9 +298,7 @@ This function is called after the function pointed out by
305 "^\\s-*(def\\(type\\|struct\\|class\\|ine-condition\\)\\s-+\\([-A-Za-z0-9+]+\\)" 298 "^\\s-*(def\\(type\\|struct\\|class\\|ine-condition\\)\\s-+\\([-A-Za-z0-9+]+\\)"
306 2)) 299 2))
307 300
308 "imenu generic expression for Lisp mode in the form 301 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
309(PATTERN), where PATTERN is a list containing entries of the form
310(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.")
311 302
312;;; 303;;;
313;;; C++ 304;;; C++
@@ -337,7 +328,7 @@ This function is called after the function pointed out by
337 "[^a-zA-Z1-9_][^(]*" ; ...or operator 328 "[^a-zA-Z1-9_][^(]*" ; ...or operator
338 " \\)" 329 " \\)"
339 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after 330 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after
340 ; the (...) to avoid prototypes. Can't 331 ; the (...) to avoid prototypes. Can't
341 ; catch cases with () inside the parentheses 332 ; catch cases with () inside the parentheses
342 ; surrounding the parameters 333 ; surrounding the parameters
343 ; (like "int foo(int a=bar()) {...}" 334 ; (like "int foo(int a=bar()) {...}"
@@ -352,7 +343,7 @@ This function is called after the function pointed out by
352 "[ \t]*[:{]" 343 "[ \t]*[:{]"
353 )) 2) 344 )) 2)
354;; Example of generic expression for finding prototypes, structs, unions, enums. 345;; Example of generic expression for finding prototypes, structs, unions, enums.
355;; Uncomment if You want to find these too. It will be at bit slower gathering 346;; Uncomment if You want to find these too. It will be at bit slower gathering
356;; the indexes. 347;; the indexes.
357; ("Prototypes" 348; ("Prototypes"
358; (, 349; (,
@@ -408,9 +399,7 @@ This function is called after the function pointed out by
408; "[ \t]*[{]" 399; "[ \t]*[{]"
409; )) 3) 400; )) 3)
410 )) 401 ))
411 "imenu generic expression for C++ mode in the form 402 "Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
412(PATTERN), where PATTERN is a list containing entries of the form
413(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.")
414 403
415;;; 404;;;
416;;; C 405;;; C
@@ -419,9 +408,7 @@ This function is called after the function pointed out by
419(defvar imenu-generic-c-expression 408(defvar imenu-generic-c-expression
420 ;; Use the C++ expression above. 409 ;; Use the C++ expression above.
421 imenu-generic-c++-expression 410 imenu-generic-c++-expression
422 "imenu generic expression for C mode in the form 411 "Imenu generic expression for C mode. See `imenu-generic-expression'.")
423(PATTERN), where PATTERN is a list containing entries of the form
424(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.")
425 412
426;; Regular expression to find C functions 413;; Regular expression to find C functions
427(defvar imenu-example--function-name-regexp-c 414(defvar imenu-example--function-name-regexp-c
@@ -464,9 +451,7 @@ This function is called after the function pointed out by
464 '((nil "^\\s-*\\(procedure\\|function\\)\\s-+\\([A-Za-z0-9_]+\\)" 2) 451 '((nil "^\\s-*\\(procedure\\|function\\)\\s-+\\([A-Za-z0-9_]+\\)" 2)
465 ("Type Defs" "^\\s-*\\(sub\\)?type\\s-+\\([A-Za-z0-9_]+\\)" 2)) 452 ("Type Defs" "^\\s-*\\(sub\\)?type\\s-+\\([A-Za-z0-9_]+\\)" 2))
466 453
467 "imenu generic expression for Ada mode in the form 454 "Imenu generic expression for Ada mode. See `imenu-generic-expression'.")
468(PATTERN), where PATTERN is a list containing entries of the form
469(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.")
470 455
471;;; 456;;;
472;;; TexInfo 457;;; TexInfo
@@ -478,9 +463,7 @@ This function is called after the function pointed out by
478 '((nil "^@node[ \t]+\\([^,\n]*\\)" 1) 463 '((nil "^@node[ \t]+\\([^,\n]*\\)" 1)
479 ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1)) 464 ("Chapters" "^@chapter[ \t]+\\(.*\\)$" 1))
480 465
481 "imenu generic expression for TexInfo mode in the form 466 "Imenu generic expression for TexInfo mode. See `imenu-generic-expression'.
482(PATTERN), where PATTERN is a list containing entries of the form
483(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.
484 467
485To overide this example, Either set 'imenu-generic-expression 468To overide this example, Either set 'imenu-generic-expression
486or 'imenu-create-index-function") 469or 'imenu-create-index-function")
@@ -502,9 +485,7 @@ or 'imenu-create-index-function")
502 ;; being printed. 485 ;; being printed.
503 ("Equations" "%[ \t]*\\([0-9]+\\.[0-9]+\\)[,;]?[ \t]?" 1)) 486 ("Equations" "%[ \t]*\\([0-9]+\\.[0-9]+\\)[,;]?[ \t]?" 1))
504 487
505 "imenu generic expression for LaTex mode in the form 488 "Imenu generic expression for LaTex mode. See `imenu-generic-expression'.")
506(PATTERN), where PATTERN is a list containing entries of the form
507(MENU-TITLE REGEXP INDEX). See `imenu-generic-expression'.")
508 489
509;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 490;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
510;;; 491;;;
@@ -521,9 +502,8 @@ or 'imenu-create-index-function")
521(make-variable-buffer-local 'imenu--index-alist) 502(make-variable-buffer-local 'imenu--index-alist)
522 503
523;; History list for 'jump-to-function-in-buffer'. 504;; History list for 'jump-to-function-in-buffer'.
524;; Buffer local. 505;; Making this buffer local caused it not to work!
525(defvar imenu--history-list nil) 506(defvar imenu--history-list nil)
526(make-variable-buffer-local 'imenu--history-list)
527 507
528(defvar imenu--scanning-method-alist 508(defvar imenu--scanning-method-alist
529 '((emacs-lisp-mode imenu-generic-lisp-expression) 509 '((emacs-lisp-mode imenu-generic-lisp-expression)
@@ -536,11 +516,11 @@ or 'imenu-create-index-function")
536 516
537 "Alist of major mode and imenu scanning methods. 517 "Alist of major mode and imenu scanning methods.
538 518
539Each item should be a list of the form: (MAJOR-MODE 519Each item should be a list of the form (MAJOR-MODE
540IMENU-SCANNING-METHOD) where both MAJOR-MODE and IMENU-SCANNING-METHOD 520IMENU-SCANNING-METHOD), where both MAJOR-MODE and IMENU-SCANNING-METHOD
541are symbols. If IMENU-SCANNING-METHOD is a function then it is called 521are symbols. If IMENU-SCANNING-METHOD is a function then it is called
542to create an index. If it is a `pattern' (See `imenu-generic-expression') 522to create an index. If it is a \"pattern\" (see `imenu-generic-expression')
543it is passed to imenu--generic-function to create an index.") 523it is passed to `imenu--generic-function' to create an index.")
544 524
545;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 525;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
546;;; 526;;;
@@ -625,7 +605,7 @@ it is passed to imenu--generic-function to create an index.")
625 (save-excursion 605 (save-excursion
626 (funcall imenu-create-index-function)))) 606 (funcall imenu-create-index-function))))
627 (or imenu--index-alist 607 (or imenu--index-alist
628 (error "No items suitable for an index found in this buffer.")) 608 (error "No items suitable for an index found in this buffer"))
629 ;; Add a rescan option to the index. 609 ;; Add a rescan option to the index.
630 (cons imenu--rescan-item imenu--index-alist)) 610 (cons imenu--rescan-item imenu--index-alist))
631;;; 611;;;
@@ -768,15 +748,15 @@ Their results are gathered into an index alist."
768 "Return an index of the current buffer as an alist. 748 "Return an index of the current buffer as an alist.
769 749
770PATTERN is an alist with elements that look like this: (MENU-TITLE 750PATTERN is an alist with elements that look like this: (MENU-TITLE
771REGEXP INDEX). 751REGEXP INDEX).
772 752
773MENU-TITLE is a string used as the title for the submenu or nil if the 753MENU-TITLE is a string used as the title for the submenu or nil if the
774entries are not nested. 754entries are not nested.
775 755
776REGEXP is a regexp that should match a construct in the buffer that is 756REGEXP is a regexp that should match a construct in the buffer that is
777to be displayed in the menu i.e. function or variable definitions, 757to be displayed in the menu; i.e., function or variable definitions,
778etc. It contains a substring which is the name to appear in the 758etc. It contains a substring which is the name to appear in the
779menu. See the info section on Regexps for more information. 759menu. See the info section on Regexps for more information.
780 760
781INDEX points to the substring in REGEXP that contains the name (of the 761INDEX points to the substring in REGEXP that contains the name (of the
782function, variable or type) that is to appear in the menu. 762function, variable or type) that is to appear in the menu.
@@ -787,8 +767,8 @@ For emacs-lisp-mode for example PATTERN would look like:
787 (\"*Vars*\" \"^\\s-*(def\\(var\\|const\\)\\s-+\\([-A-Za-z0-9]+\\)\" 2) 767 (\"*Vars*\" \"^\\s-*(def\\(var\\|const\\)\\s-+\\([-A-Za-z0-9]+\\)\" 2)
788 (\"*Types*\" \"^\\s-*(def\\(type\\|struct\\|class\\|ine-condition\\)\\s-+\\([-A-Za-z0-9]+\\)\" 2))' 768 (\"*Types*\" \"^\\s-*(def\\(type\\|struct\\|class\\|ine-condition\\)\\s-+\\([-A-Za-z0-9]+\\)\" 2))'
789 769
790Returns an index of the current buffer as an alist. The elements in 770Returns an index of the current buffer as an alist. The elements in
791the alist look like: (INDEX-NAME . INDEX-POSITION). They may also be 771the alist look like: (INDEX-NAME . INDEX-POSITION). They may also be
792nested index lists like (INDEX-NAME . INDEX-ALIST) depending on 772nested index lists like (INDEX-NAME . INDEX-ALIST) depending on
793pattern. 773pattern.
794 774
@@ -982,8 +962,7 @@ The returned value is on the form (INDEX-NAME . INDEX-POSITION)."
982 962
983;;;###autoload 963;;;###autoload
984(defun imenu-add-to-menubar (name) 964(defun imenu-add-to-menubar (name)
985 "Adds an \"imenu\" entry to the menubar for the 965 "Adds an \"imenu\" entry to the menubar for the current local keymap.
986current local keymap.
987NAME is the string naming the menu to be added. 966NAME is the string naming the menu to be added.
988See 'imenu' for more information." 967See 'imenu' for more information."
989 (interactive "sMenu name: ") 968 (interactive "sMenu name: ")
@@ -992,29 +971,29 @@ See 'imenu' for more information."
992 (cons name 'imenu)))) 971 (cons name 'imenu))))
993 972
994;;;###autoload 973;;;###autoload
995(defun imenu () 974(defun imenu (index-item)
996 "Jump to a place in the buffer chosen using a buffer menu or mouse menu. 975 "Jump to a place in the buffer chosen using a buffer menu or mouse menu.
997See `imenu-choose-buffer-index' for more information." 976See `imenu-choose-buffer-index' for more information."
998 (interactive) 977 (interactive
999 (let ((index-item (save-restriction 978 (list (save-restriction
1000 (widen) 979 (widen)
1001 (imenu-choose-buffer-index)))) 980 (imenu-choose-buffer-index))))
1002 (and index-item 981 (and index-item
1003 (progn 982 (progn
1004 (push-mark) 983 (push-mark)
1005 (cond 984 (cond
1006 ((markerp (cdr index-item)) 985 ((markerp (cdr index-item))
1007 (if (or ( > (marker-position (cdr index-item)) (point-min)) 986 (if (or ( > (marker-position (cdr index-item)) (point-min))
1008 ( < (marker-position (cdr index-item)) (point-max))) 987 ( < (marker-position (cdr index-item)) (point-max)))
1009 ;; widen if outside narrowing 988 ;; widen if outside narrowing
1010 (widen)) 989 (widen))
1011 (goto-char (marker-position (cdr index-item)))) 990 (goto-char (marker-position (cdr index-item))))
1012 (t 991 (t
1013 (if (or ( > (cdr index-item) (point-min)) 992 (if (or ( > (cdr index-item) (point-min))
1014 ( < (cdr index-item) (point-max))) 993 ( < (cdr index-item) (point-max)))
1015 ;; widen if outside narrowing 994 ;; widen if outside narrowing
1016 (widen)) 995 (widen))
1017 (goto-char (cdr index-item)))))))) 996 (goto-char (cdr index-item)))))))
1018 997
1019(provide 'imenu) 998(provide 'imenu)
1020 999