Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlinked references in same file #2397

Open
1 task done
rynoV opened this issue Oct 28, 2023 · 1 comment
Open
1 task done

Unlinked references in same file #2397

rynoV opened this issue Oct 28, 2023 · 1 comment

Comments

@rynoV
Copy link

rynoV commented Oct 28, 2023

Brief Abstract

Currently unlinked references don't work across nodes in the same file.

Long Description

This is due to this line:

(not (file-equal-p (org-roam-node-file node) f))

I like to keep many nodes in the same file, so it would be great if unlinked references could work for this use case.

Proposed Implementation (if any)

This seems to work for me:

diff --git a/org-roam-mode.el b/org-roam-mode.el
--- org-roam-mode.el
+++ org-roam-mode.el
@@ -673,20 +673,30 @@
                                                     (format "|(\\b%s\\b)" (shell-quote-argument title)))
                                                   titles ""))
                                org-roam-directory))
            (results (split-string (shell-command-to-string rg-command) "\n"))
-           f row col match)
+           f row col match other-node)
       (magit-insert-section (unlinked-references)
         (magit-insert-heading "Unlinked References:")
         (dolist (line results)
           (save-match-data
             (when (string-match org-roam-unlinked-references-result-re line)
               (setq f (match-string 1 line)
                     row (string-to-number (match-string 2 line))
                     col (string-to-number (match-string 3 line))
+                    other-node (save-match-data
+                                 (with-current-buffer (find-file-noselect f)
+                                   (save-excursion
+                                     (goto-char (point-min))
+                                     (forward-line (1- row))
+                                     (move-to-column col)
+                                     (org-roam-node-at-point))))
                     match (match-string 4 line))
               (when (and match
-                         (not (file-equal-p (org-roam-node-file node) f))
+                         (not (and other-node (string-equal
+                                               (org-roam-node-id node)
+                                               (org-roam-node-id other-node))))
                          (member (downcase match) (mapcar #'downcase titles)))
                 (magit-insert-section section (org-roam-grep-section)
                   (oset section file f)
                   (oset section row row)

Please check the following:

  • No similar feature requests
@akashpal-21
Copy link

Thank you so much for providing the diff file. This was a major bug for my usecase, I write documents in long form and this solved a huge problem. I patched my files and now org-roam-buffer behaves as it should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants