diff options
| author | Richard M. Stallman | 2006-04-18 21:22:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-04-18 21:22:33 +0000 |
| commit | 98639288c8eaff279787d862490fd136fc1ec284 (patch) | |
| tree | 6b296d97afa167f98ddbdd80543f69eae6cf208c | |
| parent | df5b8a5364661aed18c7801c3ecfb3754b6f77c6 (diff) | |
| download | emacs-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.el | 88 |
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 | ||
| 213 | It should be a function that takes no arguments and returns an index | 213 | It should be a function that takes no arguments and returns |
| 214 | of the current buffer as an alist. | 214 | an index alist of the current buffer. The function is |
| 215 | called within a `save-excursion'. | ||
| 215 | 216 | ||
| 216 | Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). | 217 | See `imenu--index-alist' for the format of the buffer index alist.") |
| 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'.") | ||
| 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. |
| 435 | Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). | 430 | |
| 436 | Special elements look like (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...). | 431 | Simple elements in the alist look like (INDEX-NAME . POSITION). |
| 437 | A nested sub-alist element looks like (INDEX-NAME SUB-ALIST).") | 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 | (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 | 558 | This works by using the hook function `imenu-create-index-function'. | |
| 552 | Report an error if the list is empty unless NOERROR is supplied and | 559 | Report an error if the list is empty unless NOERROR is supplied and |
| 553 | non-nil. | 560 | non-nil. |
| 554 | 561 | ||
| 555 | Simple elements in the alist look like (INDEX-NAME . INDEX-POSITION). | 562 | See `imenu--index-alist' for the format of the index alist." |
| 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." | ||
| 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 | ||
| 662 | Moves point to end of buffer and then repeatedly calls | 662 | The 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'. |
| 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 | ;; 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 | ||
| 729 | PATTERNS is an alist with elements that look like this: | 712 | PATTERNS 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...) |
| 733 | with zero or more ARGUMENTS. The former format creates a simple | 716 | with zero or more ARGUMENTS. The former format creates a simple |
| 734 | element in the index alist when it matches; the latter creates a | 717 | element in the index alist when it matches; the latter creates a |
| 735 | special element of the form (NAME POSITION-MARKER FUNCTION | 718 | special element of the form (INDEX-NAME POSITION-MARKER FUNCTION |
| 736 | ARGUMENTS...) with FUNCTION and ARGUMENTS copied from | 719 | ARGUMENTS...) with FUNCTION and ARGUMENTS copied from PATTERNS. |
| 737 | `imenu-generic-expression'. | ||
| 738 | 720 | ||
| 739 | MENU-TITLE is a string used as the title for the submenu or nil | 721 | MENU-TITLE is a string used as the title for the submenu or nil |
| 740 | if the entries are not nested. | 722 | if the entries are not nested. |