Commit d8b8451f authored by Sam Steingold's avatar Sam Steingold
Browse files

(imenu-default-create-index-function): Detect infinite

loops caused by imenu-prev-index-position-function.
parent 30afcdff
2010-01-11 Sam Steingold <sds@gnu.org>
* imenu.el (imenu-default-create-index-function): Detect infinite
loops caused by imenu-prev-index-position-function.
2010-01-11 Juanma Barranquero <lekktu@gmail.com> 2010-01-11 Juanma Barranquero <lekktu@gmail.com>
* htmlfontify.el (htmlfontify-load-rgb-file) * htmlfontify.el (htmlfontify-load-rgb-file)
......
...@@ -596,7 +596,7 @@ See `imenu--index-alist' for the format of the index alist." ...@@ -596,7 +596,7 @@ See `imenu--index-alist' for the format of the index alist."
;;; Find all markers in alist and makes ;;; Find all markers in alist and makes
;;; them point nowhere. ;;; them point nowhere.
;;; The top-level call uses nil as the argument; ;;; 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) (defvar imenu--cleanup-seen)
(defun imenu--cleanup (&optional alist) (defun imenu--cleanup (&optional alist)
...@@ -684,12 +684,15 @@ The alternate method, which is the one most often used, is to call ...@@ -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. ;; in these major modes. But save that change for later.
(cond ((and imenu-prev-index-position-function (cond ((and imenu-prev-index-position-function
imenu-extract-index-name-function) imenu-extract-index-name-function)
(let ((index-alist '()) (let ((index-alist '()) (pos (point))
prev-pos name) prev-pos name)
(goto-char (point-max)) (goto-char (point-max))
(imenu-progress-message prev-pos 0 t) (imenu-progress-message prev-pos 0 t)
;; Search for the function ;; Search for the function
(while (funcall imenu-prev-index-position-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) (imenu-progress-message prev-pos nil t)
(save-excursion (save-excursion
(setq name (funcall imenu-extract-index-name-function))) (setq name (funcall imenu-extract-index-name-function)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment