Browse Source

org-clock.el (org-clock-out): Fix bug.

* org-clock.el (org-clock-out): Fix bug: if a closing note
needs to be stored in the drawer where clocks are stored,
let's temporarily remove `org-clock-remove-empty-clock-drawer'
from `org-clock-out-hook'.

Thanks to Дядов Васил Стоянов for reporting this bug.
Bastien Guerry 8 years ago
parent
commit
3b21f246d6
1 changed files with 9 additions and 1 deletions
  1. 9 1
      lisp/org-clock.el

+ 9 - 1
lisp/org-clock.el

@@ -1524,7 +1524,15 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
 	  (force-mode-line-update)
 	  (message (concat "Clock stopped at %s after HH:MM = " org-time-clocksum-format "%s") te h m
 		   (if remove " => LINE REMOVED" ""))
-          (run-hooks 'org-clock-out-hook)
+	  (let ((h org-clock-out-hook))
+	    ;; If a closing note needs to be stored in the drawer
+	    ;; where clocks are stored, let's temporarily disable
+	    ;; `org-clock-remove-empty-clock-drawer'
+	    (if (and (equal org-clock-into-drawer org-log-into-drawer)
+		     (eq org-log-done 'note)
+		     org-clock-out-when-done)
+		(setq h (delq 'org-clock-remove-empty-clock-drawer h)))
+	    (mapc (lambda (f) (funcall f)) h))
 	  (unless (org-clocking-p)
 	    (org-clock-delete-current)))))))