Hello,

I've experienced occasionally errors while executing org-clock-in from
the agenda. Moving from the agenda to the todo headline in the
underlying org file and repeating org-clock-in and org-clock-out usually
lead to a state in which I could successfully run org-clock-in.

The following patch fixes the issue for me and I believe it does no
harm. I've used it daily for two month. I'd appreciate if you could add
it org-mode.

Kind regards,
  Jean-Marie

-- Jean-Marie Gaillourdet
From 319785492d55d33cdf819aa891c3e7834dafacff Mon Sep 17 00:00:00 2001
From: Jean-Marie Gaillourdet <j...@gaillourdet.net>
Subject: [PATCH] org-clock: fix runtime error in org-clock-in

* org-clock.el (org-clock-in): Under certain configurations of org,
Emacs doom, evil-org-mode and my custom settings, org-clock-in aborts
with an an error because indent-line-to is called with -2.
---
 lisp/org-clock.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6c7a797ff..4256b1a21 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -1368,7 +1368,7 @@ the default behavior."
 			(end-of-line 0)
 			(org-in-item-p)))
 	     (beginning-of-line 1)
-	     (indent-line-to (- (current-indentation) 2)))
+	     (indent-line-to (max 0 (- (current-indentation) 2))))
 	   (insert org-clock-string " ")
 	   (setq org-clock-effort (org-entry-get (point) org-effort-property))
 	   (setq org-clock-total-time (org-clock-sum-current-item
--
2.29.2

Reply via email to