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
|
||||
: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
|
||||
;; These are for functions I use that are only available in newer Emacs
|
||||
|
||||
@@ -505,21 +515,27 @@ Bindings:
|
||||
"Build graphviz graph output."
|
||||
(org-roam--ensure-cache-built)
|
||||
(with-temp-buffer
|
||||
(insert "digraph {\n")
|
||||
(dolist (file (org-roam--find-all-files))
|
||||
(insert
|
||||
(format " \"%s\" [URL=\"roam://%s\"];\n"
|
||||
(org-roam--get-title-or-slug file)
|
||||
file)))
|
||||
(maphash
|
||||
(lambda (from-link to-links)
|
||||
(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)))
|
||||
(insert "digraph {\n")
|
||||
(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
|
||||
(format " \"%s\" [label=\"%s\", shape=%s, URL=\"roam://%s\", tooltip=\"%s\"];\n"
|
||||
title
|
||||
shortened-title
|
||||
org-roam-graph-node-shape
|
||||
file
|
||||
title
|
||||
)))))
|
||||
(maphash
|
||||
(lambda (from-link to-links)
|
||||
(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 ()
|
||||
"Generate the org-roam graph in SVG format, and display it using `org-roam-graph-viewer'."
|
||||
|
Reference in New Issue
Block a user