org-roam-show-graph: PREFIX to generate a graph but not display it (#232)

This lets the viewer application watch the file, or have the user manually refresh the view rather than opening a new browser tab.
This commit is contained in:
Anthony Cowley
2020-03-05 22:22:39 -05:00
committed by GitHub
parent 09a23c377b
commit 8f83ffc2a3

View File

@@ -1113,9 +1113,10 @@ into a digraph."
(insert "}") (insert "}")
(buffer-string))) (buffer-string)))
(defun org-roam-show-graph () (defun org-roam-show-graph (&optional prefix)
"Displays the generated Org-roam graph using `org-roam-graph-viewer'." "Generates and displays the Org-roam graph using `org-roam-graph-viewer'.
(interactive) If PREFIX, then the graph is generated but the viewer is not invoked."
(interactive "P")
(declare (indent 0)) (declare (indent 0))
(unless org-roam-graphviz-executable (unless org-roam-graphviz-executable
(setq org-roam-graphviz-executable (executable-find "dot"))) (setq org-roam-graphviz-executable (executable-find "dot")))
@@ -1127,9 +1128,10 @@ into a digraph."
(with-temp-file temp-dot (with-temp-file temp-dot
(insert graph)) (insert graph))
(call-process org-roam-graphviz-executable nil 0 nil temp-dot "-Tsvg" "-o" temp-graph) (call-process org-roam-graphviz-executable nil 0 nil temp-dot "-Tsvg" "-o" temp-graph)
(if (and org-roam-graph-viewer (executable-find org-roam-graph-viewer)) (unless prefix
(call-process org-roam-graph-viewer nil 0 nil temp-graph) (if (and org-roam-graph-viewer (executable-find org-roam-graph-viewer))
(view-file temp-graph)))) (call-process org-roam-graph-viewer nil 0 nil temp-graph)
(view-file temp-graph)))))
;;; The global minor org-roam-mode ;;; The global minor org-roam-mode
(defvar org-roam-mode-map (defvar org-roam-mode-map