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.
This commit is contained in:
Ihor Radchenko 2024-02-02 16:23:05 +01:00
parent 71fa0014db
commit 96944e8d43
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 3 additions and 1 deletions

View File

@ -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.