branch: elpa/typst-ts-mode
commit eb2f385c16a4cebf2c3f109b641f2b8304e22c46
Merge: ed686468fc 01e0c737d2
Author: Meow King <mr.meowk...@posteo.com>
Commit: Meow King <mr.meowk...@posteo.com>

    Merge pull request 'Add output directory configuration option' (#44) from 
johannesneyer/typst-ts-mode:push-mqwkrrltqpmy into develop
    
    Reviewed-on: https://codeberg.org/meow_king/typst-ts-mode/pulls/44
---
 typst-ts-compile.el    | 10 ++++++++--
 typst-ts-watch-mode.el |  3 ++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/typst-ts-compile.el b/typst-ts-compile.el
index 6c73c68d24..f6f2af7c8b 100644
--- a/typst-ts-compile.el
+++ b/typst-ts-compile.el
@@ -37,6 +37,11 @@ The compile options will be passed to the end of
   :type 'string
   :group 'typst-ts)
 
+(defcustom typst-ts-output-directory ""
+  "User defined output directory for `typst-ts-compile` and `typst-ts-watch`."
+  :type 'string
+  :group 'typst-ts)
+
 (defcustom typst-ts-compile-before-compilation-hook nil
   "Hook runs after compile."
   :type 'hook
@@ -80,9 +85,10 @@ When using a prefix argument or the optional argument 
PREVIEW,
   (add-hook 'compilation-finish-functions
             (typst-ts-compile--compilation-finish-function (current-buffer)))
   (compile
-   (format "%s compile %s %s"
+   (format "%s compile %s %s %s"
            typst-ts-compile-executable-location
            (file-name-nondirectory buffer-file-name)
+           (typst-ts-compile-get-result-pdf-filename)
            typst-ts-compile-options)
    'typst-ts-compilation-mode))
 
@@ -93,7 +99,7 @@ CHECK: non-nil mean check the file existence.
 Return nil if the BUFFER has not associated file or the there is
 no compiled pdf file when CHECK is non-nil."
   (when-let ((typst-file (buffer-file-name buffer)))
-    (let ((res (concat (file-name-base typst-file) ".pdf")))
+    (let ((res (concat (file-name-as-directory typst-ts-output-directory) 
(file-name-base typst-file) ".pdf")))
       (if check
           (when (file-exists-p res)
             res)
diff --git a/typst-ts-watch-mode.el b/typst-ts-watch-mode.el
index ee1c5b1d02..e03303a286 100644
--- a/typst-ts-watch-mode.el
+++ b/typst-ts-watch-mode.el
@@ -130,9 +130,10 @@ PROC: process; OUTPUT: new output from PROC."
   (set-process-filter
    (start-process-shell-command
     typst-ts-watch-process-name typst-ts-watch-process-buffer-name
-    (format "%s watch %s %s"
+    (format "%s watch %s %s %s"
             typst-ts-compile-executable-location
             (file-name-nondirectory buffer-file-name)
+            (typst-ts-compile-get-result-pdf-filename)
             typst-ts-watch-options))
    'typst-ts--watch-process-filter)
   (message "Start Watch :3"))

Reply via email to