When a clock is started due to :clock-in t, it is saved when :clock-keep is t. But this should only be done when capture is finalized and not when killed/aborted. This change adds a check to ensure that the clock is not kept when the capture was aborted.
From 1024e23a4bb3962f5446a1cc705035a0f8e3bfde Mon Sep 17 00:00:00 2001
From: Bibek Panthi <bpanthi...@gmail.com>
Date: Tue, 29 Apr 2025 12:54:20 -0500
Subject: [PATCH] lisp/org-capture.el: cancel new clock when capture is killed

* org-capture.el (org-capture-finalize): Don't keep newly started
clock when capture is aborted.

When a clock is started due to :clock-in t, it is saved when
:clock-keep is t. But this should only be done when capture is
finalized and not when killed/aborted. This change adds a check to 
ensure that the clock is not kept when the capture was aborted.

TINYCHANGE
---
 lisp/org-capture.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index b5ec4a012..69419af4f 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -794,7 +794,7 @@
   (when (and org-capture-clock-was-started
             (equal org-clock-marker org-capture-clock-was-started))
     ;; Looks like the clock we started is still running.
-    (if org-capture-clock-keep
+    (if (and org-capture-clock-keep (not org-note-abort))
        ;; User may have completed clocked heading from the template.
        ;; Refresh clock mode line.
        (org-clock-update-mode-line t)
-- 
2.39.5 (Apple Git-154)

Reply via email to