branch: elpa/typst-ts-mode
commit b5106cb7da3a7c7faf5981a019ebaa94555a102e
Author: Valentino Slavkin <vslv...@proton.me>
Commit: Valentino Slavkin <vslv...@proton.me>

    Improved `typst-ts-preview`, deleted redundant code
---
 typst-ts-compile.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/typst-ts-compile.el b/typst-ts-compile.el
index a447550e9f..59e6ad0b97 100644
--- a/typst-ts-compile.el
+++ b/typst-ts-compile.el
@@ -107,7 +107,7 @@ CUR-BUFFER: original typst buffer, in case user set
 buffer before compilation."
   (lambda (_b _msg)
     (unwind-protect
-        (browse-url (typst-ts-compile-get-result-pdf-filename cur-buffer))
+        (typst-ts-preview cur-buffer)
       (remove-hook 'compilation-finish-functions
                    
(typst-ts-mode-compile-and-preview--compilation-finish-function cur-buffer)))))
 
@@ -119,8 +119,11 @@ Assuming the compile output file name is in default style."
   (typst-ts-compile t))
 
 ;;;###autoload
-(defun typst-ts-preview ()
-  "Preview the current typst document output."
+(defun typst-ts-preview (&optional buffer)
+  "Preview the typst document output.
+If BUFFER is passed, preview its output, otherwise use current buffer."
+  (interactive)
+  (unless buffer (setq buffer #'current-buffer))
   (browse-url (typst-ts-compile-get-result-pdf-filename #'current-buffer))
   )
 

Reply via email to