Excluding ref nodes from find-node

“Copy” might have been a little too sloppy an expression on my part; apologies if it was misleading somehow.

I could think of two general approaches – I haven’t examined either of them, so please verify them on your end; there might well be a better approach.

  1. Use filter-fn and create a custom command that wraps org-roam-node-read
    In the custom wrapper command, you can pass your custom filter function to org-roam-node-read via filter-fn argument.
    To me, a key question to be answered is, can you programmatically inspect each node and tell refs vs others. I guess yes, but I’m not sure.
    One obvious disadvantage would be performance. The program would get all the nodes including ref nodes first, then examine each of them, and finally filter out ref nodes. Dealing with a large volume of notes might result in noticeably slow performance.

  2. My “copy” idea. org-roam-node-find is a very standardized small command, so it is rather easy to copy or create a wrapper for. It seems to come with a caching mechanism, so you would want to keep it. The actual SQL statement is written in org-roam-node-list. The idea is to have a custom node-list function with your own SQL statement, and somehow swap them when you want it.
    The key investigation is to determine how you can achieve this swapping mechanism. My guess is that you could use cl-letf to temporarily replace the call to org-roam-node-list with your custom function. @arozbiz has shared a smart use of cl-letf in his post. I believe the same idea could be applied in this case, too.