Skip to content

Commit

Permalink
fix: handling of d2-flags
Browse files Browse the repository at this point in the history
They were only passed to the org babel execution and not to the regular
compile file command.

This also converts it to a list instead of a string in order to better
fit the call-process function.
  • Loading branch information
terlar committed Jun 11, 2024
1 parent cbe7b16 commit fb46d45
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions d2-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@
:group 'd2
:type 'string)

(defcustom d2-flags ""
(defcustom d2-flags nil
"Additional flags to pass to the d2-cli."
:group 'd2
:type 'string)
:type '(repeat string))

(defconst d2-font-lock-keywords
`((,(regexp-opt '("shape" "md" ) 'words) . font-lock-keyword-face)
Expand Down Expand Up @@ -117,7 +117,7 @@
(cmd (concat (shell-quote-argument d2-location)
" " temp-file
" " (org-babel-process-file-name out-file)
" " d2-flags)))
" " (string-join d2-flags " "))))
(with-temp-file temp-file (insert body))
(org-babel-eval cmd "")
nil))
Expand Down Expand Up @@ -163,10 +163,10 @@ Argument FILE-NAME the input file."
(interactive "fFilename: ")
(let* ((input file-name)
(output (concat (file-name-sans-extension input) d2-output-format)))
(apply #'call-process d2-location nil "*d2*" nil (list input output))
(apply #'call-process (shell-quote-argument d2-location) nil "*d2*" nil (append (list input output) d2-flags))
(if (equal browse t)
(progn
(d2-browse-file output))
(progn
(d2-browse-file output))
(progn
(display-buffer (find-file-noselect output t))))))

Expand Down

0 comments on commit fb46d45

Please sign in to comment.