(fix): improve error message on missing executable (#579)
This commit is contained in:
parent
1912beebc3
commit
9bc80ff9f7
1 changed files with 19 additions and 15 deletions
|
@ -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,19 +219,23 @@ 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
|
||||||
(let* ((node-query (or node-query
|
(user-error (concat "Cannot find executable "
|
||||||
`[:select [file titles]
|
(when name
|
||||||
:from titles
|
(format "\"%s\" " name))
|
||||||
,@(org-roam-graph--expand-matcher 'file t)]))
|
"to generate the graph. "
|
||||||
(graph (org-roam-graph--dot node-query))
|
"Please adjust `org-roam-graph-executable'")))
|
||||||
(temp-dot (make-temp-file "graph." nil ".dot" graph))
|
(let* ((node-query (or node-query
|
||||||
(temp-graph (make-temp-file "graph." nil ".svg")))
|
`[:select [file titles]
|
||||||
(call-process org-roam-graph-executable nil 0 nil
|
:from titles
|
||||||
temp-dot "-Tsvg" "-o" temp-graph)
|
,@(org-roam-graph--expand-matcher 'file t)]))
|
||||||
temp-graph))
|
(graph (org-roam-graph--dot node-query))
|
||||||
|
(temp-dot (make-temp-file "graph." nil ".dot" graph))
|
||||||
|
(temp-graph (make-temp-file "graph." nil ".svg")))
|
||||||
|
(call-process exec nil 0 nil temp-dot "-Tsvg" "-o" 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."
|
||||||
|
|
Loading…
Reference in a new issue