Use *org-roam* buffer to list forward links instead

I’m editing a file with multiple outbound links and no backlinks.

Here’s a cheap and dirty way to get the outbound links to show up in the *org-roam* buffer instead of backlinks—though with this one-line change they are still referred to as “backlinks”.

(defun org-roam--get-backlinks (targets)
  "Return the backlinks for TARGETS.
TARGETS is a list of strings corresponding to the TO value in the
Org-roam cache. It may be a file, for Org-roam file links, or a
citation key, for Org-ref cite links."
  (unless (listp targets)
    (setq targets (list targets)))
  (let ((conditions (--> targets
                         ;; I've swapped 'dest for 'source here! -JAC
                         (mapcar (lambda (i) (list '= 'source i)) it) 
                         (org-roam--list-interleave it :or))))
    (org-roam-db-query `[:select [source dest properties] :from links
                         :where ,@conditions
                         :order-by (asc source)])))

OK, so this is a bit silly! But maybe it could inspire a better solution.

Another solution that doesn’t require changing code or other such silly stuff is: M-x occur RET file: RET.

1 Like