From fb46d45e0223a095c904983aebea3d40f8d1a8b9 Mon Sep 17 00:00:00 2001 From: Terje Larsen Date: Tue, 11 Jun 2024 22:47:29 +0200 Subject: [PATCH] fix: handling of d2-flags 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. --- d2-mode.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/d2-mode.el b/d2-mode.el index c308693..5d1e8c0 100644 --- a/d2-mode.el +++ b/d2-mode.el @@ -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) @@ -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)) @@ -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))))))