192 |
(defvar imenu-generic-expression nil |
(defvar imenu-generic-expression nil |
193 |
"The regex pattern to use for creating a buffer index. |
"The regex pattern to use for creating a buffer index. |
194 |
|
|
195 |
If non-nil this pattern is passed to `imenu--generic-function' |
If non-nil this pattern is passed to `imenu--generic-function' to |
196 |
to create a buffer index. |
create a buffer index. Look there for the documentation of this |
197 |
|
pattern's structure. |
|
The value should be an alist with elements that look like this: |
|
|
(MENU-TITLE REGEXP INDEX) |
|
|
or like this: |
|
|
(MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
|
|
with zero or more ARGUMENTS. The former format creates a simple element in |
|
|
the index alist when it matches; the latter creates a special element |
|
|
of the form (NAME POSITION-MARKER FUNCTION ARGUMENTS...) |
|
|
with FUNCTION and ARGUMENTS copied from `imenu-generic-expression'. |
|
|
|
|
|
MENU-TITLE is a string used as the title for the submenu or nil if the |
|
|
entries are not nested. |
|
|
|
|
|
REGEXP is a regexp that should match a construct in the buffer that is |
|
|
to be displayed in the menu; i.e., function or variable definitions, |
|
|
etc. It contains a substring which is the name to appear in the |
|
|
menu. See the info section on Regexps for more information. |
|
|
|
|
|
INDEX points to the substring in REGEXP that contains the name (of the |
|
|
function, variable or type) that is to appear in the menu. |
|
|
|
|
|
The variable `imenu-case-fold-search' determines whether or not the |
|
|
regexp matches are case sensitive, and `imenu-syntax-alist' can be |
|
|
used to alter the syntax table for the search. |
|
198 |
|
|
199 |
For example, see the value of `fortran-imenu-generic-expression' used by |
For example, see the value of `fortran-imenu-generic-expression' used by |
200 |
`fortran-mode' with `imenu-syntax-alist' set locally to give the |
`fortran-mode' with `imenu-syntax-alist' set locally to give the |
727 |
"Return an index of the current buffer as an alist. |
"Return an index of the current buffer as an alist. |
728 |
|
|
729 |
PATTERNS is an alist with elements that look like this: |
PATTERNS is an alist with elements that look like this: |
730 |
(MENU-TITLE REGEXP INDEX). |
(MENU-TITLE REGEXP INDEX) |
731 |
or like this: |
or like this: |
732 |
(MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
(MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) |
733 |
with zero or more ARGUMENTS. |
with zero or more ARGUMENTS. The former format creates a simple |
734 |
|
element in the index alist when it matches; the latter creates a |
735 |
MENU-TITLE is a string used as the title for the submenu or nil if the |
special element of the form (NAME POSITION-MARKER FUNCTION |
736 |
entries are not nested. |
ARGUMENTS...) with FUNCTION and ARGUMENTS copied from |
737 |
|
`imenu-generic-expression'. |
738 |
REGEXP is a regexp that should match a construct in the buffer that is |
|
739 |
to be displayed in the menu; i.e., function or variable definitions, |
MENU-TITLE is a string used as the title for the submenu or nil |
740 |
etc. It contains a substring which is the name to appear in the |
if the entries are not nested. |
741 |
menu. See the info section on Regexps for more information. |
|
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. |
753 |
|
|
754 |
INDEX points to the substring in REGEXP that contains the name (of the |
The variable `imenu-case-fold-search' determines whether or not the |
755 |
function, variable or type) that is to appear in the menu. |
regexp matches are case sensitive, and `imenu-syntax-alist' can be |
756 |
|
used to alter the syntax table for the search. |
757 |
|
|
758 |
See `lisp-imenu-generic-expression' for an example of PATTERNS. |
See `lisp-imenu-generic-expression' for an example of PATTERNS. |
759 |
|
|
800 |
start beg) |
start beg) |
801 |
;; Go backwards for convenience of adding items in order. |
;; Go backwards for convenience of adding items in order. |
802 |
(goto-char (point-max)) |
(goto-char (point-max)) |
803 |
(while (and (re-search-backward regexp nil t) |
(while (and (if (functionp regexp) |
804 |
|
(funcall regexp) |
805 |
|
(re-search-backward regexp nil t)) |
806 |
;; Exit the loop if we get an empty match, |
;; Exit the loop if we get an empty match, |
807 |
;; because it means a bad regexp was specified. |
;; because it means a bad regexp was specified. |
808 |
(not (= (match-beginning 0) (match-end 0)))) |
(not (= (match-beginning 0) (match-end 0)))) |