Created
May 19, 2024 08:49
-
-
Save dmgerman/1c76743aa36c5d86112123fd333566e2 to your computer and use it in GitHub Desktop.
Improve performance of org-roam-find-node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq dmg-roam-candidates-cache (make-hash-table :test 'equal)) | |
(defun org-roam-node-read--to-candidate (node template) | |
"Return a minibuffer completion candidate given NODE. | |
TEMPLATE is the processed template used to format the entry." | |
(let* ((args (list node template)) | |
(cached-result (gethash args dmg-roam-candidates-cache)) | |
) | |
(if cached-result | |
cached-result | |
(let* ((candidate-main (org-roam-node--format-entry | |
template | |
node | |
(1- (if (bufferp (current-buffer)) | |
(window-width) (frame-width))))) | |
(result (cons (propertize candidate-main 'node node) node)) | |
) | |
(progn | |
(puthash args result dmg-roam-candidates-cache) | |
result | |
) | |
)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment