From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Subject: [BUG] Changing TODO states sometimes modifies the scheduling of the next heading Date: Sun, 3 Apr 2011 06:46:11 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=48012 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q6H50-00058Q-TP for emacs-orgmode@gnu.org; Sun, 03 Apr 2011 02:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q6H4v-00020w-Co for emacs-orgmode@gnu.org; Sun, 03 Apr 2011 02:46:34 -0400 Received: from lo.gmane.org ([80.91.229.12]:59438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q6H4v-00020V-0X for emacs-orgmode@gnu.org; Sun, 03 Apr 2011 02:46:29 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q6H4o-00044O-Fh for emacs-orgmode@gnu.org; Sun, 03 Apr 2011 08:46:22 +0200 Received: from 84-236-127-100.pool.digikabel.hu ([84.236.127.100]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2011 08:46:22 +0200 Received: from adatgyujto by 84-236-127-100.pool.digikabel.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 03 Apr 2011 08:46:22 +0200 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: emacs-orgmode@gnu.org I have a heading where the scheduling changed misteriuosly. It is set to repeat weekly and I found it jumped to the next week without me touching it at all. I set up a background watcher and after a week it detected when the unwanted change happens. I could not yet create a simple org file to reproduce the problem, but I found the problematic part in the code. It happens when I change the TODO state of a heading with repeating scheduling. When org modifies the scheduling of the heading according to the repeat period it also modifies the scheduling of the heading under it. Here's the buggy part of the code: (defun org-auto-repeat-maybe (done-word) ... (while (re-search-forward re (save-excursion (outline-next-heading) (point)) t) http://repo.or.cz/w/org-mode.git/blob/HEAD:/lisp/org.el#l11546 The problem is the bound for the search is determined within the while loop. The problem occurs when the scheduling of the heading is changed and cursor is put on the beginning of the next line after that. If that next line happens to be the next heading line then the (outline-next-heading) call in the re-search-forward skips over the next heading, setting the bound of the search to the end of it, so the search includes the contents of the next heading too, so its scheduling is also modified behind the user's back. The solution is simple: determine the bound of the search (the end of the heading) before the while loop and use that value in re-search-forward, instead of computing it within the loop.