Skip to content

Commit

Permalink
Enable coalton-mode as a submode inside coalton-toplevel in lisp-mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Jan 14, 2025
1 parent 476cce3 commit 46e2959
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion extensions/coalton-mode/coalton-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,10 @@
(variable-value 'insertion-line-comment) ";; "
(variable-value 'language-mode-tag) 'coalton-mode
(variable-value 'idle-function) 'coalton-idle-function)
(set-syntax-parser *syntax-table* (make-tmlanguage-coalton))
(lem-lisp-mode/internal::check-connection))

(set-syntax-parser *syntax-table* (make-tmlanguage-coalton))

(defun guess-current-position-package (point)
(with-point ((p point))
(loop
Expand Down Expand Up @@ -348,3 +349,21 @@
(defmethod execute :after ((mode coalton-mode) (command self-insert) argument)
(when (eql #\space (get-self-insert-char))
(lem-lisp-mode/autodoc:lisp-autodoc)))

(defun after-syntax-scan (start end)
(ignore-errors
(when (eq 'lem-lisp-mode:lisp-mode
(buffer-major-mode (point-buffer start)))
(with-point ((p start))
(loop while (lem:search-forward p "(coalton-toplevel" end)
unless (lem:in-string-or-comment-p p)
do (with-point ((start p))
(lem:scan-lists p -1 1)
(lem:scan-lists p 1 0)
(lem:character-offset p -1)
(set-region-major-mode start p 'coalton-mode)
(syntax-scan-region start p
:syntax-table *syntax-table*
:recursive-check nil)))))))

(add-hook (variable-value 'after-syntax-scan-hook :global) 'after-syntax-scan)

0 comments on commit 46e2959

Please sign in to comment.