|
@@ -63,10 +63,17 @@ which see."
|
|
|
|
|
|
(defcustom org-clock-out-when-done t
|
|
(defcustom org-clock-out-when-done t
|
|
"When non-nil, clock will be stopped when the clocked entry is marked DONE.
|
|
"When non-nil, clock will be stopped when the clocked entry is marked DONE.
|
|
|
|
+DONE here means any DONE-like state.
|
|
A nil value means, clock will keep running until stopped explicitly with
|
|
A nil value means, clock will keep running until stopped explicitly with
|
|
-`C-c C-x C-o', or until the clock is started in a different item."
|
|
|
|
|
|
+`C-c C-x C-o', or until the clock is started in a different item.
|
|
|
|
+Instead of t, this can also be a list of TODO states that should trigger
|
|
|
|
+clocking out."
|
|
:group 'org-clock
|
|
:group 'org-clock
|
|
- :type 'boolean)
|
|
|
|
|
|
+ :type '(choice
|
|
|
|
+ (const :tag "No" nil)
|
|
|
|
+ (const :tag "Yes, when done" t)
|
|
|
|
+ (repeat :tag "State list"
|
|
|
|
+ (string :tag "TODO keyword"))))
|
|
|
|
|
|
(defcustom org-clock-out-remove-zero-time-clocks nil
|
|
(defcustom org-clock-out-remove-zero-time-clocks nil
|
|
"Non-nil means, remove the clock line when the resulting time is zero."
|
|
"Non-nil means, remove the clock line when the resulting time is zero."
|
|
@@ -1170,7 +1177,8 @@ If there is no running clock, throw an error, unless FAIL-QUIETLY is set."
|
|
(when org-clock-out-switch-to-state
|
|
(when org-clock-out-switch-to-state
|
|
(save-excursion
|
|
(save-excursion
|
|
(org-back-to-heading t)
|
|
(org-back-to-heading t)
|
|
- (let ((org-inhibit-logging t))
|
|
|
|
|
|
+ (let ((org-inhibit-logging t)
|
|
|
|
+ (org-clock-out-when-done nil))
|
|
(cond
|
|
(cond
|
|
((functionp org-clock-out-switch-to-state)
|
|
((functionp org-clock-out-switch-to-state)
|
|
(looking-at org-complex-heading-regexp)
|
|
(looking-at org-complex-heading-regexp)
|
|
@@ -1384,7 +1392,10 @@ from the `before-change-functions' in the current buffer."
|
|
This is used to stop the clock after a TODO entry is marked DONE,
|
|
This is used to stop the clock after a TODO entry is marked DONE,
|
|
and is only done if the variable `org-clock-out-when-done' is not nil."
|
|
and is only done if the variable `org-clock-out-when-done' is not nil."
|
|
(when (and org-clock-out-when-done
|
|
(when (and org-clock-out-when-done
|
|
- (member state org-done-keywords)
|
|
|
|
|
|
+ (or (and (eq t org-clock-out-when-done)
|
|
|
|
+ (member state org-done-keywords))
|
|
|
|
+ (and (listp org-clock-out-when-done)
|
|
|
|
+ (member state org-clock-out-when-done)))
|
|
(equal (or (buffer-base-buffer (marker-buffer org-clock-marker))
|
|
(equal (or (buffer-base-buffer (marker-buffer org-clock-marker))
|
|
(marker-buffer org-clock-marker))
|
|
(marker-buffer org-clock-marker))
|
|
(or (buffer-base-buffer (current-buffer))
|
|
(or (buffer-base-buffer (current-buffer))
|
|
@@ -1393,7 +1404,8 @@ and is only done if the variable `org-clock-out-when-done' is not nil."
|
|
(> (save-excursion (outline-next-heading) (point))
|
|
(> (save-excursion (outline-next-heading) (point))
|
|
org-clock-marker))
|
|
org-clock-marker))
|
|
;; Clock out, but don't accept a logging message for this.
|
|
;; Clock out, but don't accept a logging message for this.
|
|
- (let ((org-log-note-clock-out nil))
|
|
|
|
|
|
+ (let ((org-log-note-clock-out nil)
|
|
|
|
+ (org-clock-out-switch-to-state nil))
|
|
(org-clock-out))))
|
|
(org-clock-out))))
|
|
|
|
|
|
(add-hook 'org-after-todo-state-change-hook
|
|
(add-hook 'org-after-todo-state-change-hook
|