Skip to content

Commit

Permalink
Merge pull request #48 from terlar/main
Browse files Browse the repository at this point in the history
fix: handling of d2-flags
  • Loading branch information
andorsk authored Jul 1, 2024
2 parents cbe7b16 + 855fc5c commit 6dc1ae9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 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 All @@ -114,10 +114,12 @@
(let* ((out-file (or (cdr (assoc :file params))
(error "D2 requires a \":file\" header argument")))
(temp-file (org-babel-temp-file "d2-"))
(cmd (concat (shell-quote-argument d2-location)
" " temp-file
" " (org-babel-process-file-name out-file)
" " d2-flags)))
(cmd (mapconcat #'shell-quote-argument
(append (list d2-location
temp-file
(org-babel-process-file-name out-file))
d2-flags)
" ")))
(with-temp-file temp-file (insert body))
(org-babel-eval cmd "")
nil))
Expand Down Expand Up @@ -163,10 +165,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 6dc1ae9

Please sign in to comment.