Fix bulk agenda processing with parents and children in the loop
commitbabd053bd68a4c43e44eeb26e30485764c39a2cb
authorCarsten Dominik <carsten.dominik@gmail.com>
Tue, 4 Aug 2009 20:34:53 +0000 (4 22:34 +0200)
committerCarsten Dominik <carsten.dominik@gmail.com>
Tue, 4 Aug 2009 20:46:08 +0000 (4 22:46 +0200)
tree35effc2662dde92c13b4fc4db80c5db197a2d1ec
parent064c7976cf8ae630b67c754627143dd14385fa8d
Fix bulk agenda processing with parents and children in the loop

Bernt Hansen writes:

> Every so often I run into a situation where bulk refiling
> doesn't work anymore.
>
> I currently have 15 items in my refile.org file that I want
> to refile to other locations.  I marked a few of them and
> bulk refiled them just fine.  Then I marked a few more and B
> r fails with "Cannot find entry for marker #<marker at
> 297156 in norang.org>"
>
> I think this happens when I mark multiple tasks in the same
> subtree (i.e. the parent and a sibling) and refile both to
> the same location.  After that it gets confused.
>
> If I have a task like this in refile.org
>
> #+FILETAGS: REFILE
> * Test
> ** Test 2
>
> and run a tags match on REFILE I see both tasks.  Mark both
> with m in the agenda and B r to some other location.  It
> refiles the first (and this moves the sibling too) and then
> it's broken after that.
>
> I get the following backtrace
>
> Debugger entered--Lisp error: (error "Cannot find entry for
> marker #<marker at 297156 in norang.org>")

Indeed the happens because, when a parent gets refiled or
achieved, any entries corresponding to its children are
removed from the agenda.

We address this issue by

- sorting the markers, to make sure parents will be handled
  before children

- No longer throwing an error when a bulk action entry no
  longer is present in the agenda - most likely it was taken
  care of together with its parent.
lisp/ChangeLog
lisp/org-agenda.el