unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* imenu issue from Bug #13438
@ 2013-01-21 21:09 Fabian Ezequiel Gallina
  2013-01-22  1:07 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Ezequiel Gallina @ 2013-01-21 21:09 UTC (permalink / raw)
  To: Emacs-Devel devel

Got a quick look at
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13438, in there I think
the problem is related to how `imenu-default-create-index-function'
detects infinite recursion. I this case, because the the point is at
the beginning of the latest available defun, the points doesn't move
and it throws the infinite loop error.

Here's a mindless quick patch that seems to fix the problem. I could
install it myself but I'd like some input first.


=== modified file 'lisp/imenu.el'
--- lisp/imenu.el       2013-01-01 09:11:05 +0000
+++ lisp/imenu.el       2013-01-21 21:03:57 +0000
@@ -683,7 +683,8 @@
           (goto-char (point-max))
           ;; Search for the function
           (while (funcall imenu-prev-index-position-function)
-             (when (= pos (point))
+             (when (and (= pos (point))
+                        (save-excursion (beginning-of-defun)))
                (error "Infinite loop at %s:%d:
imenu-prev-index-position-function does not move point" (buffer-name)
pos))
              (setq pos (point))
             (save-excursion



Regards,
Fabián



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: imenu issue from Bug #13438
  2013-01-21 21:09 imenu issue from Bug #13438 Fabian Ezequiel Gallina
@ 2013-01-22  1:07 ` Stefan Monnier
  2013-01-22 18:37   ` Fabian Ezequiel Gallina
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2013-01-22  1:07 UTC (permalink / raw)
  To: Fabian Ezequiel Gallina; +Cc: Emacs-Devel devel

> Here's a mindless quick patch that seems to fix the problem. I could
> install it myself but I'd like some input first.

Calling beginning-of-defun in such generic code is not an option,
because this function only works properly in those major modes that set
it up appropriately.

I think testing bobp makes more sense (and python's function should make
sure it eventually either returns nil or moves up to bob).


        Stefan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: imenu issue from Bug #13438
  2013-01-22  1:07 ` Stefan Monnier
@ 2013-01-22 18:37   ` Fabian Ezequiel Gallina
  2013-01-22 21:08     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Fabian Ezequiel Gallina @ 2013-01-22 18:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-Devel devel

2013/1/21 Stefan Monnier <monnier@iro.umontreal.ca>:
>> Here's a mindless quick patch that seems to fix the problem. I could
>> install it myself but I'd like some input first.
>
> Calling beginning-of-defun in such generic code is not an option,
> because this function only works properly in those major modes that set
> it up appropriately.
>
> I think testing bobp makes more sense (and python's function should make
> sure it eventually either returns nil or moves up to bob).
>

bobp is not enough, because I could build an
imenu-prev-index-position-function that returns something even when at
bobp and the infloop would take place. I feel the following fix makes
sense, let me know what do you think.


=== 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))))
                (error "Infinite loop at %s:%d:
imenu-prev-index-position-function does not move point" (buffer-name)
pos))
              (setq pos (point))
             (save-excursion



Regards,
Fabián



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: imenu issue from Bug #13438
  2013-01-22 18:37   ` Fabian Ezequiel Gallina
@ 2013-01-22 21:08     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-01-22 21:08 UTC (permalink / raw)
  To: Fabian Ezequiel Gallina; +Cc: Emacs-Devel devel

> bobp is not enough, because I could build an
> imenu-prev-index-position-function that returns something even when at
> bobp and the infloop would take place.

That's OK.  It'd be a bug in that imenu-prev-index-position-function.
Actually, AFAIK bobp would never be needed, it's just the responsibility
of imenu-prev-index-position-function to make sure it eventually
returns nil.


        Stefan



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-22 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-21 21:09 imenu issue from Bug #13438 Fabian Ezequiel Gallina
2013-01-22  1:07 ` Stefan Monnier
2013-01-22 18:37   ` Fabian Ezequiel Gallina
2013-01-22 21:08     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).