236 |
@item |
@item |
237 |
The mode should specify how Imenu should find the definitions or |
The mode should specify how Imenu should find the definitions or |
238 |
sections of a buffer, by setting up a buffer-local value for the |
sections of a buffer, by setting up a buffer-local value for the |
239 |
variable @code{imenu-generic-expression} or |
variable @code{imenu-generic-expression}, for the pair of variables |
240 |
|
@code{imenu-prev-index-position-function} and |
241 |
|
@code{imenu-extract-index-name-function}, or for the variable |
242 |
@code{imenu-create-index-function} (@pxref{Imenu}). |
@code{imenu-create-index-function} (@pxref{Imenu}). |
243 |
|
|
244 |
@item |
@item |
1704 |
@code{imenu-generic-expression}: |
@code{imenu-generic-expression}: |
1705 |
|
|
1706 |
@defvar imenu-generic-expression |
@defvar imenu-generic-expression |
1707 |
This variable, if non-@code{nil}, specifies regular expressions for |
This variable, if non-@code{nil}, is a list that specifies regular |
1708 |
finding definitions for Imenu. In the simplest case, elements should |
expressions for finding definitions for Imenu. Simple elements of |
1709 |
look like this: |
@code{imenu-generic-expression} look like this: |
1710 |
|
|
1711 |
@example |
@example |
1712 |
(@var{menu-title} @var{regexp} @var{subexp}) |
(@var{menu-title} @var{regexp} @var{index}) |
1713 |
@end example |
@end example |
1714 |
|
|
1715 |
Here, if @var{menu-title} is non-@code{nil}, it says that the matches |
Here, if @var{menu-title} is non-@code{nil}, it says that the matches |
1719 |
in the top level of the buffer index. |
in the top level of the buffer index. |
1720 |
|
|
1721 |
The second item in the list, @var{regexp}, is a regular expression |
The second item in the list, @var{regexp}, is a regular expression |
1722 |
(@pxref{Regular Expressions}); anything in the buffer that it matches is |
(@pxref{Regular Expressions}); anything in the buffer that it matches |
1723 |
considered a definition, something to mention in the buffer index. The |
is considered a definition, something to mention in the buffer index. |
1724 |
third item, @var{subexp}, indicates which subexpression in @var{regexp} |
The third item, @var{index}, is a non-negative integer that indicates |
1725 |
matches the definition's name. |
which subexpression in @var{regexp} matches the definition's name. |
1726 |
|
|
1727 |
An element can also look like this: |
An element can also look like this: |
1728 |
|
|
1730 |
(@var{menu-title} @var{regexp} @var{index} @var{function} @var{arguments}@dots{}) |
(@var{menu-title} @var{regexp} @var{index} @var{function} @var{arguments}@dots{}) |
1731 |
@end example |
@end example |
1732 |
|
|
1733 |
Each match for this element creates a special index item which, if |
Like in the previous case, each match for this element creates an |
1734 |
selected by the user, calls @var{function} with arguments consisting of |
index item. However, if this index item is selected by the user, it |
1735 |
the item name, the buffer position, and @var{arguments}. |
calls @var{function} with arguments consisting of the item name, the |
1736 |
|
buffer position, and @var{arguments}. |
1737 |
|
|
1738 |
For Emacs Lisp mode, @var{pattern} could look like this: |
For Emacs Lisp mode, @code{imenu-generic-expression} could look like |
1739 |
|
this: |
1740 |
|
|
1741 |
@c should probably use imenu-syntax-alist and \\sw rather than [-A-Za-z0-9+] |
@c should probably use imenu-syntax-alist and \\sw rather than [-A-Za-z0-9+] |
1742 |
@example |
@example |
1760 |
@end defvar |
@end defvar |
1761 |
|
|
1762 |
@defvar imenu-case-fold-search |
@defvar imenu-case-fold-search |
1763 |
This variable controls whether matching against |
This variable controls whether matching against the regular |
1764 |
@var{imenu-generic-expression} is case-sensitive: @code{t}, the default, |
expressions in the value of @code{imenu-generic-expression} is |
1765 |
means matching should ignore case. |
case-sensitive: @code{t}, the default, means matching should ignore |
1766 |
|
case. |
1767 |
|
|
1768 |
Setting this variable makes it buffer-local in the current buffer. |
Setting this variable makes it buffer-local in the current buffer. |
1769 |
@end defvar |
@end defvar |
1791 |
(setq imenu-syntax-alist '(("_$" . "w"))) |
(setq imenu-syntax-alist '(("_$" . "w"))) |
1792 |
@end example |
@end example |
1793 |
|
|
1794 |
The @code{imenu-generic-expression} patterns can then use @samp{\\sw+} |
The @code{imenu-generic-expression} regular expressions can then use |
1795 |
instead of @samp{\\(\\sw\\|\\s_\\)+}. Note that this technique may be |
@samp{\\sw+} instead of @samp{\\(\\sw\\|\\s_\\)+}. Note that this |
1796 |
inconvenient when the mode needs to limit the initial character |
technique may be inconvenient when the mode needs to limit the initial |
1797 |
of a name to a smaller set of characters than are allowed in the rest |
character of a name to a smaller set of characters than are allowed in |
1798 |
of a name. |
the rest of a name. |
1799 |
|
|
1800 |
Setting this variable makes it buffer-local in the current buffer. |
Setting this variable makes it buffer-local in the current buffer. |
1801 |
@end defvar |
@end defvar |
1828 |
variable @code{imenu-create-index-function}: |
variable @code{imenu-create-index-function}: |
1829 |
|
|
1830 |
@defvar imenu-create-index-function |
@defvar imenu-create-index-function |
1831 |
This variable specifies the function to use for creating a buffer index. |
This variable specifies the function to use for creating a buffer |
1832 |
The function should take no arguments, and return an index for the |
index. The function should take no arguments, and return an index |
1833 |
current buffer. It is called within @code{save-excursion}, so where it |
alist for the current buffer. It is called within |
1834 |
leaves point makes no difference. |
@code{save-excursion}, so where it leaves point makes no difference. |
|
|
|
|
The default value is a function that uses |
|
|
@code{imenu-generic-expression} to produce the index alist. If you |
|
|
specify a different function, then @code{imenu-generic-expression} is |
|
|
not used. |
|
1835 |
|
|
1836 |
Setting this variable makes it buffer-local in the current buffer. |
The index alist can have three types of elements. Simple elements |
1837 |
@end defvar |
look like this: |
1838 |
|
|
1839 |
|
@example |
1840 |
|
(@var{index-name} . @var{index-position}) |
1841 |
|
@end example |
1842 |
|
|
1843 |
|
Selecting a simple element has the effect of moving to position |
1844 |
|
@var{index-position} in the buffer. Special elements look like this: |
1845 |
|
|
1846 |
|
@example |
1847 |
|
(@var{index-name} @var{index-position} @var{function} @var{arguments}@dots{}) |
1848 |
|
@end example |
1849 |
|
|
1850 |
@defvar imenu-index-alist |
Selecting a special element performs: |
|
This variable holds the index alist for the current buffer. |
|
|
Setting it makes it buffer-local in the current buffer. |
|
|
|
|
|
Simple elements in the alist look like @code{(@var{index-name} |
|
|
. @var{index-position})}. Selecting a simple element has the effect of |
|
|
moving to position @var{index-position} in the buffer. |
|
|
|
|
|
Special elements look like @code{(@var{index-name} @var{position} |
|
|
@var{function} @var{arguments}@dots{})}. Selecting a special element |
|
|
performs |
|
1851 |
|
|
1852 |
@example |
@example |
1853 |
(funcall @var{function} @var{index-name} @var{position} @var{arguments}@dots{}) |
(funcall @var{function} |
1854 |
|
@var{index-name} @var{index-position} @var{arguments}@dots{}) |
1855 |
@end example |
@end example |
1856 |
|
|
1857 |
A nested sub-alist element looks like @code{(@var{index-name} |
A nested sub-alist element looks like this: |
1858 |
@var{sub-alist})}. |
|
1859 |
|
@example |
1860 |
|
(@var{index-name} @var{sub-alist}) |
1861 |
|
@end example |
1862 |
|
|
1863 |
|
It creates a submenu specified by @var{sub-alist}. |
1864 |
|
|
1865 |
|
The default value of @code{imenu-create-index-function} is a function |
1866 |
|
that uses @code{imenu-prev-index-position-function} and |
1867 |
|
@code{imenu-extract-index-name-function} to produce the index alist. |
1868 |
|
However, if either of these two variables is @code{nil}, the default |
1869 |
|
function uses @code{imenu-generic-expression} instead. |
1870 |
|
|
1871 |
|
Setting this variable makes it buffer-local in the current buffer. |
1872 |
@end defvar |
@end defvar |
1873 |
|
|
1874 |
@node Font Lock Mode |
@node Font Lock Mode |