|
| From: | Mike McLean |
| Subject: | [O] Org Clock Table / Subtree Export subtle bug |
| Date: | Fri, 27 Apr 2012 14:35:53 -0400 |
Hello
I have found a bug with clock tables and even have localized the exact point in org-clock.el where it occurs. I don’t know enough of the Org Mode code base to figure out the best solution and submit a patch.
The general symptom is that if:
org-update-all-dblocks added to org-export-first-hook with the goal of ensuring that dynamic blocks are current before every export; ANDC-c C-e 1 b (buffer/subtree export)
The Mark terminating the end of the region to be exported is carried into the org-clocktable-write-default formatting function and the call of (backward-delete-char 1) on line 2352 oforg-clock.el deletes a region (between the Mark of the initial call and point, which is immediately before the #+END: construct of the clock table). Deletion of the #+END: construct malforms the clock table and ultimately the export fails leaving the Org file is a corrupt state.
Launch Emacs clean:
/Applications/Emacs.app/Contents/MacOS/Emacs -Q
Add the update to org-export-first-hook by evaluating the follwing line in *scratch*
(add-hook 'org-export-first-hook 'org-update-all-dblocks)
Report versions (note this report is done from the non-Git-HEAD Org 7.8.09 included with Emacs, but the problem also exists in HEAD):
M-x emacs-version GNU Emacs 24.1.50.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-04-27 on bob.porkrind.org M-x org-version Org-mode version 7.8.09
Open the following test file
* Project A Clock summary at [2012-04-27 Fri 14:30] | Headline | Time | | |--------------+--------+------| | *Total time* | *2:59* | | |--------------+--------+------| | Project A | 2:59 | | | Task A1 | | 2:00 | | Task A2 | | 0:59 | ** Task A1 CLOCK: [2012-04-26 Fri 11:58]--[2012-04-26 Thu 13:58] => 2:00 ** Task A2 CLOCK: [2012-04-27 Fri 09:00]--[2012-04-27 Fri 09:59] => 0:59 * Project B ** Task B1
Export the entire buffer as a baseline test
C-c C-e b
The result is as expected:
Clock Summary line changes to reflect the current time (showing that org-update-all-dblocks) ran correctlyPut the cursor on the Project A line and attempt to export just the Project A subtree
C-c C-e 1 b
The expected result is a (smaller than before) valid HTML export.
The actual result is:
org-map-dblocks: Dynamic block not terminated in the echo area#+END: and Project B are deleted from the file resulting in the following invalid Org file#+STARTUP: showeverything * Project A #+BEGIN: clocktable :maxlevel 2 :scope subtree Clock summary at [2012-04-27 Fri 14:15] | Headline | Time | | |--------------+--------+------| | *Total time* | *2:59* | | |--------------+--------+------| | Project A | 2:59 | | | Task A1 | | 2:00 | | Task A2 | | 0:59 | * Project B
Tracing through org-clock.el I found the culprit on line 2352, if I add a (debug) statement immediately before that line I see the following:
C-c C-c on the #+BEGIN: line) the debugger enters and there is no region highlightedtest.org from the end of the table (Point) to the end of the entire Project Asubtree (Mark, from the selection made by the export subtree code)
test.org
Description: Binary data
| [Prev in Thread] | Current Thread | [Next in Thread] |