(feat): Add org-roam-graph-node-extra-config (#385)

org-roam-graph-node-extra-config is an alist containing additional node
configuration options, as per
https://graphviz.gitlab.io/_pages/doc/info/attrs.html

This also deprecates org-roam-graph-node-shape, which is a special case
of the node options
This commit is contained in:
Jethro Kuan
2020-04-01 11:36:24 +08:00
committed by GitHub
parent 2e3119e027
commit e4f77eb586
2 changed files with 28 additions and 7 deletions

View File

@ -2,10 +2,14 @@
## 1.0.1 (TBD)
### Breaking Changes
* [#385][gh-385] Deprecate `org-roam-graph-node-shape` in favour of `org-roam-graph-node-extra-config`.
### New Features
* [#350][gh-350] Add `org-roam-db-location`
* [#359][gh-359] Add `org-roam-verbose`
* [#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
## 1.0.0 (23-03-2020)
@ -157,6 +161,9 @@ Mostly a documentation/cleanup release.
[gh-296]: https://github.com/jethrokuan/org-roam/pull/296
[gh-350]: https://github.com/jethrokuan/org-roam/pull/350
[gh-359]: https://github.com/jethrokuan/org-roam/pull/359
[gh-380]: https://github.com/jethrokuan/org-roam/pull/380
[gh-385]: https://github.com/jethrokuan/org-roam/pull/385
# Local Variables:
# eval: (auto-fill-mode -1)

View File

@ -56,12 +56,19 @@
(make-obsolete-variable 'org-roam-graphviz-extra-options 'org-roam-graph-extra-config "2020/03/31")
(make-obsolete-variable 'org-roam-grapher-extra-options 'org-roam-graph-extra-config "2020/03/31")
(defcustom org-roam-graph-extra-config nil
"Extra options passed to the graphing executable.
"Extra options passed to graphviz.
Example:
'((\"rankdir\" . \"LR\"))"
:type '(alist)
:group 'org-roam)
(defcustom org-roam-graph-node-extra-config nil
"Extra options for graphviz nodes.
Example:
'((\"color\" . \"skyblue\"))"
:type '(alist)
:group 'org-roam)
(defcustom org-roam-graph-max-title-length 100
"Maximum length of titles in graph nodes."
:type 'number
@ -81,6 +88,7 @@ are excluded."
(list :tag "Matchers"))
:group 'org-roam)
(make-obsolete-variable 'org-roam-graph-node-shape 'org-roam-graph-node-extra-config "2020/04/01")
(defcustom org-roam-graph-node-shape "ellipse"
"Shape of graph nodes."
:type 'string
@ -140,14 +148,20 @@ into a digraph."
(let* ((file (xml-escape-string (car node)))
(title (or (caadr node)
(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))
(cons "URL" (concat "org-protocol://roam-file?file="
(url-hexify-string file)))
(cons "tooltip" (xml-escape-string title))))
(node-properties (append base-node-properties
org-roam-graph-node-extra-config)))
(insert
(format " \"%s\" [label=\"%s\", shape=%s, URL=\"org-protocol://roam-file?file=%s\", tooltip=\"%s\"];\n"
(format " \"%s\" [%s];\n"
file
(s-replace "\"" "\\\"" shortened-title)
org-roam-graph-node-shape
(url-hexify-string file)
(xml-escape-string title)))))
(->> node-properties
(mapcar (lambda (n)
(concat (car n) "=" "\"" (cdr n) "\"")))
(s-join ","))))))
(dolist (edge edges)
(insert (format " \"%s\" -> \"%s\";\n"
(xml-escape-string (car edge))