branch: elpa/typst-ts-mode commit 01b802534041a48e9ada024c92bb1971952870c9 Merge: 4abd0cd7fe b18c2a9f3b Author: Meow King <mr.meowk...@anche.no> Commit: Meow King <mr.meowk...@anche.no>
refactor!: split files && customizable options' name change --- README.md | 16 ++++++++-------- typst-ts-compile.el | 4 ++-- typst-ts-mode.el | 2 +- typst-ts-watch-mode.el | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index dc42c06188..69f324c77f 100644 --- a/README.md +++ b/README.md @@ -45,17 +45,17 @@ Example configuration. ## Keys -**C-c C-c c** : **typst-ts-mode-compile-and-preview** -**C-c C-c C** : **typst-ts-mode-compile** -**C-c C-c w** : **typst-ts-mode-watch-toggle** +**C-c C-c c** : **typst-ts-compile-and-preview** +**C-c C-c C** : **typst-ts-compile** +**C-c C-c w** : **typst-ts-watch-mode** **C-c C-c p** : **typst-ts-mode-preview** **M-<left>** : **typst-ts-mode-heading-decrease** **M-<right>** : **typst-ts-mode-heading-increase** **M-<up>** : **typst-ts-mode-heading-up** **M-<down>** : **typst-ts-mode-heading-down** -**TAB** : **typst-ts-mode-cycle** **M-<return>**: **typst-ts-mode-meta-return** **<return>** : **typst-ts-mode-return** +**TAB** : **typst-ts-mode-cycle** *NOTE*: `outline-minor-mode` is enabled by `typst-ts-mode`, so you can use command defined by `outline-minor-mode` such as `outline-cycle`. @@ -67,21 +67,21 @@ For customizable options: `customize` -> `typst-ts`. Here are some options you may find useful: 1. **typst-ts-mode-indent-offset** (default 4) Use [outline-indent-mode](https://sr.ht/~meow_king/outline-indent-mode/) to behave like `org-indent-mode`. -2. **typst-ts-mode-executable-location** +2. **typst-ts-compile-executable-location** 3. **typst-ts-watch-options**. Set this to `--open` so typst will open the compiled file for you. -4. **typst-ts-mode-compile-options**. +4. **typst-ts-compile-options**. Note that setting `--open` has no use for this customization variable. You can execute the shell command `typst compile <file> --open && sleep 1` to view what is happening. -5. **typst-ts-mode-display-watch-process-bufer-automatically**. (default `t`) +5. **typst-ts-watch-auto-display-compilation-error**. (default `t`) so the `typst watch` process buffer appear when an error occurs, and disappear when there is no error. You may find sometimes there is only one error at a time, and it is because Typst itself do this style. You may find `auto-save-visited-mode`, [auto-save](https://github.com/manateelazycat/auto-save) or [super-save](https://github.com/bbatsov/super-save) useful (or annoying). -6. **typst-ts-mode-before-compile-hook** and **typst-ts-mode-after-compile-hook** +6. **typst-ts-compile-before-compilation-hook** and **typst-ts-compile-after-compilation-hook** 7. **typst-ts-mode-return-autoincrement** autoincrement lists when pressing RETURN (default `t`). 8. **typst-ts-mode-grammar-location**: used for grammar version check (may not be accurate every time) diff --git a/typst-ts-compile.el b/typst-ts-compile.el index dbcac7be47..fc9a6b0cfa 100644 --- a/typst-ts-compile.el +++ b/typst-ts-compile.el @@ -86,8 +86,8 @@ If BUFFER is nil, it means use the current buffer. 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 buffer-file-name - (let ((res (concat (file-name-base (buffer-file-name buffer)) ".pdf"))) + (when-let ((typst-file (buffer-file-name buffer))) + (let ((res (concat (file-name-base typst-file) ".pdf"))) (if check (when (file-exists-p res) res) diff --git a/typst-ts-mode.el b/typst-ts-mode.el index a91271e6c2..e9f110dda5 100644 --- a/typst-ts-mode.el +++ b/typst-ts-mode.el @@ -925,7 +925,7 @@ When there is no section it will insert a heading below point." (defun typst-ts-mode-preview (file) "Open the result compile file. FILE: file path for the result compile file." - (interactive (typst-ts-compile-get-result-pdf-filename)) + (interactive (list (typst-ts-compile-get-result-pdf-filename))) ;; don't use `browse-url-of-file', which cannot open non-english documents (browse-url file)) diff --git a/typst-ts-watch-mode.el b/typst-ts-watch-mode.el index 3b0cb3b95f..14ca0e6be9 100644 --- a/typst-ts-watch-mode.el +++ b/typst-ts-watch-mode.el @@ -53,14 +53,14 @@ The compile options will be passed to the :type 'string :group 'typst-ts-watch) -(defcustom typst-ts-display-watch-process-bufer-automatically t +(defcustom typst-ts-watch-auto-display-compilation-error t "Whether the typst watch process buffer should be displayed automatically. This means the buffer will be displayed when error occurs, hide when error is eliminated." :type 'boolean :group 'typst-ts-watch) -(defcustom typst-ts-display-watch-process-buffer-parameters +(defcustom typst-ts-watch-display-buffer-parameters `(display-buffer-at-bottom (window-height . fit-window-to-buffer)) "Display buffer parameters." @@ -97,11 +97,11 @@ PROC: process; OUTPUT: new output from PROC." next-match-start-pos (match-end 0))) ;; Insert the Error text (if (not res-output) - (when (and typst-ts-display-watch-process-bufer-automatically window) + (when (and typst-ts-watch-auto-display-compilation-error window) (delete-window window)) (insert res-output) (goto-char (point-min)) - (when typst-ts-display-watch-process-bufer-automatically + (when typst-ts-watch-auto-display-compilation-error (typst-ts-watch-display-buffer))))))) ;;;###autoload @@ -112,7 +112,7 @@ PROC: process; OUTPUT: new output from PROC." (user-error "The typst watch process buffer %s is not alive!" typst-ts-watch-process-buffer-name) (display-buffer typst-ts-watch-process-buffer-name - typst-ts-display-watch-process-buffer-parameters))) + typst-ts-watch-display-buffer-parameters))) ;;;###autoload (defun typst-ts-watch-start ()