(defun dmg-org-roam-danling-links (&optional limit)
(let (
(lim (or limit 25))
)
(unless (integerp lim)
(error "limit should be nil or an integer"))
(org-roam-db-query
(format
"
with dangling as
(select dest as dest
from links
where type in ('\"roam\"', '\"id\"')
except
select id from nodes)
select source, links.pos, links.dest, links.type, title, file
from dangling
natural join links
join nodes on (nodes.id = links.source)
where type in ('\"roam\"', '\"id\"')
limit %d
" lim)
)))
(defun org-dblock-write:dmg-org-roam-dangling-links (&optional params)
(let
((n (or (plist-get params :n) 20)) ; Default to 10 if :n is not provided
)
(insert "| source | destination|type |\n|--\n")
(insert
(mapconcat (lambda (link)
(pcase link
(`(,source ,pos ,dest ,type ,title ,file )
(format "| [[%s::%s][%s]]| [[%s:%s][%s]] |%s |\n"
file pos title
type dest dest
type)
)))
(dmg-org-roam-danling-links n)
))
(org-table-align)
(insert (concat "\nlast evaluated: " (current-time-string)))
))
org-dblock-write:dmg-org-roam-dangling-links
source | destination | type |
---|---|---|
2023-09-24 Sun | 2D4266F5-7418-4586-8092-40EC2C11F032 | id |
2024-04-15 Mon | bite-size-japanese | roam |
2022-08-04 | 444FFDD8-EB0B-46B5-8A01-D67F7C63DF14 | id |
computers | emacs | fuzzy |
last evaluated: Sat Jun 8 13:06:18 2024