Changeset 4073 for trunk/lisp/imenu.el
- Timestamp:
- 2006年05月03日 18時37分43秒 (3 years ago)
- Files:
-
- trunk (modified) (1 prop)
- trunk/lisp/imenu.el (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore changed from
bin
to
bin
site-lisp
- Property svn:ignore changed from
trunk/lisp/imenu.el
r4037 r4073 209 209 ;;;###autoload 210 210 (defvar imenu-create-index-function 'imenu-default-create-index-function 211 "The function to use for creating a buffer index. 212 213 It should be a function that takes no arguments and returns an index 214 of the current buffer as an alist. 215 216 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 217 Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). 218 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST). 219 The function `imenu--subalist-p' tests an element and returns t 220 if it is a sub-alist. 221 222 This function is called within a `save-excursion'.") 211 "The function to use for creating an index alist of the current buffer. 212 213 It should be a function that takes no arguments and returns 214 an index alist of the current buffer. The function is 215 called within a `save-excursion'. 216 217 See `imenu--index-alist' for the format of the buffer index alist.") 223 218 ;;;###autoload 224 219 (make-variable-buffer-local 'imenu-create-index-function) … … 432 427 ;; Buffer local. 433 428 (defvar imenu--index-alist nil 434 "The buffer index computed for this buffer in Imenu. 435 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 436 Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). 437 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).") 429 "The buffer index alist computed for this buffer in Imenu. 430 431 Simple elements in the alist look like (INDEX-NAME . POSITION). 432 POSITION is the buffer position of the item; to go to the item 433 is simply to move point to that position. 434 435 Special elements look like (INDEX-NAME POSITION FUNCTION ARGUMENTS...). 436 To \"go to\" a special element means applying FUNCTION 437 to INDEX-NAME, POSITION, and the ARGUMENTS. 438 439 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST). 440 The function `imenu--subalist-p' tests an element and returns t 441 if it is a sub-alist. 442 443 There is one simple element with negative POSITION; selecting that 444 element recalculates the buffer's index alist.") 438 445 439 446 (make-variable-buffer-local 'imenu--index-alist) 440 447 441 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 451 (make-variable-buffer-local 'imenu--last-menubar-index-alist) … … 548 555 549 556 (defun imenu--make-index-alist (&optional noerror) 550 "Create an index -alist for the definitions in the current buffer.551 557 "Create an index alist for the definitions in the current buffer. 558 This works by using the hook function `imenu-create-index-function'. 552 559 Report an error if the list is empty unless NOERROR is supplied and 553 560 non-nil. 554 561 555 Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). 556 Special elements look like (INDEX-NAME FUNCTION ARGUMENTS...). 557 A nested sub-alist element looks like (INDEX-NAME SUB-ALIST). 558 The function `imenu--subalist-p' tests an element and returns t 559 if it is a sub-alist. 560 561 There is one simple element with negative POSITION; that's intended 562 as a way for the user to ask to recalculate the buffer's index alist." 562 See `imenu--index-alist' for the format of the index alist." 563 563 (or (and imenu--index-alist 564 564 (or (not imenu-auto-rescan) … … 658 658 659 659 (defun imenu-default-create-index-function () 660 "* Wrapper for index searching functions.661 662 Moves point to end of buffer and then repeatedly calls 660 "*Default function to create an index alist of the current buffer. 661 662 The most general method is to move point to end of buffer, then repeatedly call 663 663 `imenu-prev-index-position-function' and `imenu-extract-index-name-function'. 664 Their results are gathered into an index alist." 664 All the results returned by the latter are gathered into an index alist. 665 This method is used if those two variables are non-nil. 666 667 The alternate method, which is the one most often used, is to call 668 `imenu--generic-function' with `imenu-generic-expression' as argument." 665 669 ;; These should really be done by setting imenu-create-index-function 666 670 ;; in these major modes. But save that change for later. … … 688 692 (error "This buffer cannot use `imenu-default-create-index-function'")))) 689 693 690 ;; Not used and would require cl at run time691 ;; (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 its694 ;; ;; name and a space concatenated to the names of the children.695 ;; ;; Third argument PREFIX is for internal use only.696 ;; (mapcan697 ;; (lambda (item)698 ;; (let* ((name (car item))699 ;; (pos (cdr item))700 ;; (new-prefix (and concat-names701 ;; (if prefix702 ;; (concat prefix imenu-level-separator name)703 ;; name))))704 ;; (cond705 ;; ((or (markerp pos) (numberp pos))706 ;; (list (cons new-prefix pos)))707 ;; (t708 ;; (imenu--flatten-index-alist pos new-prefix)))))709 ;; index-alist))710 711 694 ;;; 712 695 ;;; Generic index gathering function. … … 725 708 ;; so it needs to be careful never to loop! 726 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 729 712 PATTERNS is an alist with elements that look like this: … … 733 716 with zero or more ARGUMENTS. The former format creates a simple 734 717 element in the index alist when it matches; the latter creates a 735 special element of the form (NAME POSITION-MARKER FUNCTION 736 ARGUMENTS...) with FUNCTION and ARGUMENTS copied from 737 `imenu-generic-expression'. 718 special element of the form (INDEX-NAME POSITION-MARKER FUNCTION 719 ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS. 738 720 739 721 MENU-TITLE is a string used as the title for the submenu or nil
