branch: elpa/typst-ts-mode
commit 9c7f17dfdf7c9cd990d428ff56b54b007615c639
Author: Huan Thieu Nguyen <nguyenthieuh...@gmail.com>
Commit: Huan Thieu Nguyen <nguyenthieuh...@gmail.com>

    feat: custom auto-fill function #27
    
    not hook to set it on auto-fill-mode yet.
---
 typst-ts-editing.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/typst-ts-editing.el b/typst-ts-editing.el
index 6cbca0b0d4..c626bd8ac5 100644
--- a/typst-ts-editing.el
+++ b/typst-ts-editing.el
@@ -472,6 +472,14 @@ When there is no section it will insert a heading below 
point."
     (unless (eq execute-result 'success)
       (call-interactively (global-key-binding (kbd "TAB"))))))
 
+(defun typst-ts-mode-auto-fill-function ()
+  "Function for `auto-fill-mode'.
+
+Inserts newline and indents according to context."
+  (when (>= (current-column) (current-fill-column))
+    (insert "\n")
+    (typst-ts-mode-indent-line-function)))
+
 (provide 'typst-ts-editing)
 
 ;;; typst-ts-editing.el ends here

Reply via email to