Skip to content
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

Typescript-xml polymode #320

Open
abeforgit opened this issue Jun 17, 2022 · 0 comments
Open

Typescript-xml polymode #320

abeforgit opened this issue Jun 17, 2022 · 0 comments

Comments

@abeforgit
Copy link

abeforgit commented Jun 17, 2022

It seems the emacs-default nxml-mode doesn't play nice with polymode, at least not with typescript-mode

My setup:

(define-hostmode poly-ts-hostmode
  :mode 'typescript-mode
  )
(define-innermode poly-xml-ts-innermode
  :mode 'xml-mode
  :head-matcher (rx "vdom`")
  :tail-matcher (rx "`")
  :head-mode 'host
  :tail-mode 'host
  )
(define-polymode poly-ts-xml-mode
  :hostmode 'poly-ts-hostmode
  :innermodes '(poly-xml-ts-innermode)
  )
(add-to-list 'auto-mode-alist '("\\.ts" . poly-ts-xml-mode))

(the head-matcher may seem weird but makes sense in my project)
(note: xml-mode is an alias for nxml-mode in modern emacs)

The syntax highlighting breaks completely. It considers the whole buffer to be xml, even though mode-switching does work for other functionality.

The setup works much better with sgml-mode, although sometimes highlighting only works for the first xml block, and the following errors appear in my modeline when I edit an xml block:

(jit-lock--run-functions 1172 1281) [span 1172 1281 insert-text-command-test.ts[sgml]] -> (font-lock-default-fontify-region 1172 1281): Args out of range: 1171, 1171

(insert-text-command-test.ts is the file I'm editing on this particular occasion)
They don't seem to break anything significant though.

So in summary: default xml-mode breaks syntax highlighting (but seems to work otherwise) and the old sgml-mode works, but with some jankiness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant