fix(org): reload org-mode in half-loaded capture buffers

Fix: #5411
This commit is contained in:
Henrik Lissner 2024-07-02 02:19:26 -04:00
parent 7bb5df4cd4
commit b0e16dc243
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -767,10 +767,9 @@ mutating hooks on exported output, like formatters."
(defun +org--restart-mode-h ()
"Restart `org-mode', but only once."
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h 'local)
(quiet! (org-mode-restart))
(delq! (current-buffer) org-agenda-new-buffers)
(remove-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
'local)
(run-hooks 'find-file-hook))
(add-hook! 'org-agenda-finalize-hook
@ -796,14 +795,14 @@ can grow up to be fully-fledged org-mode buffers."
(add-hook 'doom-switch-buffer-hook #'+org--restart-mode-h
nil 'local))))))
(defadvice! +org--restart-mode-before-indirect-buffer-a (base-buffer &rest _)
(defadvice! +org--restart-mode-before-indirect-buffer-a (&optional buffer _)
"Restart `org-mode' in buffers in which the mode has been deferred (see
`+org-defer-mode-in-agenda-buffers-h') before they become the base buffer for an
indirect buffer. This ensures that the buffer is fully functional not only when
the *user* visits it, but also when some code interacts with it via an indirect
buffer as done, e.g., by `org-capture'."
:before #'make-indirect-buffer
(with-current-buffer base-buffer
:before #'org-capture-get-indirect-buffer
(with-current-buffer (or buffer (current-buffer))
(when (memq #'+org--restart-mode-h doom-switch-buffer-hook)
(+org--restart-mode-h))))