web...@toryanderson.com (Tory S. Anderson) writes:
> Steps to reproduce:
>
> 1. load emacs with the use-package declaration below
> 2. visit =M-x org-agenda<RET>a3. Clock in to the "Parent" item on the agenda 
> by highlighting it and doing =C-c C-x <TAB>   -- thread will freeze 
> indefinitely, although in toy example you can break free with C-g   

Confirmed

The patch is attached.

Best,
Ihor

>From 5c4a699e5a8d9ce6045d0ce710dcf14b9a92d2d8 Mon Sep 17 00:00:00 2001
Message-Id: <5c4a699e5a8d9ce6045d0ce710dcf14b9a92d2d8.1624364038.git.yanta...@gmail.com>
From: Ihor Radchenko <yanta...@gmail.com>
Date: Tue, 22 Jun 2021 20:10:16 +0800
Subject: [PATCH] Avoid infinite loop in org-agenda-dim-blocked-tasks

* lisp/org-agenda.el (org-agenda-dim-blocked-tasks): When the blocked
task is the last line in agenda buffer and no trailing newline is
present, (move-beginning-of-line 2) would not move the point causing
infinite loop.  Now, such case is handled correctly.
---
 lisp/org-agenda.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 44acd035a..b5fc0179a 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -4107,7 +4107,9 @@ (defun org-agenda-dim-blocked-tasks (&optional _invisible)
 	    (overlay-put ov 'face 'org-agenda-dimmed-todo-face))
 	  (when invisible
 	    (org-agenda-filter-hide-line 'todo-blocked)))
-	(move-beginning-of-line 2))))
+        (if (= (point-max) (line-end-position))
+            (goto-char (point-max))
+	  (move-beginning-of-line 2)))))
   (when (called-interactively-p 'interactive)
     (message "Dim or hide blocked tasks...done")))
 
-- 
2.31.1

Reply via email to