Skip to content

Instantly share code, notes, and snippets.

@akashpal-21
Last active June 26, 2024 16:19
Show Gist options
  • Save akashpal-21/988588f42b78b505865dff53fe2e6730 to your computer and use it in GitHub Desktop.
Save akashpal-21/988588f42b78b505865dff53fe2e6730 to your computer and use it in GitHub Desktop.
org-roam-link-utils.el
@lyndhurst
Copy link

Comments

I tried to spare you my foobar gibberish this time. It took me a while and many attempts to put together a testing setup that covers everything that (supposedly) went wrong when testing last night while preserving clarity, so I cannot go more into it this morning. I hope you will find it helpful anyway, because if you do it wwill be easier for me toodo more tests now. If not, please let me know how to improve it.

I realized after the fact that the 'control link' n° 7 was not set up correctly after the fact. It was fixed for the second test. I did not have the courage to start over, and, since there was no issues with control links, I did not think it mattered much.

I have not retested the version from yesterday, did not think it was relevant anymore.

Test Repair 1

Initial Test Setup

testing-setup-1

Test Results

  • Running (org-roam-repair-broken-links)
  • ID links pointing to test node are repaired
  • Roam Links pointing to test node are NOT repaired, but are turned into ID links
  • Control links pointing to other nodes are left untouched

test-repair-1

Test Repair 2

Initial Test Setup

testing-setup-1

Test Results

  • Running (org-roam-repair-broken-links t)
  • ID links pointing to test node are NOT repaired
  • Roam Links pointing to test node:
    • Link with no description repaired
    • Link with matching description NOT repaired
    • Link with custom description NOT repaired
    • I am just realizing I forgot to check if they are turned into ID links, sorry I can rerun it later if needed.
  • Control links pointing to other nodes are left untouched

test-repair-2

@akashpal-21
Copy link
Author

I will fix them, I will take a week to test everything and let you know, I need to do this patiently, so many moving parts

@akashpal-21
Copy link
Author

Refactored the functions,
I think the bugs are fixed now 🤞 - hopefully each functions being smaller & independent have also made it easier to read,

The function responsible for rename does not convert roam links to id links now - it just does a simple rename so that links point to the correct place.

The "repair" function is now called "convert-all"

untitled.mp4

Best,

@akashpal-21
Copy link
Author

akashpal-21 commented Jun 6, 2024

TODO

  1. Process Roam links that use alias instead of title DONE

@lyndhurst
Copy link

While adding some key bindings, I just realized there is a similar org-roam-link-replace-all function that converts all roam links in the buffer with id links. I renamed your convert-all function org-roam-link-replace-all-backlinks in my config for a more uniform naming convention.
I personally prefer convert, but I think this name the other one was there first. It would be even more intuitive imho if the other one was named org-roam-link-replace-all-in-buffer. I thought it was worth mentioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment