Mercurial > emacs
comparison lisp/imenu.el @ 106796:9479a9da9b8c
(imenu-default-create-index-function): Detect infinite
loops caused by imenu-prev-index-position-function.
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Mon, 11 Jan 2010 15:53:23 -0500 |
parents | c220a29e75fd |
children | 1d1d5d9bd884 |
comparison
equal
deleted
inserted
replaced
106795:8802f28da1a8 | 106796:9479a9da9b8c |
---|---|
594 (cons imenu--rescan-item imenu--index-alist)) | 594 (cons imenu--rescan-item imenu--index-alist)) |
595 | 595 |
596 ;;; Find all markers in alist and makes | 596 ;;; Find all markers in alist and makes |
597 ;;; them point nowhere. | 597 ;;; them point nowhere. |
598 ;;; The top-level call uses nil as the argument; | 598 ;;; The top-level call uses nil as the argument; |
599 ;;; non-nil arguments are in recursivecalls. | 599 ;;; non-nil arguments are in recursive calls. |
600 (defvar imenu--cleanup-seen) | 600 (defvar imenu--cleanup-seen) |
601 | 601 |
602 (defun imenu--cleanup (&optional alist) | 602 (defun imenu--cleanup (&optional alist) |
603 ;; If alist is provided use that list. | 603 ;; If alist is provided use that list. |
604 ;; If not, empty the table of lists already seen | 604 ;; If not, empty the table of lists already seen |
682 `imenu--generic-function' with `imenu-generic-expression' as argument." | 682 `imenu--generic-function' with `imenu-generic-expression' as argument." |
683 ;; These should really be done by setting imenu-create-index-function | 683 ;; These should really be done by setting imenu-create-index-function |
684 ;; in these major modes. But save that change for later. | 684 ;; in these major modes. But save that change for later. |
685 (cond ((and imenu-prev-index-position-function | 685 (cond ((and imenu-prev-index-position-function |
686 imenu-extract-index-name-function) | 686 imenu-extract-index-name-function) |
687 (let ((index-alist '()) | 687 (let ((index-alist '()) (pos (point)) |
688 prev-pos name) | 688 prev-pos name) |
689 (goto-char (point-max)) | 689 (goto-char (point-max)) |
690 (imenu-progress-message prev-pos 0 t) | 690 (imenu-progress-message prev-pos 0 t) |
691 ;; Search for the function | 691 ;; Search for the function |
692 (while (funcall imenu-prev-index-position-function) | 692 (while (funcall imenu-prev-index-position-function) |
693 (when (= pos (point)) | |
694 (error "Infinite loop at %s:%d: imenu-prev-index-position-function does not move point" (buffer-name) pos)) | |
695 (setq pos (point)) | |
693 (imenu-progress-message prev-pos nil t) | 696 (imenu-progress-message prev-pos nil t) |
694 (save-excursion | 697 (save-excursion |
695 (setq name (funcall imenu-extract-index-name-function))) | 698 (setq name (funcall imenu-extract-index-name-function))) |
696 (and (stringp name) | 699 (and (stringp name) |
697 ;; [ydi] updated for imenu-use-markers | 700 ;; [ydi] updated for imenu-use-markers |