From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina Newsgroups: gmane.emacs.bugs 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 Message-ID: <51028EED.30406@anue.biz> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------030900070104000800040207" X-Trace: ger.gmane.org 1359122112 23289 80.91.229.3 (25 Jan 2013 13:55:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Jan 2013 13:55:12 +0000 (UTC) Cc: 13438@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 25 14:55:31 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tyjkg-0000op-O2 for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 14:55:30 +0100 Original-Received: from localhost ([::1]:38870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyjkP-000543-9D for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 08:55:13 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:58628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyjkE-0004zZ-SV for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 08:55:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tyjk6-0007C7-KZ for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 08:55:02 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyjk6-0007C2-HR for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 08:54:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TyjkE-0000Hs-3y for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 08:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Jan 2013 13:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13438 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13438-submit@debbugs.gnu.org id=B13438.13591220911080 (code B ref 13438); Fri, 25 Jan 2013 13:55:02 +0000 Original-Received: (at 13438) by debbugs.gnu.org; 25 Jan 2013 13:54:51 +0000 Original-Received: from localhost ([127.0.0.1]:48857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tyjk2-0000HN-Bk for submit@debbugs.gnu.org; Fri, 25 Jan 2013 08:54:50 -0500 Original-Received: from mail-gh0-f173.google.com ([209.85.160.173]:52076) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tyjjz-0000H6-VA for 13438@debbugs.gnu.org; Fri, 25 Jan 2013 08:54:49 -0500 Original-Received: by mail-gh0-f173.google.com with SMTP id g2so44347ghb.4 for <13438@debbugs.gnu.org>; Fri, 25 Jan 2013 05:54:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-gm-message-state; bh=3U7Kyt0xprcIghgPXEtFeAnWpRyPuhvlzrWPVtaI89Y=; b=Hx8u8hSbmLpL3t2Aln4xslro3DWi9+rFVEgP3etMDux3nooM0XzjUhQuIElD1+SZ3m Q++RXW5niYJinoaocgfLwxTlyZh0sCvffnlR02mhPY8CuVUvoEtbYdVAo4GzQliyfSh4 cNlfUl6jvvV4gk5ZiAYBRPoM2/f7RkFtZ6JqoajkpfoSsI8R8i/wDC08PJ9+L4pC99lP 71lASE4uI64EusJ/fn4WGgMHu65g6GC2SE33MNMsNXagGOQqpB3iaA3d1gjUKX5zbVgn BCtCol+xbfSVyXDNe1L0NRoqhXUIztvzjZHRjn12X+7yGDLR5SzMYJAs3w4+jDzcOuT0 jHOA== X-Received: by 10.236.121.99 with SMTP id q63mr5956174yhh.105.1359122073752; Fri, 25 Jan 2013 05:54:33 -0800 (PST) Original-Received: from [192.168.1.136] (OL144-145.fibertel.com.ar. [24.232.145.144]) by mx.google.com with ESMTPS id r17sm776322ani.8.2013.01.25.05.54.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Jan 2013 05:54:32 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130109 Thunderbird/17.0.2 In-Reply-To: X-Gm-Message-State: ALoCoQn9rZEVNBaaw27dp9X1ZlrC+2qZVGkrXPlAPneVJcPsefwKpV8M4rcvtB0xUdhqVEwTRTfA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70293 Archived-At: This is a multi-part message in MIME format. --------------030900070104000800040207 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------030900070104000800040207 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
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.

--------------030900070104000800040207--