From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Lundin Subject: Re: [BUG] Infinite loop in org-agenda-show-new-time Date: Mon, 05 Aug 2013 15:14:09 -0500 Message-ID: <87fvun6gku.fsf@fastmail.fm> References: <87zjswb0vq.fsf@fastmail.fm> <87siyojc2c.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6RAa-0007iI-1M for emacs-orgmode@gnu.org; Mon, 05 Aug 2013 16:14:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6RAV-0001BE-Ep for emacs-orgmode@gnu.org; Mon, 05 Aug 2013 16:14:19 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:55429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6RAV-00019m-6g for emacs-orgmode@gnu.org; Mon, 05 Aug 2013 16:14:15 -0400 Received: from archeee (unknown [98.228.97.243]) by mail.messagingengine.com (Postfix) with ESMTPA id 08E20680123 for ; Mon, 5 Aug 2013 16:14:09 -0400 (EDT) In-Reply-To: <87siyojc2c.fsf@gmail.com> (Nick Dokos's message of "Mon, 05 Aug 2013 13:13:15 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode Nick Dokos writes: > Matt Lundin writes: > > My one feeble attempt to reproduce this failed. Looking at the code Here are the steps to reproduce the problem: 1. Create file test.org with the following content: --8<---------------cut here---------------start------------->8--- * TODO A :home: SCHEDULED: <2013-08-05 Mon> * TODO B :work: SCHEDULED: <2013-08-05 Mon> * TODO C :play: SCHEDULED: <2013-08-05 Mon> * TODO D :home: SCHEDULED: <2013-08-05 Mon> * TODO E :work: SCHEDULED: <2013-08-05 Mon> * TODO F :play: SCHEDULED: <2013-08-05 Mon> * TODO G :home: SCHEDULED: <2013-08-05 Mon> * TODO H :work: SCHEDULED: <2013-08-05 Mon> * TODO I :play: SCHEDULED: <2013-08-05 Mon> --8<---------------cut here---------------end--------------->8--- 2. /usr/bin/emacs -Q 3. find file test.org 4. M-x org-agenda -> hit "<" to restrict to buffer and then "a" for diary 5. / home 6. Attempt to reschedule one of the visible items. > (while (not (bobp)) > (when (equal marker (org-get-at-bol 'org-marker)) > (org-move-to-column (- (window-width) (length stamp)) t) > (org-agenda-fix-tags-filter-overlays-at (point)) > ... > (beginning-of-line 1)) > (beginning-of-line 0))))) > > let's assume we are not at the beginning of the buffer, so we don't exit > the loop that way. If the when succeeds, we do a couple of things and > then do (beginning-of-line 1). This just takes us to the beginning of > the current line. But after the when is done, we do (beginning-of-line > 0) which should take us to the previous line. So we should be making > steady progress towards the beginning of the buffer and the loop should > terminate. > > Since you can reproduce it (and you've already done the hard work of > figuring out where the inf loop is), maybe you can edebug the function > and step through it a couple of times to see what's happening. Thanks for the pointers. Running edebug with the file above reveals that org-move-to-column is not working with the invisible sections of the buffer. With the sample file above, I filter the agenda to display only items tagged :home:. --8<---------------cut here---------------start------------->8--- Day-agenda (W32): Monday 5 August 2013 W32 test: Scheduled: TODO A :home: test: Scheduled: TODO D :home: test: Scheduled: TODO G :home: --8<---------------cut here---------------end--------------->8--- When stepping through org-agenda-do-date-later, edebug reveals that the point goes to the end of the buffer, as expected and then works its way backward. When it arrives at the beginning of the line with task "G", it finds and match and executes the following functions: --8<---------------cut here---------------start------------->8--- (org-move-to-column (- (window-width) (length stamp)) t) (org-agenda-fix-tags-filter-overlays-at (point)) --8<---------------cut here---------------end--------------->8--- The problem is that org-move-to-column shifts the point several lines forward. In fact, if I make all contents of the agenda buffer visible after edebug executes org-move-to-column, I find that the point is now all the way at the end of line "I," which, of course, will trigger an endless loop. In other words, org-move-to-column moves the point to the end of the entire invisible section. --8<---------------cut here---------------start------------->8--- Day-agenda (W32): Monday 5 August 2013 W32 test: Scheduled: TODO A :home: test: Scheduled: TODO B :work: test: Scheduled: TODO C :play: test: Scheduled: TODO D :home: test: Scheduled: TODO E :work: test: Scheduled: TODO F :play: test: Scheduled: TODO G :home: test: Scheduled: TODO H :work: test: Scheduled: TODO I :play: --8<---------------cut here---------------end--------------->8--- ^ | here This bug was introduced with the following commit: --8<---------------cut here---------------start------------->8--- commit fafb5f3429c41cba1eddb9fc78d9f9e0980acbe2 Author: Bastien Guerry Date: Mon Feb 11 14:56:38 2013 +0100 org-agenda.el: Fix bug when displaying a temporary overlay * org-agenda.el (org-agenda-schedule, org-agenda-deadline): Cosmetic changes. (org-agenda-show-new-time): Fix bug when displaying a temporary overlay with the scheduled/deadline information. Thanks to Thomas Morgan for reporting this bug and testing the patch. --8<---------------cut here---------------end--------------->8--- This commit removed the local binding of buffer-invisibility-spec to nil in org-agenda-show-new-time. Here is the bug this change was meant to fix: http://permalink.gmane.org/gmane.emacs.orgmode/52667 Might we revert this change? The original bug was cosmetic. This bug, however, interferes in an essential way with the functioning of agenda buffers. Best, Matt