summaryrefslogtreecommitdiff
path: root/lisp/imenu.el
diff options
context:
space:
mode:
authorSam Steingold <sds@gnu.org>2010-01-11 15:53:23 -0500
committerSam Steingold <sds@gnu.org>2010-01-11 15:53:23 -0500
commitd8b8451f8ea52d751035449278ec36c3e598f9cf (patch)
tree9cb59bcd796de4c54d625aa0e4b4fa903918ca5c /lisp/imenu.el
parent30afcdfffd95e24183956a666749cf6c03150d14 (diff)
downloademacs-d8b8451f8ea52d751035449278ec36c3e598f9cf.tar.gz
(imenu-default-create-index-function): Detect infinite
loops caused by imenu-prev-index-position-function.
Diffstat (limited to 'lisp/imenu.el')
-rw-r--r--lisp/imenu.el7
1 files changed, 5 insertions, 2 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 77035c602d8..47c99ad1997 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -596,7 +596,7 @@ See `imenu--index-alist' for the format of the index alist."
;;; Find all markers in alist and makes
;;; them point nowhere.
;;; The top-level call uses nil as the argument;
-;;; non-nil arguments are in recursivecalls.
+;;; non-nil arguments are in recursive calls.
(defvar imenu--cleanup-seen)
(defun imenu--cleanup (&optional alist)
@@ -684,12 +684,15 @@ The alternate method, which is the one most often used, is to call
;; 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 '())
+ (let ((index-alist '()) (pos (point))
prev-pos name)
(goto-char (point-max))
(imenu-progress-message prev-pos 0 t)
;; Search for the function
(while (funcall imenu-prev-index-position-function)
+ (when (= pos (point))
+ (error "Infinite loop at %s:%d: imenu-prev-index-position-function does not move point" (buffer-name) pos))
+ (setq pos (point))
(imenu-progress-message prev-pos nil t)
(save-excursion
(setq name (funcall imenu-extract-index-name-function)))