bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13438: /srv/bzr/emacs/emacs-24 r111196: * imenu.el (imenu-default-cr


From: Fabián Ezequiel Gallina
Subject: bug#13438: /srv/bzr/emacs/emacs-24 r111196: * imenu.el (imenu-default-create-index-function): Remove useless
Date: Fri, 25 Jan 2013 10:55:57 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130109 Thunderbird/17.0.2

On 01/25/2013 05:34 AM, Glenn Morris wrote:

      
Why is this issue (apparently) only seen in Python mode
Answering my own question, it happens in any mode that sets
imenu-prev-index-position-function and
imenu-extract-index-name-function, but there are very few of those.

Eg prolog mode. With buffer contents:

------
fac(0,1).
fac(N,F) :- N > 0, M is N - 1,
       fac(M,Fm), F is N * Fm.
------

and point at point-min, switching to prolog-mode causes the same issue.

How about taking the more cautious approach with:

(when (and (= pos (point))
           (not (bobp)))
   (error "Infinite loop... ))

(IIUC, this was actually the suggestion in
http://lists.gnu.org/archive/html/emacs-devel/2013-01/msg00510.html ?)
I ran into the same thing, and checking bobp is not enough, try adding a newline at the beginning of file to the recipe and call imenu with point at beginning of defun and you'll see the infinite error check will trigger.

I proposed the following patch that works:

=== modified file 'lisp/imenu.el'
--- lisp/imenu.el       2013-01-01 09:11:05 +0000
+++ lisp/imenu.el       2013-01-22 18:24:45 +0000
@@ -683,7 +683,14 @@
           (goto-char (point-max))
           ;; Search for the function
           (while (funcall imenu-prev-index-position-function)
-             (when (= pos (point))
+             (when (and (= pos (point))
+                        (= pos
+                           (save-excursion
+                             ;; The infinite loop is true if there's
+                             ;; another index position but point keeps
+                             ;; itself in the same place. bug#13438
+                             (if (funcall imenu-prev-index-position-
function)
+                                 (point) 0))))

But finally after some mails with Stefan we decided the best thing will be to remove this check altogether.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]