aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2006-04-18 21:22:33 +0000
committerRichard M. Stallman2006-04-18 21:22:33 +0000
commit98639288c8eaff279787d862490fd136fc1ec284 (patch)
tree6b296d97afa167f98ddbdd80543f69eae6cf208c
parentdf5b8a5364661aed18c7801c3ecfb3754b6f77c6 (diff)
downloademacs-98639288c8eaff279787d862490fd136fc1ec284.tar.gz
emacs-98639288c8eaff279787d862490fd136fc1ec284.zip
(imenu-create-index-function, imenu--index-alist)
(imenu--last-menubar-index-alist, imenu--make-index-alist) (imenu-default-create-index-function, imenu--generic-function): Doc fixes.
-rw-r--r--lisp/imenu.el88
1 files changed, 35 insertions, 53 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 774903e1092..381e6481393 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -208,18 +208,13 @@ during matching.")
208 208
209;;;###autoload 209;;;###autoload
210(defvar imenu-create-index-function 'imenu-default-create-index-function 210(defvar imenu-create-index-function 'imenu-default-create-index-function
211 "The function to use for creating a buffer index. 211 "The function to use for creating an index alist of the current buffer.
212 212
213It should be a function that takes no arguments and returns an index 213It should be a function that takes no arguments and returns
214of the current buffer as an alist. 214an index alist of the current buffer. The function is
215called within a `save-excursion'.
215 216
216Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 217See `imenu--index-alist' for the format of the buffer index alist.")
217Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...).
218A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
219The function `imenu--subalist-p' tests an element and returns t
220if it is a sub-alist.
221
222This function is called within a `save-excursion'.")
223;;;###autoload 218;;;###autoload
224(make-variable-buffer-local 'imenu-create-index-function) 219(make-variable-buffer-local 'imenu-create-index-function)
225 220
@@ -431,15 +426,27 @@ Don't move point."
431;; The latest buffer index. 426;; The latest buffer index.
432;; Buffer local. 427;; Buffer local.
433(defvar imenu--index-alist nil 428(defvar imenu--index-alist nil
434 "The buffer index computed for this buffer in Imenu. 429 "The buffer index alist computed for this buffer in Imenu.
435Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 430
436Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). 431Simple elements in the alist look like (INDEX-NAME . POSITION).
437A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).") 432POSITION is the buffer position of the item; to go to the item
433is simply to move point to that position.
434
435Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...).
436To \"go to\" a special element means applying FUNCTION
437to INDEX-NAME, POSITION, and the ARGUMENTS.
438
439A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
440The function `imenu--subalist-p' tests an element and returns t
441if it is a sub-alist.
442
443There is one simple element with negative POSITION; selecting that
444element recalculates the buffer's index alist."
438 445
439(make-variable-buffer-local 'imenu--index-alist) 446(make-variable-buffer-local 'imenu--index-alist)
440 447
441(defvar imenu--last-menubar-index-alist nil 448(defvar imenu--last-menubar-index-alist nil
442 "The latest buffer index used to update the menu bar menu.") 449 "The latest buffer index alist used to update the menu bar menu.")
443 450
444(make-variable-buffer-local 'imenu--last-menubar-index-alist) 451(make-variable-buffer-local 'imenu--last-menubar-index-alist)
445 452
@@ -547,19 +554,12 @@ A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).")
547 554
548 555
549(defun imenu--make-index-alist (&optional noerror) 556(defun imenu--make-index-alist (&optional noerror)
550 "Create an index-alist for the definitions in the current buffer. 557 "Create an index alist for the definitions in the current buffer.
551 558This works by using the hook function `imenu-create-index-function'.
552Report an error if the list is empty unless NOERROR is supplied and 559Report an error if the list is empty unless NOERROR is supplied and
553non-nil. 560non-nil.
554 561
555Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 562See `imenu--index-alist' for the format of the index alist."
556Special elements look like (INDEX-NAME FUNCTION ARGUMENTS...).
557A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).
558The function `imenu--subalist-p' tests an element and returns t
559if it is a sub-alist.
560
561There is one simple element with negative POSITION; that's intended
562as a way for the user to ask to recalculate the buffer's index alist."
563 (or (and imenu--index-alist 563 (or (and imenu--index-alist
564 (or (not imenu-auto-rescan) 564 (or (not imenu-auto-rescan)
565 (and imenu-auto-rescan 565 (and imenu-auto-rescan
@@ -657,11 +657,15 @@ and speed-up matching.")
657(make-variable-buffer-local 'imenu-syntax-alist) 657(make-variable-buffer-local 'imenu-syntax-alist)
658 658
659(defun imenu-default-create-index-function () 659(defun imenu-default-create-index-function ()
660 "*Wrapper for index searching functions. 660 "*Default function to create an index alist of the current buffer.
661 661
662Moves point to end of buffer and then repeatedly calls 662The most general method is to move point to end of buffer, then repeatedly call
663`imenu-prev-index-position-function' and `imenu-extract-index-name-function'. 663`imenu-prev-index-position-function' and `imenu-extract-index-name-function'.
664Their results are gathered into an index alist." 664All the results returned by the latter are gathered into an index alist.
665This method is used if those two variables are non-nil.
666
667The alternate method, which is the one most often used, is to call
668`imenu--generic-function' with `imenu-generic-expression' as argument."
665 ;; These should really be done by setting imenu-create-index-function 669 ;; These should really be done by setting imenu-create-index-function
666 ;; in these major modes. But save that change for later. 670 ;; in these major modes. But save that change for later.
667 (cond ((and imenu-prev-index-position-function 671 (cond ((and imenu-prev-index-position-function
@@ -687,27 +691,6 @@ Their results are gathered into an index alist."
687 (t 691 (t
688 (error "This buffer cannot use `imenu-default-create-index-function'")))) 692 (error "This buffer cannot use `imenu-default-create-index-function'"))))
689 693
690;; Not used and would require cl at run time
691;; (defun imenu--flatten-index-alist (index-alist &optional concat-names prefix)
692;; ;; Takes a nested INDEX-ALIST and returns a flat index alist.
693;; ;; If optional CONCAT-NAMES is non-nil, then a nested index has its
694;; ;; name and a space concatenated to the names of the children.
695;; ;; Third argument PREFIX is for internal use only.
696;; (mapcan
697;; (lambda (item)
698;; (let* ((name (car item))
699;; (pos (cdr item))
700;; (new-prefix (and concat-names
701;; (if prefix
702;; (concat prefix imenu-level-separator name)
703;; name))))
704;; (cond
705;; ((or (markerp pos) (numberp pos))
706;; (list (cons new-prefix pos)))
707;; (t
708;; (imenu--flatten-index-alist pos new-prefix)))))
709;; index-alist))
710
711;;; 694;;;
712;;; Generic index gathering function. 695;;; Generic index gathering function.
713;;; 696;;;
@@ -724,7 +707,7 @@ for modes which use `imenu--generic-function'. If it is not set, but
724;; This function can be called with quitting disabled, 707;; This function can be called with quitting disabled,
725;; so it needs to be careful never to loop! 708;; so it needs to be careful never to loop!
726(defun imenu--generic-function (patterns) 709(defun imenu--generic-function (patterns)
727 "Return an index of the current buffer as an alist. 710 "Return an index alist of the current buffer based on PATTERNS.
728 711
729PATTERNS is an alist with elements that look like this: 712PATTERNS is an alist with elements that look like this:
730 (MENU-TITLE REGEXP INDEX) 713 (MENU-TITLE REGEXP INDEX)
@@ -732,9 +715,8 @@ or like this:
732 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) 715 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
733with zero or more ARGUMENTS. The former format creates a simple 716with zero or more ARGUMENTS. The former format creates a simple
734element in the index alist when it matches; the latter creates a 717element in the index alist when it matches; the latter creates a
735special element of the form (NAME POSITION-MARKER FUNCTION 718special element of the form (INDEX-NAME POSITION-MARKER FUNCTION
736ARGUMENTS...) with FUNCTION and ARGUMENTS copied from 719ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS.
737`imenu-generic-expression'.
738 720
739MENU-TITLE is a string used as the title for the submenu or nil 721MENU-TITLE is a string used as the title for the submenu or nil
740if the entries are not nested. 722if the entries are not nested.