*org-roam* buffer in frame A not refreshing for org buffers in frame B

My elisp isn’t the best, so I would appreciate if someone could tell me what I’m doing wrong.

(defun buffer-exists (bufname doathing)
  "Helper function to do something if bufname
exists and current buffer is org file."
  (when (and (string-match "^.*\.org$"
(buffer-name)) (not (eq nil (get-buffer
bufname))))
      (funcall doathing)))

(defun org-roam-backlinks ()
  "Redisplays buffer as long as current buffer
is not *org-roam* and *org-roam* buffer exists"
  (buffer-exists "*org-roam*"
'org-roam-buffer--redisplay-h))

(add-hook 'post-command-hook 'org-roam-backlinks)

Just to be sure…: the manual has this.

org-roam-buffer-toggle: Launch an Org-roam buffer that tracks the node currently at point. This means that the content of the buffer changes as the point is moved, if necessary.

This does not work across frames?

Just overriding org-roam-buffer--redisplay-h seems to do the job

(defun org-roam-buffer--redisplay-h ()
  "Reconstruct the persistent `org-roam-buffer'.
This needs to be quick or infrequent, because this designed to
run at `post-command-hook'."
  (and (get-buffer-window org-roam-buffer :all-frames) ;;<- just added an additional argument to `get-buffer-window'
       (org-roam-buffer-persistent-redisplay)))
3 Likes

Unfortunately, no. org-roam-buffer-toggle does display *org-roam* and will refresh backlinks for a given node visited in a buffer in the same frame. Unless *org-roam* is present in both frames, it won’t work across frames, which seems kindof redundant. Really, I would just like the option to open a frame with a sole window just for backlinks. If I replace the above code with (org-roam-db-autosync-mode) it behaves the same way. Is this just expected behaviour for org-roam?

Edit: sorry, I didn’t see your reply. I’ll try that out.

It works and it’s so simple! Thank you so much.

2 Likes