Function: imenu-default-create-index-function
imenu-default-create-index-function is a byte-compiled function
defined in imenu.el.gz.
Signature
(imenu-default-create-index-function)
Documentation
Default function to create an index alist of the current buffer.
The most general method is to move point to end of buffer, then repeatedly call
imenu-prev-index-position-function and imenu-extract-index-name-function.
All the results returned by the latter are gathered into an index alist.
This method is used if those two variables are non-nil.
The alternate method, which is the one most often used, is to call
imenu--generic-function with imenu-generic-expression as argument.
Source Code
;; Defined in /usr/src/emacs/lisp/imenu.el.gz
(defun imenu-default-create-index-function ()
"Default function to create an index alist of the current buffer.
The most general method is to move point to end of buffer, then repeatedly call
`imenu-prev-index-position-function' and `imenu-extract-index-name-function'.
All the results returned by the latter are gathered into an index alist.
This method is used if those two variables are non-nil.
The alternate method, which is the one most often used, is to call
`imenu--generic-function' with `imenu-generic-expression' as argument."
;; These should really be done by setting imenu-create-index-function
;; in these major modes. But save that change for later.
(cond ((and imenu-prev-index-position-function
imenu-extract-index-name-function)
(let ((index-alist '()) (pos (point-max))
(start (float-time))
name)
(goto-char pos)
;; Search for the function
(while (and (funcall imenu-prev-index-position-function)
;; Don't use an excessive amount of time.
(< (- (float-time) start) imenu-max-index-time))
(unless (< (point) pos)
(error "Infinite loop at %s:%d: imenu-prev-index-position-function does not move point" (buffer-name) pos))
(setq pos (point))
(save-excursion
(setq name (funcall imenu-extract-index-name-function)))
(and (stringp name)
;; [ydi] Updated for imenu-use-markers.
(push (cons name
(if imenu-use-markers
(copy-marker (point) t)
(point)))
index-alist)))
index-alist))
;; Use generic expression if possible.
((and imenu-generic-expression)
(imenu--generic-function imenu-generic-expression))
(t
(imenu-unavailable-error "This buffer cannot use `imenu-default-create-index-function'"))))