diff options
| author | Daniel Pfeiffer | 2005-05-21 02:44:29 +0000 |
|---|---|---|
| committer | Daniel Pfeiffer | 2005-05-21 02:44:29 +0000 |
| commit | fb50d1e9db15111b5952a8709e4a5774ae34624b (patch) | |
| tree | db5a7bc1184655f2fd8a13057f95898d396e4864 | |
| parent | 813731b3dc55a2e92b29a2ef656353cbf20faa6e (diff) | |
| download | emacs-fb50d1e9db15111b5952a8709e4a5774ae34624b.tar.gz emacs-fb50d1e9db15111b5952a8709e4a5774ae34624b.zip | |
(imenu-generic-expression, imenu--generic-function'): REGEXP may also be a search function now. The part of doc-string for describing the structure was 95% identical to that of `imenu--generic-function'. Unify it there.
| -rw-r--r-- | lisp/imenu.el | 69 |
1 files changed, 30 insertions, 39 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 92e00282ea0..0ebdbc4b5f3 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -192,32 +192,9 @@ with name concatenation." | |||
| 192 | (defvar imenu-generic-expression nil | 192 | (defvar imenu-generic-expression nil |
| 193 | "The regex pattern to use for creating a buffer index. | 193 | "The regex pattern to use for creating a buffer index. |
| 194 | 194 | ||
| 195 | If non-nil this pattern is passed to `imenu--generic-function' | 195 | If non-nil this pattern is passed to `imenu--generic-function' to |
| 196 | to create a buffer index. | 196 | create a buffer index. Look there for the documentation of this |
| 197 | 197 | pattern's structure. | |
| 198 | The value should be an alist with elements that look like this: | ||
| 199 | (MENU-TITLE REGEXP INDEX) | ||
| 200 | or like this: | ||
| 201 | (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) | ||
| 202 | with zero or more ARGUMENTS. The former format creates a simple element in | ||
| 203 | the index alist when it matches; the latter creates a special element | ||
| 204 | of the form (NAME POSITION-MARKER FUNCTION ARGUMENTS...) | ||
| 205 | with FUNCTION and ARGUMENTS copied from `imenu-generic-expression'. | ||
| 206 | |||
| 207 | MENU-TITLE is a string used as the title for the submenu or nil if the | ||
| 208 | entries are not nested. | ||
| 209 | |||
| 210 | REGEXP is a regexp that should match a construct in the buffer that is | ||
| 211 | to be displayed in the menu; i.e., function or variable definitions, | ||
| 212 | etc. It contains a substring which is the name to appear in the | ||
| 213 | menu. See the info section on Regexps for more information. | ||
| 214 | |||
| 215 | INDEX points to the substring in REGEXP that contains the name (of the | ||
| 216 | function, variable or type) that is to appear in the menu. | ||
| 217 | |||
| 218 | The variable `imenu-case-fold-search' determines whether or not the | ||
| 219 | regexp matches are case sensitive, and `imenu-syntax-alist' can be | ||
| 220 | used to alter the syntax table for the search. | ||
| 221 | 198 | ||
| 222 | For example, see the value of `fortran-imenu-generic-expression' used by | 199 | For example, see the value of `fortran-imenu-generic-expression' used by |
| 223 | `fortran-mode' with `imenu-syntax-alist' set locally to give the | 200 | `fortran-mode' with `imenu-syntax-alist' set locally to give the |
| @@ -750,21 +727,33 @@ for modes which use `imenu--generic-function'. If it is not set, but | |||
| 750 | "Return an index of the current buffer as an alist. | 727 | "Return an index of the current buffer as an alist. |
| 751 | 728 | ||
| 752 | PATTERNS is an alist with elements that look like this: | 729 | PATTERNS is an alist with elements that look like this: |
| 753 | (MENU-TITLE REGEXP INDEX). | 730 | (MENU-TITLE REGEXP INDEX) |
| 754 | or like this: | 731 | or like this: |
| 755 | (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) | 732 | (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
| 756 | with zero or more ARGUMENTS. | 733 | with zero or more ARGUMENTS. The former format creates a simple |
| 757 | 734 | element in the index alist when it matches; the latter creates a | |
| 758 | MENU-TITLE is a string used as the title for the submenu or nil if the | 735 | special element of the form (NAME POSITION-MARKER FUNCTION |
| 759 | entries are not nested. | 736 | ARGUMENTS...) with FUNCTION and ARGUMENTS copied from |
| 737 | `imenu-generic-expression'. | ||
| 738 | |||
| 739 | MENU-TITLE is a string used as the title for the submenu or nil | ||
| 740 | if the entries are not nested. | ||
| 741 | |||
| 742 | REGEXP is a regexp that should match a construct in the buffer | ||
| 743 | that is to be displayed in the menu; i.e., function or variable | ||
| 744 | definitions, etc. It contains a substring which is the name to | ||
| 745 | appear in the menu. See the info section on Regexps for more | ||
| 746 | information. REGEXP may also be a function, called without | ||
| 747 | arguments. It is expected to search backwards. It shall return | ||
| 748 | true and set `match-data' iff it finds another element. | ||
| 749 | |||
| 750 | INDEX points to the substring in REGEXP that contains the | ||
| 751 | name (of the function, variable or type) that is to appear in the | ||
| 752 | menu. | ||
| 760 | 753 | ||
| 761 | REGEXP is a regexp that should match a construct in the buffer that is | 754 | The variable `imenu-case-fold-search' determines whether or not the |
| 762 | to be displayed in the menu; i.e., function or variable definitions, | 755 | regexp matches are case sensitive, and `imenu-syntax-alist' can be |
| 763 | etc. It contains a substring which is the name to appear in the | 756 | used to alter the syntax table for the search. |
| 764 | menu. See the info section on Regexps for more information. | ||
| 765 | |||
| 766 | INDEX points to the substring in REGEXP that contains the name (of the | ||
| 767 | function, variable or type) that is to appear in the menu. | ||
| 768 | 757 | ||
| 769 | See `lisp-imenu-generic-expression' for an example of PATTERNS. | 758 | See `lisp-imenu-generic-expression' for an example of PATTERNS. |
| 770 | 759 | ||
| @@ -811,7 +800,9 @@ depending on PATTERNS." | |||
| 811 | start beg) | 800 | start beg) |
| 812 | ;; Go backwards for convenience of adding items in order. | 801 | ;; Go backwards for convenience of adding items in order. |
| 813 | (goto-char (point-max)) | 802 | (goto-char (point-max)) |
| 814 | (while (and (re-search-backward regexp nil t) | 803 | (while (and (if (functionp regexp) |
| 804 | (funcall regexp) | ||
| 805 | (re-search-backward regexp nil t)) | ||
| 815 | ;; Exit the loop if we get an empty match, | 806 | ;; Exit the loop if we get an empty match, |
| 816 | ;; because it means a bad regexp was specified. | 807 | ;; because it means a bad regexp was specified. |
| 817 | (not (= (match-beginning 0) (match-end 0)))) | 808 | (not (= (match-beginning 0) (match-end 0)))) |