37 lines
1.3 KiB
Org Mode
37 lines
1.3 KiB
Org Mode
:PROPERTIES:
|
|
:ID: 20220713T141408.123508
|
|
:END:
|
|
#+TITLE: Jump to Missing Org Roam Nodes
|
|
#+FILETAGS: :CCE:
|
|
#+AUTO_TANGLE: t
|
|
|
|
#+ARROYO_EMACS_MODULE: missing-org-roam
|
|
#+ARCOLOGY_KEY: cce/jump-to-missing-node
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
Invoking =jump-to-missing-node= picks a random [[id:cce/org-roam][org-roam]] link which is of the =[[roam:Some Text]]= form, i.e. a stub, so that you can fill in missing parts of your graph. This paired with [[help:org-roam-refile]] is a helpful way to flesh out your [[id:knowledge_base][Knowledge Base]].
|
|
|
|
#+begin_src emacs-lisp :tangle ~/org/cce/missing-org-roam.el
|
|
(defun one-random (list)
|
|
(elt list
|
|
(random (length list))))
|
|
|
|
(defun one-missing-node ()
|
|
(let* ((from-db (org-roam-db-query [:select [source dest] :from links :where (= type "roam")]))
|
|
(dest-names (-map #'cadr from-db))
|
|
(as-alist (--map (cons (cadr it) (car it)) from-db))
|
|
(eln (one-random dest-names)))
|
|
(assoc eln as-alist #'equal)))
|
|
|
|
(defun jump-to-missing-node ()
|
|
(interactive)
|
|
(pcase-let* ((`(,text . ,source-id) (one-missing-node))
|
|
(node (org-roam-node-from-id source-id)))
|
|
(org-roam-node-open node)
|
|
(goto-char (point-min))
|
|
(search-forward (format "[[roam:%s]]" text))
|
|
(outline-show-all)))
|
|
|
|
(provide 'cce/missing-org-roam)
|
|
#+end_src
|