Created
July 15, 2021 17:35
-
-
Save SirensOfTitan/75204ccffc5227baaa131c203066bcf1 to your computer and use it in GitHub Desktop.
random-excluding-dailies
This file contains 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
(defun sirensoftitan/org-roam-node-random (&optional other-window) | |
"Find a random Org-roam node not in the daily notes collection. | |
With prefix argument OTHER-WINDOW, visit the node in another | |
window instead." | |
(interactive current-prefix-arg) | |
(if (not org-roam-dailies-directory) | |
(org-roam-node-random other-window) | |
(let* ((expanded-dir (expand-file-name org-roam-dailies-directory)) | |
(where-pred (concat expanded-dir "%")) | |
(results (org-roam-db-query [:select [id file pos] :from nodes :where (not-like file $s1)] where-pred)) | |
(random-row (seq-random-elt results))) | |
(org-roam-node-visit (org-roam-node-create :id (nth 0 random-row) | |
:file (nth 1 random-row) | |
:point (nth 2 random-row)) | |
other-window)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment