branch: elpa/typst-ts-mode
commit 97ccb33aeb6e33066d3a451d94c68963a03217a3
Author: meowking <[email protected]>
Commit: meowking <[email protected]>
chore: prefix argument handling for `typst-ts-compile` command
https://codeberg.org/meow_king/typst-ts-mode/issues/21
---
typst-ts-compile.el | 12 +++++++++---
typst-ts-mode.el | 3 +--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/typst-ts-compile.el b/typst-ts-compile.el
index 38890eeaa1..225f725a1b 100644
--- a/typst-ts-compile.el
+++ b/typst-ts-compile.el
@@ -63,9 +63,15 @@ compilation buffer before compilation."
(remove-hook 'compilation-finish-functions
(typst-ts-compile--compilation-finish-function
cur-buffer)))))
-(defun typst-ts-compile ()
- "Compile current typst file."
- (interactive)
+(defun typst-ts-compile (&optional arg)
+ "Compile current typst file.
+When use a prefix argument, then preview the document after compilation.
+ARG: prefix argument."
+ (interactive "P")
+ (when arg
+ (add-hook 'compilation-finish-functions
+ (typst-ts-mode-compile-and-preview--compilation-finish-function
+ (current-buffer))))
(run-hooks typst-ts-compile-before-compilation-hook)
;; The reason to take such a awkward solution is that
`compilation-finish-functions'
diff --git a/typst-ts-mode.el b/typst-ts-mode.el
index b868bc2cfb..3b3032c666 100644
--- a/typst-ts-mode.el
+++ b/typst-ts-mode.el
@@ -605,8 +605,7 @@ FILE: file path for the result compile file."
;;;###autoload
(defvar-keymap typst-ts-mode-map
- "C-c C-c" #'typst-ts-compile-and-preview
- "C-u C-c C-c" #'typst-ts-compile
+ "C-c C-c" #'typst-ts-compile ; use prefix argument to do preview
"C-c C-w" #'typst-ts-watch-mode
"C-c C-p" #'typst-ts-mode-preview