Fix J in agenda when clock out hook clocks in again

* org-clock.el (org-clock-out): Do not delete the current clocking task
when org-clock-out-hook clocks in another task

My clock out hook keeps the clock running by automatically clocking in
a new task (the parent task, or the default task).  This sets a new
clocking task which was then clobbered at the end of org-clock-out
so that J in the agenda would return

    "No running clock, use `C-c C-x C-j' to jump to the most recent one"

We now detect that another task is clocked in and skip clearing the
org-clock-current-task variable used by the agenda to determine if
the clock is currently running.
This commit is contained in:
Bernt Hansen 2012-02-09 22:43:40 +00:00 committed by David Maus
parent 1fd0234a30
commit df0a988a92
1 changed files with 2 additions and 1 deletions

View File

@ -1387,7 +1387,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
(message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
(if remove " => LINE REMOVED" "")) (if remove " => LINE REMOVED" ""))
(run-hooks 'org-clock-out-hook) (run-hooks 'org-clock-out-hook)
(org-clock-delete-current)))))) (unless (org-clocking-p)
(org-clock-delete-current)))))))
(add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer) (add-hook 'org-clock-out-hook 'org-clock-remove-empty-clock-drawer)