Show Org roam buffer in selected window before updating its content

This is to address the issue of malformed content in the Org roam
buffer, see https://github.com/org-roam/org-roam/issues/1586.  The
excellent description of @camdez in [there][1] is the basis for this
workaround.

[1]: https://github.com/org-roam/org-roam/issues/1586#issuecomment-1412250226
This commit is contained in:
Daniel - 2023-12-23 21:04:56 +01:00
parent 4eeb5527bc
commit 18e612b447
Signed by: dbo
GPG Key ID: 784AA8DF0CCDF625
1 changed files with 16 additions and 1 deletions

17
init.el
View File

@ -1267,7 +1267,22 @@
:bind (:map org-mode-map
(("C-c n l" . org-roam-buffer-toggle)
("C-c n g" . org-roam-graph)))
:config (org-roam-db-autosync-mode))
:config (progn
(org-roam-db-autosync-mode)
(define-advice org-roam-buffer-render-contents
(:around (orig-func) show-buffer-in-selected-window)
"Show Org roam buffer in selected window before updating its content.
See https://github.com/org-roam/org-roam/issues/1586, and in particular
https://github.com/org-roam/org-roam/issues/1586#issuecomment-1412250226.
Note that this workaround is incomplete, as explained in this comment."
(let ((org-roam-buffer-window (display-buffer (current-buffer))))
;; When we cannot display the buffer, there is also no need to
;; update it, no?
(when org-roam-buffer-window
(with-selected-window org-roam-buffer-window
(funcall orig-func)))))))
;; * General Programming