Now, this is annoying as I cannot see the totality of the backlink text at a glance. I need to navigate the cursor to the backlinks window and move the cursor to read the text properly.
A partial remedy to that is enableling visual-line-mode in the backlinks buffer, which results in the following layout:
Better, as I can see the whole backlinks paragraph without navigating the cursor there. BUT, now the newlines inserted by org-fill-paragraph (M-q) also reflect themselves in the backlinks buffer text display. That looks annoying.
Is there a better solution to displaying the backlinks buffer text?
The easiest fix perhaps would be to change the window-width so that org-roam-buffer will be wider than the fill-column variable (used by org-fill-paragraph).
If this is not what you prefer, then you can use the org-roam-preview-function hook and either re-define the default function or set your own function to the hook. I think you can reverse the effect of (org-)fill-paragraph somehow.
I have the following function to “undo” fill-paragraph but it works only on a single paragraph – you would need to apply it to every paragraph:
This adaption below seems to work in a buffer, so I think you can put the result of org-roam-preview-default-function into a temp buffer and call the function below to remove the hard line-wrapping. Does this make sense?
I can’t do that, the fill-column variable is 70 characters long, that would be making the backlinks buffer larger than the main org-roam buffer. The point about backlinks buffer is that it’s not supposed to be the main center of attention. It’s supposed to be the side window for quickly glancing at the referencing notes.
It’s a bit complicated solution. I need to think on it. It would be more desirable to have a “just works” solution rather than defining my own hooks and elisp functions.
To me, it is a “just works” solution. It’s up to you what you take (from the Elisp viewpoint, it would be a few lines and I find it straightforward). There may be other and easier ways that I don’t know.
The use of temp-buffer to manipulate text is idiomatic in Emacs Lisp. See the buffer example from Elisp Cookbook on EmacsWiki (in 1-1. Strings vs buffer text).
Something like this should work for you – I have tested it lightly on my end.
(defun my/org-roam-preview-default-function ()
(let ((content (org-roam-preview-default-function))
(fill-column (- (point-max) (point-min))))
(with-temp-buffer
(insert content)
(mark-whole-buffer)
(org-fill-paragraph nil t)
(deactivate-mark)
(buffer-substring-no-properties (point-min) (point-max)))))
(setopt org-roam-preview-function #'my/org-roam-preview-default-function)
;; you can use `setq` instead of `setopt` if you like
(add-hook 'org-roam-mode-hook #'visual-line-mode)