From 498f4b78c470637b8977a1013d69ff4735fa0894 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Fri, 8 Dec 2023 17:43:59 +0100 Subject: [PATCH] Automatically clock into interrupted task only when not closed yet This is to avoid jumping back to old task that are still pointed at by `org-clock-interrupted-task` that have long been closed. Let's see whether this is enough to handle this case. --- site-lisp/db-org.el | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index c170e86..f003480 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -424,15 +424,21 @@ should not be clocked." This functions tries to clock into the interrupted task, the parent task, or the default task, in that order and only when -available, respectively. If none of these tasks is available, -interactively query the user for the next task to clock into." +available, respectively. Clock in to the interrupted task only +if it is not closed yet. + +If none of the listed tasks is available, interactively query the +user for the next task to clock into." (when (and (not org-clock-clocking-in) (not org-clock-resolving-clocks-due-to-idleness)) (let ((parent-task (db/find-parent-task))) (save-mark-and-excursion (cond ((and (markerp org-clock-interrupted-task) - (marker-buffer org-clock-interrupted-task)) + (marker-buffer org-clock-interrupted-task) + (org-with-point-at org-clock-interrupted-task + (not (member (nth 2 (org-heading-components)) + org-done-keywords)))) ;; interrupted task is set (org-with-point-at org-clock-interrupted-task (org-clock-in)))