Hi Ihor and everyone,

When trying to mark a repeating task as DONE from the agenda, Org throws
an error:

    user-error: No Org agenda currently displayed

This happens on current main (commit c812866f3) and was introduced in
commit c14fa8a07 ("org-agenda-todo: Add more visual feedback on repeating 
tasks").

Backtrace:                                                                      
                                                                                
                                                                
     Debugger entered--Lisp error: (error "No Org agenda currently displayed")  
                                                                                
                                                                   
       error("No Org agenda currently displayed")                               
                                                                                
                                                                   
       org-agenda-check-type(nil agenda)                                        
                                                                                
                                                                   
       org-agenda-todo("DONE")                                                  
                                                                                
                                                                   
       funcall-interactively(org-agenda-todo "DONE")                            
                                                                                
                                                                   
       call-interactively(org-agenda-todo)

The attached patch fixes this by:                                               
                                                                                
                                                                
- Updating `org-agenda-check-type` to respect ERROR when `org-agenda-type` is 
nil.                                                                            
                                                                                
                                        
- In `org-agenda-todo`, capturing whether the current entry belongs to an       
                                                                                
                                                                
  agenda component via `(eq (org-get-at-bol 'org-agenda-type) 'agenda)`         
                                                                                
                                                                
  before switching buffers.                                                     
                                                                                
                                                                
                                                                                
                                                                                
                                                                
Best,
-- 
Slawomir Grochowski
>From 807f705b88aa4aeeefbbb4a1c47441ce064df6fd Mon Sep 17 00:00:00 2001
From: Slawomir Grochowski <[email protected]>
Date: Tue, 15 Sep 2026 18:57:35 +0200
Subject: [PATCH] org-agenda: Fix TODO changes for repeating tasks

* lisp/org-agenda.el (org-agenda-check-type): Respect ERROR when the
agenda type is nil.
(org-agenda-todo): Read the current line's type before switching buffers,
including when bulk actions move between agenda blocks.
---
 lisp/org-agenda.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 6db2bdffc..1fa976b67 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7792,7 +7792,7 @@ subtree."
 If ERROR is non-nil, throw an error, otherwise just return nil.
 Allowed types are `agenda' `todo' `tags' `search'."
   (cond ((not org-agenda-type)
-	 (error "No Org agenda currently displayed"))
+	 (and error (error "No Org agenda currently displayed")))
 	((memq org-agenda-type types) t)
 	(error
 	 (error "Not allowed in `%s'-type agenda buffer or component" org-agenda-type))
@@ -9777,6 +9777,7 @@ the same tree node, and the headline of the tree node in the Org file."
 	  (pos (marker-position marker))
 	  (hdmarker (org-get-at-bol 'org-hd-marker))
 	  (todayp (org-agenda-today-p (org-get-at-bol 'day)))
+	  (agendap (eq (org-get-at-bol 'org-agenda-type) 'agenda))
 	  (inhibit-read-only t)
 	  org-loop-over-headlines-in-active-region
 	  org-agenda-headline-snapshot-before-repeat newhead just-one)
@@ -9796,7 +9797,7 @@ the same tree node, and the headline of the tree node in the Org file."
 	 (when (and org-agenda-headline-snapshot-before-repeat
 		    (not (equal org-agenda-headline-snapshot-before-repeat
 			      newhead))
-		    (or (not (org-agenda-check-type nil 'agenda))
+		    (or (not agendap)
                         todayp))
 	   (setq newhead org-agenda-headline-snapshot-before-repeat
 		 just-one t))
-- 
2.47.3

Reply via email to