From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martyn Jago Subject: Re: [BUG] Unmatched #+end-src Date: Sat, 12 Mar 2011 20:43:12 +0000 Message-ID: <87aah0cbof.fsf@btinternet.com> References: <87ei6cffbw.fsf@btinternet.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=55142 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PyVeh-0001oS-Fw for emacs-orgmode@gnu.org; Sat, 12 Mar 2011 15:43:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PyVee-0001Yn-9C for emacs-orgmode@gnu.org; Sat, 12 Mar 2011 15:43:19 -0500 Received: from smarthost02.mail.zen.net.uk ([212.23.3.141]:40309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PyVee-0001YX-1d for emacs-orgmode@gnu.org; Sat, 12 Mar 2011 15:43:16 -0500 In-Reply-To: (aankhen@gmail.com's message of "Sun, 13 Mar 2011 00:59:07 +0530") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Aankhen Cc: Org-mode ml --=-=-= Content-Type: text/plain Aankhen writes: Thanks for the heads-up Aankhen, I had indeed missed the enclosing infinite loop. I modified your patch slightly since my test still failed, and made further tests. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-endless-loop-in-org-in-item-p-where-end_-block-h.patch Content-Description: Fix-endless-loop-in-org-in-item-p >From b55d846b57fc2ebf3c282cb1fbb27becfdd7d4fd Mon Sep 17 00:00:00 2001 From: Martyn Jago Date: Sat, 12 Mar 2011 20:38:14 +0000 Subject: [PATCH] Fix endless loop in 'org-in-item-p where #+end_ block has no matching beginning block --- lisp/org-list.el | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/org-list.el b/lisp/org-list.el index 4b50910..7d8692b 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -465,8 +465,9 @@ This checks `org-list-ending-method'." (looking-at org-list-end-re)) (throw 'exit nil)) ;; Skip blocks, drawers, inline-tasks, blank lines - ((looking-at "^[ \t]*#\\+end_") - (re-search-backward "^[ \t]*#\\+begin_" nil t)) + ((and (looking-at "^[ \t]*#\\+end_") + (not (re-search-backward "^[ \t]*#\\+begin_" nil t))) + (throw 'exit nil)) ((looking-at "^[ \t]*:END:") (re-search-backward org-drawer-regexp nil t) (beginning-of-line)) -- 1.7.4.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Regards Martyn > Hi, > > On Sat, Mar 12, 2011 at 22:26, Martyn Jago w= rote: >> --8<---------------cut here---------------start------------->8--- >> * Unmatched #+end-src bug >> >> #+end_src >> --8<---------------cut here---------------end--------------->8--- >> >> With the above simple org file, placing the cursor at the end of >> #+end_src and hitting return causes emacs to hang. >> >> The bug can be replicated with the following simple test which also >> causes emacs to hang... >> >> [snip] >> >> It appears to be related to the following in 'org-in-item-p >> (org-list.el)... >> >> --8<---------------cut here---------------start------------->8--- >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((looking-at "^[ \t]*#\= \+end_") >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(re-search-backwa= rd "^[ \t]*#\\+begin_" nil t)) >> --8<---------------cut here---------------end--------------->8--- >> >> I've tried to pin down the bug but its left me perplexed, so I'm going >> to defer to more experienced org lispers! > > The =3Dcond=3D is part of a =3Dwhile=3D loop; it just keeps looping, ente= ring > that branch and doing nothing (rather than moving point and picking up > again from there). Going by the other branches, I think the correct > thing to do is just exit the loop: > > diff --git a/lisp/org-list.el b/lisp/org-list.el > --- a/lisp/org-list.el > +++ b/lisp/org-list.el > @@ -450,17 +450,19 @@ This checks `org-list-ending-method'." > ;; At upper bound of search or looking at the end of a > ;; previous list: search is over. > ((<=3D (point) lim-up) (throw 'exit nil)) > ((and (not (eq org-list-ending-method 'indent)) > (looking-at org-list-end-re)) > (throw 'exit nil)) > ;; Skip blocks, drawers, inline-tasks, blank lines > ((looking-at "^[ \t]*#\\+end_") > - (re-search-backward "^[ \t]*#\\+begin_" nil t)) > + (condition-case nil > + (re-search-backward "^[ \t]*#\\+begin_" nil) > + (search-failed (throw 'exit nil)))) > ((looking-at "^[ \t]*:END:") > (re-search-backward org-drawer-regexp nil t) > (beginning-of-line)) > ((and inlinetask-re (looking-at inlinetask-re)) > (org-inlinetask-goto-beginning) > (forward-line -1)) > ((looking-at "^[ \t]*$") (forward-line -1)) > ;; Text at column 0 cannot belong to a list: stop. > > Hope this helps, > Aankhen --=-=-=--