Skip to content

Instantly share code, notes, and snippets.

@mmarshall540
Last active November 18, 2025 13:25
Show Gist options
  • Select an option

  • Save mmarshall540/d722dc8b8f2ca0da9cc6a6dfcfc439d8 to your computer and use it in GitHub Desktop.

Select an option

Save mmarshall540/d722dc8b8f2ca0da9cc6a6dfcfc439d8 to your computer and use it in GitHub Desktop.
Backlinking facilities for Org-mode entries
@mmarshall540
Copy link
Author

This provides functionality for backlinking Org-mode entries without installing extra packages.

  • A command to list all entries that link to the current node (assumes that the current entry has an ID property).

  • A command to insert a dynamic block which can be updated with all other nodes that link to the current node (requires that both the current node and nodes that link to it have ID properties).

My reasons for doing this:

  1. Org-roam can't work with Orgzly-revived or Orgro. That's understandable, since those are mobile apps that are not Emacs. But it means that in order to follow backlinks in those apps, the backlinks must be found in the text of the entries. The dynamic block achieves that.

  2. There are other packages which can insert backlinks in the content of an entry, such as Org-super-links and Org-node. But a dynamic block is a built-in Org-mode feature which is easy to update automatically. And I like built-in features.

To update the dynamic block, you just enter C-c C-c with point on the block. Or you can use this to automatically update all dynamic blocks in an Org-mode buffer before each save.

(add-hook 'before-save-hook 'org-update-all-dblocks)

See the Info node "(org) Dynamic Blocks" for more info.

@mmarshall540
Copy link
Author

Aaaand of course this doesn't scale well. At least not with org-update-all-dblocks placed on after-save-hook.

If it gets too slow, I can have some code that adds a single link to a link-target's block when linking. Then, only run org-update-all-dblocks every once in a while.

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