emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Changing TODO states sometimes modifies the scheduling of the next heading
@ 2011-04-03  6:46 Tom
  2011-04-03  8:35 ` Tom
  0 siblings, 1 reply; 10+ messages in thread
From: Tom @ 2011-04-03  6:46 UTC (permalink / raw)
  To: emacs-orgmode

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.

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

end of thread, other threads:[~2011-07-22  7:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-03  6:46 [BUG] Changing TODO states sometimes modifies the scheduling of the next heading Tom
2011-04-03  8:35 ` Tom
2011-04-03 13:37   ` Matt Lundin
2011-04-03 14:09     ` [BUG] Changing TODO states sometimes modifies the schedulingof " Tom
2011-04-03 16:42       ` Matt Lundin
2011-04-03 17:49         ` Tom
2011-04-04 20:25           ` Tom
2011-07-20  8:28             ` Nicolas Goaziou
2011-07-21 19:25               ` Tom
2011-07-22  7:31                 ` Bastien

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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).