mirror of
https://github.com/org-roam/org-roam
synced 2025-08-03 12:27:23 -05:00
(feat): add org-roam-graph-edge-extra-config (#435)
Introduces `org-roam-graph-edge-extra-config` to add options to edges
This commit is contained in:
@ -11,6 +11,7 @@
|
|||||||
* [#374][gh-374] Add support for `org-ref` `cite:` links
|
* [#374][gh-374] Add support for `org-ref` `cite:` links
|
||||||
* [#380][gh-380] Allow `org-roam-buffer-position` to also be `top` or `bottom`
|
* [#380][gh-380] Allow `org-roam-buffer-position` to also be `top` or `bottom`
|
||||||
* [#385][gh-385] Add `org-roam-graph-node-extra-config` to configure Graphviz nodes
|
* [#385][gh-385] Add `org-roam-graph-node-extra-config` to configure Graphviz nodes
|
||||||
|
* [#435][gh-435] Add `org-roam-graph-edge-extra-config` to configure Graphviz edges
|
||||||
|
|
||||||
## 1.0.0 (23-03-2020)
|
## 1.0.0 (23-03-2020)
|
||||||
|
|
||||||
|
@ -67,6 +67,13 @@ Example:
|
|||||||
:type '(alist)
|
:type '(alist)
|
||||||
:group 'org-roam)
|
:group 'org-roam)
|
||||||
|
|
||||||
|
(defcustom org-roam-graph-edge-extra-config nil
|
||||||
|
"Extra options for graphviz edges.
|
||||||
|
Example:
|
||||||
|
'((\"dir\" . \"back\"))"
|
||||||
|
:type '(alist)
|
||||||
|
:group 'org-roam)
|
||||||
|
|
||||||
(defcustom org-roam-graph-max-title-length 100
|
(defcustom org-roam-graph-max-title-length 100
|
||||||
"Maximum length of titles in graph nodes."
|
"Maximum length of titles in graph nodes."
|
||||||
:type 'number
|
:type 'number
|
||||||
@ -134,22 +141,33 @@ into a digraph."
|
|||||||
:where (and (in to selected) (in from selected))])
|
:where (and (in to selected) (in from selected))])
|
||||||
(edges (org-roam-db-query edges-query)))
|
(edges (org-roam-db-query edges-query)))
|
||||||
(insert "digraph \"org-roam\" {\n")
|
(insert "digraph \"org-roam\" {\n")
|
||||||
|
|
||||||
(dolist (option org-roam-graph-extra-config)
|
(dolist (option org-roam-graph-extra-config)
|
||||||
(insert (concat (car option)
|
(insert (concat " "
|
||||||
|
(car option)
|
||||||
"="
|
"="
|
||||||
(cdr option)
|
(cdr option)
|
||||||
";\n")))
|
";\n")))
|
||||||
|
(insert (format " node [%s];\n"
|
||||||
|
(->> org-roam-graph-node-extra-config
|
||||||
|
(mapcar (lambda (n)
|
||||||
|
(concat (car n) "=" (cdr n))))
|
||||||
|
(s-join ","))))
|
||||||
|
(insert (format " edge [%s];\n"
|
||||||
|
(->> org-roam-graph-edge-extra-config
|
||||||
|
(mapcar (lambda (n)
|
||||||
|
(concat (car n) "=" (cdr n))))
|
||||||
|
(s-join ","))))
|
||||||
|
|
||||||
(dolist (node nodes)
|
(dolist (node nodes)
|
||||||
(let* ((file (xml-escape-string (car node)))
|
(let* ((file (xml-escape-string (car node)))
|
||||||
(title (or (caadr node)
|
(title (or (caadr node)
|
||||||
(org-roam--path-to-slug file)))
|
(org-roam--path-to-slug file)))
|
||||||
(shortened-title (s-truncate org-roam-graph-max-title-length title))
|
(shortened-title (s-truncate org-roam-graph-max-title-length title))
|
||||||
(base-node-properties (list (cons "label" (s-replace "\"" "\\\"" shortened-title))
|
(node-properties (list (cons "label" (s-replace "\"" "\\\"" shortened-title))
|
||||||
(cons "URL" (concat "org-protocol://roam-file?file="
|
(cons "URL" (concat "org-protocol://roam-file?file="
|
||||||
(url-hexify-string file)))
|
(url-hexify-string file)))
|
||||||
(cons "tooltip" (xml-escape-string title))))
|
(cons "tooltip" (xml-escape-string title)))))
|
||||||
(node-properties (append base-node-properties
|
|
||||||
org-roam-graph-node-extra-config)))
|
|
||||||
(insert
|
(insert
|
||||||
(format " \"%s\" [%s];\n"
|
(format " \"%s\" [%s];\n"
|
||||||
file
|
file
|
||||||
|
Reference in New Issue
Block a user