# HG changeset patch # User Sam Steingold # Date 1263243203 18000 # Node ID 9479a9da9b8c5bac02c6c851a345c409da31f659 # Parent 8802f28da1a86dfa079a85d82dbda1c564c99918 (imenu-default-create-index-function): Detect infinite loops caused by imenu-prev-index-position-function. diff -r 8802f28da1a8 -r 9479a9da9b8c lisp/ChangeLog --- a/lisp/ChangeLog Mon Jan 11 18:26:28 2010 +0100 +++ b/lisp/ChangeLog Mon Jan 11 15:53:23 2010 -0500 @@ -1,3 +1,8 @@ +2010-01-11 Sam Steingold + + * imenu.el (imenu-default-create-index-function): Detect infinite + loops caused by imenu-prev-index-position-function. + 2010-01-11 Juanma Barranquero * htmlfontify.el (htmlfontify-load-rgb-file) diff -r 8802f28da1a8 -r 9479a9da9b8c lisp/imenu.el --- a/lisp/imenu.el Mon Jan 11 18:26:28 2010 +0100 +++ b/lisp/imenu.el Mon Jan 11 15:53:23 2010 -0500 @@ -596,7 +596,7 @@ ;;; 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 @@ ;; 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)))