aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeiffer2005-05-21 02:44:29 +0000
committerDaniel Pfeiffer2005-05-21 02:44:29 +0000
commitfb50d1e9db15111b5952a8709e4a5774ae34624b (patch)
treedb5a7bc1184655f2fd8a13057f95898d396e4864
parent813731b3dc55a2e92b29a2ef656353cbf20faa6e (diff)
downloademacs-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.el69
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
195If non-nil this pattern is passed to `imenu--generic-function' 195If non-nil this pattern is passed to `imenu--generic-function' to
196to create a buffer index. 196create a buffer index. Look there for the documentation of this
197 197pattern's structure.
198The value should be an alist with elements that look like this:
199 (MENU-TITLE REGEXP INDEX)
200or like this:
201 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
202with zero or more ARGUMENTS. The former format creates a simple element in
203the index alist when it matches; the latter creates a special element
204of the form (NAME POSITION-MARKER FUNCTION ARGUMENTS...)
205with FUNCTION and ARGUMENTS copied from `imenu-generic-expression'.
206
207MENU-TITLE is a string used as the title for the submenu or nil if the
208entries are not nested.
209
210REGEXP is a regexp that should match a construct in the buffer that is
211to be displayed in the menu; i.e., function or variable definitions,
212etc. It contains a substring which is the name to appear in the
213menu. See the info section on Regexps for more information.
214
215INDEX points to the substring in REGEXP that contains the name (of the
216function, variable or type) that is to appear in the menu.
217
218The variable `imenu-case-fold-search' determines whether or not the
219regexp matches are case sensitive, and `imenu-syntax-alist' can be
220used to alter the syntax table for the search.
221 198
222For example, see the value of `fortran-imenu-generic-expression' used by 199For 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
752PATTERNS is an alist with elements that look like this: 729PATTERNS is an alist with elements that look like this:
753 (MENU-TITLE REGEXP INDEX). 730 (MENU-TITLE REGEXP INDEX)
754or like this: 731or like this:
755 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...) 732 (MENU-TITLE REGEXP INDEX FUNCTION ARGUMENTS...)
756with zero or more ARGUMENTS. 733with zero or more ARGUMENTS. The former format creates a simple
757 734element in the index alist when it matches; the latter creates a
758MENU-TITLE is a string used as the title for the submenu or nil if the 735special element of the form (NAME POSITION-MARKER FUNCTION
759entries are not nested. 736ARGUMENTS...) with FUNCTION and ARGUMENTS copied from
737`imenu-generic-expression'.
738
739MENU-TITLE is a string used as the title for the submenu or nil
740if the entries are not nested.
741
742REGEXP is a regexp that should match a construct in the buffer
743that is to be displayed in the menu; i.e., function or variable
744definitions, etc. It contains a substring which is the name to
745appear in the menu. See the info section on Regexps for more
746information. REGEXP may also be a function, called without
747arguments. It is expected to search backwards. It shall return
748true and set `match-data' iff it finds another element.
749
750INDEX points to the substring in REGEXP that contains the
751name (of the function, variable or type) that is to appear in the
752menu.
760 753
761REGEXP is a regexp that should match a construct in the buffer that is 754The variable `imenu-case-fold-search' determines whether or not the
762to be displayed in the menu; i.e., function or variable definitions, 755regexp matches are case sensitive, and `imenu-syntax-alist' can be
763etc. It contains a substring which is the name to appear in the 756used to alter the syntax table for the search.
764menu. See the info section on Regexps for more information.
765
766INDEX points to the substring in REGEXP that contains the name (of the
767function, variable or type) that is to appear in the menu.
768 757
769See `lisp-imenu-generic-expression' for an example of PATTERNS. 758See `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))))