From 96944e8d43a06ce85a676dfe4ad73a804310ef1f Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Fri, 2 Feb 2024 16:23:05 +0100 Subject: [PATCH] org-fold-core--process-delayed: Fix delayed folding in killed buffers * lisp/org-fold-core.el (org-fold-core--process-delayed): Do not fold when markers point to killed buffers. --- lisp/org-fold-core.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index 610eae259..9c148d328 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -1357,7 +1357,9 @@ Pass the same FROM, TO, FLAG, and SPEC-OR-ALIAS." "Perform folding for `org-fold-core--region-delayed-list'." (when org-fold-core--region-delayed-list (mapc (lambda (args) - (when (< (nth 0 args) (nth 1 args)) + (when (and (buffer-live-p (marker-buffer (nth 0 args))) + (buffer-live-p (marker-buffer (nth 1 args))) + (< (nth 0 args) (nth 1 args))) (org-with-point-at (car args) (apply #'org-fold-core-region args)))) ;; Restore the initial folding order.