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
Question on org-roam-node-insert and org-roam-node-find #2431
Comments
I don't grasp the problem here - org-roam should not open any files for processing - it queries a db; You want the find to be fast? To make the find fast we can cache the formatting by introducing a cache-mechanism using hash-tables,
Recently I came across this cache - it would work well for your case, for larger node sizes we can cache more things. EDIT |
I came up with this : (with-eval-after-load 'org-roam
(cl-defmethod org-roam-node-mytitle ((node org-roam-node))
"Return the parent node of NODE."
(let ((level (org-roam-node-level node))
(title (org-roam-node-title node)))
(cond
((= level 0) title)
((= level 1) (concat (org-roam-node-file-title node) "/" title))
(t (let* ((file (org-roam-node-file node))
(marker (org-roam-node-marker node)))
(with-temp-buffer
(insert-file-contents file)
(goto-char marker)
(org-up-heading-or-point-min)
(concat (org-roam-node-title (org-roam-node-from-id (org-entry-get (point) "ID" t))) "/" title)))))))) which is faster. I am still interested in customizing node insertion ( |
This is a very inefficient way - there are a lot of redundant things being done. If you create such inefficiencies - they shall scale up and make your day to day operation a nightmare. Q) Why are you creating a temp buffer? what is the meaning of this? You are getting the node struct as an argument to this function - you are going around the world to get it again. Please consider not creating such inefficiencies -- unless you cache - this list is being prepared over and over when you call the read function which gives you the interface to choose a node. Can you please come to the discourse -- it is not possible to talk extensively here -- your case is not a issue - but if you require help, youd get better help there. |
This is what I use - do not define a t type -- all you need is two scenarios. I use Bold and Italic to differentiate - but you can as easily remove them. |
Brief Abstract
I want
org-roam-node-insert
andorg-roam-node-find
to insert and return the chosen node with its parent as :Proposed Implementation (if any)
Here is an implementation of this for
org-roam-node-find
:This implementation defines a custom function to retrieve the title of the node. If the node level is the root (0),
the title is returned as is, if level is 1, this means it is a first header of a file and the parent node is the file title
itself, otherwise I have to parse the file back up to the upper level node.
This implementation works well :
Problem
My current issue is that with an increasing number of nodes (about a thousand), this
implementation becomes slow, not because of the number of nodes itself but because
all files are opened and there is some org processing each time :
But I do not need all this org processing to just retrieve the parent node.
Request
org-roam-node-insert
so that inserting a link in a filewould result in
parent node title/linked node title
, but it seems harder to implement at first sight,how could I proceed ?
To my knowledge : [ X] No similar feature requests
The text was updated successfully, but these errors were encountered: