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
Adding dynamic blocks to org-roam #2251
Comments
@chrisbarrett BTW: does it support "nodes" level?
|
@qingshuizheng probably better to ask for support on my repo at this stage, but I'll answer these quick questions here. :)
You can use the
^ This variable is not intended to be customised--the names of blocks are hardcoded and cannot be customised due to limitations of the dblocks API. |
@chrisbarrett Ahh! Exactly. Apologies. :-)
I must have been blind for skipping this. Let me dive into it. |
I just want to chime in that this is an amazing addition (in terms of functionality -- can't judge the code) and I hope it gets included in Org-roam itself! Or, if not, that you'd package it outside your 'nursery' 😄 |
Wow this is great, i think about something similar using org-ql (alphapapa/org-ql#183). perhaps that could enhance some of your already function to filter content @chrisbarrett ? |
Perhaps there is a link between the two project, alphapapa/org-ql#303 and the recent merge made by @jethrokuan for #2288 ? |
This is pretty cool. For what it's worth, I have a very rough version working with org-ql (https://github.com/ahmed-shariff/dotfiles/blob/master/.emacs.d/customFiles/okm-ql-view.el), but for some reason org-ql (and org) with large number of files is super slow (as seen in alphapapa/org-ql#303) |
Brief Abstract
org-mode has a feature called dynamic blocks (dblocks), which allow you to define blocks whose contents are computed dynamically. I've got an implementation that builds lists of links to org-roam nodes, allowing you to create 'canned searches'. I'd like to offer it for inclusion if there's interest.
Long Description
Dynamic blocks are an extension mechanism that allows packages to teach org-mode about new kinds of blocks. The contents of these blocks are dynamically computed.
I've written an implementation that inserts a list of nodes from the org-roam db that match criteria in the header. I have also written a corresponding minor-mode that automatically updates the blocks on file visit and before save, which keeps them up-to-date.
Use-cases for these blocks include dynamically discovering nodes based on criteria (e.g. tags) to build up Maps of Content (MOCs), list backlinks that match certain predicates, etc.
As a simple example, I have the following nodes in my DB:
Action (genre)
Sci-Fi (genre)
Horror (genre)
Say I want to abstract over these nodes with a higher-level MOC listing all genres. I could go into each note and insert backlinks, or built a list of links in the MOC by hand.
But since they all follow a title convention (they end with
(genre)
) I could use one of these dynamic blocks to generate the list for me:Hitting C-c C-c on the header fills it out:
Assuming I've enabled the auto-update minor mode, I can then create new nodes later with the
<name> (genre)
convention. Next time I open up my genres MOC, that list will update automatically to include links to those new nodes.Proposed Implementation (if any)
https://github.com/chrisbarrett/nursery/blob/main/lisp/org-roam-dblocks.el
The implementation uses some support libraries defined in that repo. I'd remove these dependencies if this were to be contributed.
Commentary:
Please check the following:
The text was updated successfully, but these errors were encountered: