From 64b75906a325a748e278b15c6f58bf7618b4fc76 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 23 Dec 2023 21:04:56 +0100 Subject: [PATCH] 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 --- init.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 1c8c1ea..3088e1c 100644 --- a/init.el +++ b/init.el @@ -1267,7 +1267,21 @@ :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." + (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