(fix): improve error message on missing executable (#579)

This commit is contained in:
Leo Vivier
2020-05-07 19:44:28 +02:00
committed by GitHub
parent 1912beebc3
commit 9bc80ff9f7

View File

@ -53,8 +53,8 @@ It may be one of the following:
(const :tag "view-file")) (const :tag "view-file"))
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-graph-executable (executable-find "dot") (defcustom org-roam-graph-executable "dot"
"Path to graphing executable." "Path to graphing executable, or its name."
:type 'string :type 'string
:group 'org-roam) :group 'org-roam)
@ -219,9 +219,14 @@ into a digraph."
(defun org-roam-graph--build (&optional node-query) (defun org-roam-graph--build (&optional node-query)
"Generate a graph showing the relations between nodes in NODE-QUERY." "Generate a graph showing the relations between nodes in NODE-QUERY."
(unless org-roam-graph-executable (let* ((name org-roam-graph-executable)
(user-error "Can't find %s executable. Please check if it is in your path" (exec (ignore-errors (executable-find name))))
org-roam-graph-executable)) (unless exec
(user-error (concat "Cannot find executable "
(when name
(format "\"%s\" " name))
"to generate the graph. "
"Please adjust `org-roam-graph-executable'")))
(let* ((node-query (or node-query (let* ((node-query (or node-query
`[:select [file titles] `[:select [file titles]
:from titles :from titles
@ -229,9 +234,8 @@ into a digraph."
(graph (org-roam-graph--dot node-query)) (graph (org-roam-graph--dot node-query))
(temp-dot (make-temp-file "graph." nil ".dot" graph)) (temp-dot (make-temp-file "graph." nil ".dot" graph))
(temp-graph (make-temp-file "graph." nil ".svg"))) (temp-graph (make-temp-file "graph." nil ".svg")))
(call-process org-roam-graph-executable nil 0 nil (call-process exec nil 0 nil temp-dot "-Tsvg" "-o" temp-graph)
temp-dot "-Tsvg" "-o" temp-graph) temp-graph)))
temp-graph))
(defun org-roam-graph--open (file) (defun org-roam-graph--open (file)
"Open FILE using `org-roam-graph-viewer' with `view-file' as a fallback." "Open FILE using `org-roam-graph-viewer' with `view-file' as a fallback."