From 18e612b44787e2c960e0b498c8996f17b2715788 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 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 1c8c1ea..705079b 100644 --- a/init.el +++ b/init.el @@ -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