Ihor Radchenko <[email protected]> writes:

> Morgan Smith <[email protected]> writes:
>>
>> I've pushed the code.
>
> The new code will throw an error when point is not on heading, unlike
> the old code.

Darn.  I tried my best to ensure the API switchover didn't change behavior.

I had foolishly assumed that "(org-is-habit-p (point))" would error when
not on a heading.  I was wrong.

I've attached a patch that fixes the issue.  Let me know what you think.

>From d59c4fc6215f18efec911f43bb326ddebcd26da1 Mon Sep 17 00:00:00 2001
From: Morgan Smith <[email protected]>
Date: Tue, 14 Jul 2026 18:42:22 -0400
Subject: [PATCH] org-habit: Correctly parse habit when not at heading

This worked before e55fdd953.

* lisp/org-habit.el (org-habit-parse-todo): Fix when not at heading.
---
 lisp/org-habit.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index bf52e50e8..db62f8191 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -197,7 +197,7 @@ org-habit-parse-todo
   5: Repeater type as a string
 
 This list represents a \"habit\" for the rest of this module."
-  (let ((todo (org-element-at-point epom)))
+  (let ((todo (org-element-at-point (or epom (org-entry-beginning-position)))))
     (cl-assert (org-is-habit-p todo))
     (let* ((habit-entry (org-no-properties (org-element-property :title todo)))
            (scheduled
-- 
2.54.0

Reply via email to