Feature Request: Link Metadata #25
Replies: 3 comments 18 replies
-
I think this is a great idea and one which I've also considered myself, and luckily react-force-graph has built in support for this kind of thing. The problem lies more in collecting that data, which org-roam does for us. If someone were to write a plugin for org-roam which adds this kind of information to the database we'd happily support this, but I don't see us doing this ourselves anytime soon. I'll convert this issue to a discussion as I'd be interested to hear what other think of this! |
Beta Was this translation helpful? Give feedback.
-
I looked at this and this seems to be not that difficult. We need 2 advices: ;;; Link properties (for 'id' links only).
;;; Adapted from https://linevi.ch/en/org-link-extra-attrs.html
(defun odm/org-link-extra-attrs (orig-fun &rest args)
"Post processor for parsing links"
(setq parser-result orig-fun)
;;; Retrieving inital values that should be replaced
(setq raw-path (plist-get (nth 1 parser-result) :raw-link))
;; Checking if link match the regular expression
(if (string-match-p "^id:.*|\s*:" raw-path)
(progn
;; Retrieving parameters after the vertical bar
(setq results (s-split "|" raw-path))
(setq raw-path (car results))
(setq path (s-chop-prefix "id:" raw-path))
;; Cleaning, splitting and making symbols
(setq results (s-split "\s" (s-trim (s-collapse-whitespace
(car (-slice results 1))))))
(setq results (--map (intern it) results))
;; Updating the ouput with the new values
(setq orig-fun-cleaned (plist-put (nth 1 orig-fun) :raw-link raw-path))
(setq orig-fun-cleaned (plist-put orig-fun-cleaned :path path))
;; Check that the number is even
(if (= 2 (length (-last-item (-partition-all 2 results))))
(list 'link (-snoc orig-fun-cleaned :extra-attrs results))
(progn
(message "Links properties are incorrect.")
(list 'link orig-fun-cleaned))))
;; Or returning original value of the function
orig-fun))
(advice-add 'org-element-link-parser :filter-return #'odm/org-link-extra-attrs)
(defun odm/org-roam-db-extra-properties (link)
"Append extra-attrs to the LINK's properties."
(save-excursion
(goto-char (org-element-property :begin link))
(let ((path (org-element-property :path link))
(source (org-roam-id-at-point))
(extra-attrs (org-element-property :extra-attrs link)))
(when extra-attrs
(setq properties (caar (org-roam-db-query
[:select properties :from links
:where (= source $s1) :and (= dest $s2)
:limit 1]
source path)))
(setq properties (append properties extra-attrs))
(when (and source path)
(org-roam-db-query
[:update links :set (= properties $s3)
:where (= source $s1) :and (= dest $s2)]
source path properties))))))
(advice-add 'org-roam-db-insert-link :after #'odm/org-roam-db-extra-properties) This adds a new syntax for links (backward compatible) and allows us to add link properties which are stored in the database. The syntax is: Does this look promising? |
Beta Was this translation helpful? Give feedback.
-
I was informed that my issue #132 is a duplicate of this discussion, however I'd like to compare the two proposed implementations as they are quite different and have their pros and cons. Property Drawer linksI'm modifying my implementation proposal relative to when I opened the issue. In the meantime I discovered org-edna which allows to define tasks dependencies for tasks which are not direct descendants of each other, defining new property drawers such as I think would be a pretty interesting addition to org-roam-ui, as one of the most important use cases of seeing a graph of new types of links are task dependencies. The syntax would be:
Several ids are allowed for a given link One disadvantage though is that links are only allowed as part of a heading, and only in a property drawer. Using links with extra attributes allows you to add context between two or more links, and how they relate to each other. Another disadvantage is that org-edna has more type of links than id-based and full compatibility would have to implement all these type of links, some being non-standard (for example Maybe this is out of scope for a org-roam-ui (more appropiate perhaps for "org-edna-ui"), but it's a tempting opportunity nonetheless. For further info on org-edna and graphs see Karl Voit's post |
Beta Was this translation helpful? Give feedback.
-
Is Your Feature Request Related To A Problem? Please Describe.
With notes often having many branches to other notes in many different contexts, it can be difficult to relate data in a meaningful way, understand what relevance certain links may have had, or simply be lost in a glut of links.
Describe The Solution You'd Like
Some additional fields for link metadata. This could be useful if one wanted to expand the depth of a network, but filter for certain conceptual links across wider regions of the networks. In other words, this can be used to capture wider bodies of knowledge or research themes.
for example:
[[<link id>][<link title>][:tags <tag> :context <short description>]]
Describe Alternatives You've Considered
A link-note that contains all the information as a separate entity. This could be viewed as a pop-up by hovering over the link and provide additional context.
Additional Context
Links between notes are almost as important as the notes themselves. There should be some kind of additional features that reflect this.
Beta Was this translation helpful? Give feedback.
All reactions