-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable coalton-mode inside coalton-toplevel
in lisp-mode.
#1747
Conversation
It appears that diff --git a/extensions/coalton-mode/coalton-mode.lisp b/extensions/coalton-mode/coalton-mode.lisp
index ba083762..dd7d0849 100644
--- a/extensions/coalton-mode/coalton-mode.lisp
+++ b/extensions/coalton-mode/coalton-mode.lisp
@@ -350,6 +350,7 @@
(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))
@@ -361,6 +362,7 @@
(lem:character-offset p -1)
(set-region-major-mode start p 'coalton-mode)
(syntax-scan-region start p
- :syntax-table *syntax-table*))))))
+ :syntax-table *syntax-table*
+ :recursive-check nil))))))) |
d32be80
to
46e2959
Compare
coalton-toplevel
in lisp-mode.coalton-toplevel
in lisp-mode.
@cxxxr Thanks! I've fixed it to work correctly. |
coalton-toplevel
in lisp-mode.coalton-toplevel
in lisp-mode.
@cxxxr Is it possible to make it work even if
I changed the code to scan a list backward, but it throws a control stack overflow at |
I sse, this worked. ❯ git diff -w
diff --git a/extensions/coalton-mode/coalton-mode.lisp b/extensions/coalton-mode/coalton-mode.lisp
index dede144d..a5559c6b 100644
--- a/extensions/coalton-mode/coalton-mode.lisp
+++ b/extensions/coalton-mode/coalton-mode.lisp
@@ -350,11 +350,15 @@
(when (eql #\space (get-self-insert-char))
(lem-lisp-mode/autodoc:lisp-autodoc)))
+(defvar *recursive* nil)
+
(defun after-syntax-scan (start end)
+ (unless *recursive*
(ignore-errors
(when (eq 'lem-lisp-mode:lisp-mode
(buffer-major-mode (point-buffer start)))
(with-point ((p start))
+ (lem-lisp-syntax:beginning-of-defun p -1)
(loop while (lem:search-forward p "(coalton-toplevel" end)
unless (lem:in-string-or-comment-p p)
do (with-point ((start p))
@@ -362,8 +366,9 @@
(lem:scan-lists p 1 0)
(lem:character-offset p -1)
(set-region-major-mode start p 'coalton-mode)
+ (let ((*recursive* t))
(syntax-scan-region start p
:syntax-table *syntax-table*
- :recursive-check nil)))))))
+ :recursive-check nil)))))))))
(add-hook (variable-value 'after-syntax-scan-hook :global) 'after-syntax-scan) |
Fantastic! Thank you! |
coalton-toplevel
in lisp-mode.coalton-toplevel
in lisp-mode.
Can I merge this PR? |
Absolutely, if it looks fine to you! |
Thank you for your support. 🙂 |
I need help to make coalton-mode work as a sub-mode of lisp-mode.I'm usingafter-syntax-scan-hook
to enable coalton-mode partially only insidecoalton-toplevel
, however it doesn't work for some reason.Enable
coalton-mode
(added in #1744) as a submode insidecoalton-toplevel
in lisp-mode.For example, in the following file, the type
Integer
should be highlighted even in lisp-mode.TODO
coalton-toplevel
by looking backward