branch: externals/org-modern
commit a4d242994d279a532317e04036e335708a166a16
Author: JD Smith <[email protected]>
Commit: JD Smith <[email protected]>
Guard against deleted buffers (org-roam may do this)
If buffers are opened and closed quickly and still on the wait list,
this causes timer errors
---
org-modern-indent.el | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/org-modern-indent.el b/org-modern-indent.el
index ed23e94df0..57a04cc5b1 100644
--- a/org-modern-indent.el
+++ b/org-modern-indent.el
@@ -163,25 +163,27 @@ returned."
(defvar-local org-modern-indent--init nil)
(defun org-modern-indent--wait-and-refresh (buf)
"Wait for org-indent to finish initializing BUF, then refresh."
- (if (or (not (bound-and-true-p org-indent-agentized-buffers))
- (not (memq buf org-indent-agentized-buffers)))
- (when (buffer-live-p buf) ; org-capture buffers vanish fast
+ (when (buffer-live-p buf)
+ (if (or (not (bound-and-true-p org-indent-agentized-buffers))
+ (not (memq buf org-indent-agentized-buffers)))
(with-current-buffer buf
(font-lock-add-keywords nil org-modern-indent--font-lock-keywords t)
- (font-lock-flush)))
- ;; still waiting
- (with-current-buffer buf
- (if org-modern-indent--init
- (let ((cnt (cl-incf (cadr org-modern-indent--init))))
- (if (> cnt 5)
- (user-error
- "org-modern-indent: Gave up waiting for %s to initialize" buf)
- (timer-activate (timer-set-time (car org-modern-indent--init)
- (time-add (current-time) 0.2)))))
- (setq
- org-modern-indent--init
- (list (run-at-time 0.1 nil #'org-modern-indent--wait-and-refresh buf)
- 1))))))
+ (font-lock-flush))
+ ;; still waiting
+ (with-current-buffer buf
+ (if org-modern-indent--init
+ (let ((cnt (cl-incf (cadr org-modern-indent--init))))
+ (if (> cnt 5)
+ (user-error
+ "org-modern-indent: Gave up waiting for %s to initialize"
+ buf)
+ (timer-activate
+ (timer-set-time (car org-modern-indent--init)
+ (time-add (current-time) 0.2)))))
+ (setq
+ org-modern-indent--init
+ (list (run-at-time 0.1 nil #'org-modern-indent--wait-and-refresh buf)
+ 1)))))))
(defun org-modern-indent--refresh ()
"Unfontify entire buffer and refresh line prefix."