(feature): allow customization of graphviz node appearance (#132)

This commit is contained in:
ffrigge
2020-02-20 10:43:30 +01:00
committed by GitHub
parent 8523fb43b4
commit b78b545d31

View File

@@ -123,6 +123,16 @@ If nil, always ask for filename."
:type 'string :type 'string
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-graph-max-title-length 100
"Maximum length of titles in graphviz graph nodes"
:type 'number
:group 'org-roam)
(defcustom org-roam-graph-node-shape "ellipse"
"Maximum length of titles in graphviz graph nodes"
:type 'string
:group 'org-roam)
;;; Polyfills ;;; Polyfills
;; These are for functions I use that are only available in newer Emacs ;; These are for functions I use that are only available in newer Emacs
@@ -507,10 +517,16 @@ Bindings:
(with-temp-buffer (with-temp-buffer
(insert "digraph {\n") (insert "digraph {\n")
(dolist (file (org-roam--find-all-files)) (dolist (file (org-roam--find-all-files))
(let ((title (org-roam--get-title-or-slug file)))
(let ((shortened-title (s-truncate org-roam-graph-max-title-length title)))
(insert (insert
(format " \"%s\" [URL=\"roam://%s\"];\n" (format " \"%s\" [label=\"%s\", shape=%s, URL=\"roam://%s\", tooltip=\"%s\"];\n"
(org-roam--get-title-or-slug file) title
file))) shortened-title
org-roam-graph-node-shape
file
title
)))))
(maphash (maphash
(lambda (from-link to-links) (lambda (from-link to-links)
(dolist (to-link to-links) (dolist (to-link to-links)