mirror of
https://github.com/org-roam/org-roam
synced 2025-09-26 16:40:56 -05:00
(feature): allow customization of graphviz node appearance (#132)
This commit is contained in:
46
org-roam.el
46
org-roam.el
@@ -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
|
||||||
|
|
||||||
@@ -505,21 +515,27 @@ Bindings:
|
|||||||
"Build graphviz graph output."
|
"Build graphviz graph output."
|
||||||
(org-roam--ensure-cache-built)
|
(org-roam--ensure-cache-built)
|
||||||
(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))
|
||||||
(insert
|
(let ((title (org-roam--get-title-or-slug file)))
|
||||||
(format " \"%s\" [URL=\"roam://%s\"];\n"
|
(let ((shortened-title (s-truncate org-roam-graph-max-title-length title)))
|
||||||
(org-roam--get-title-or-slug file)
|
(insert
|
||||||
file)))
|
(format " \"%s\" [label=\"%s\", shape=%s, URL=\"roam://%s\", tooltip=\"%s\"];\n"
|
||||||
(maphash
|
title
|
||||||
(lambda (from-link to-links)
|
shortened-title
|
||||||
(dolist (to-link to-links)
|
org-roam-graph-node-shape
|
||||||
(insert (format " \"%s\" -> \"%s\";\n"
|
file
|
||||||
(org-roam--get-title-or-slug from-link)
|
title
|
||||||
(org-roam--get-title-or-slug to-link)))))
|
)))))
|
||||||
org-roam-forward-links-cache)
|
(maphash
|
||||||
(insert "}")
|
(lambda (from-link to-links)
|
||||||
(buffer-string)))
|
(dolist (to-link to-links)
|
||||||
|
(insert (format " \"%s\" -> \"%s\";\n"
|
||||||
|
(org-roam--get-title-or-slug from-link)
|
||||||
|
(org-roam--get-title-or-slug to-link)))))
|
||||||
|
org-roam-forward-links-cache)
|
||||||
|
(insert "}")
|
||||||
|
(buffer-string)))
|
||||||
|
|
||||||
(defun org-roam-show-graph ()
|
(defun org-roam-show-graph ()
|
||||||
"Generate the org-roam graph in SVG format, and display it using `org-roam-graph-viewer'."
|
"Generate the org-roam graph in SVG format, and display it using `org-roam-graph-viewer'."
|
||||||
|
Reference in New Issue
Block a user