4 ms·
Of course, now that tree-sitter is embedded in the upcoming Emacs 29, expect even better support than polymode to emerge over time as you can dole out parcels o
by mickeyp 4y ago
Of course, now that tree-sitter is embedded in the upcoming Emacs 29, expect even better support than polymode to emerge over time as you can dole out parcels of your buffer to different language parsers.
- KRAKRISMOTT 4y agoHow does the language detection work?
- accoil 4y agoWhen adding languages you define a function/regex to match the start and end positions of each language block. Polymode then scans the document, and runs the matchers. e.g this matches markdown code blocks (and also extracts the language from the start to select the mode to run) (define-auto-innermode poly-markdown-fenced-code-innermode :head-matcher (cons "^[ \t]*\\(```{?[[:alpha:]].*\n\\)" 1) :tail-matcher (cons "^[ \t]*\\(```\\)[ \t]*$" 1) :mode-matcher (cons "```[ \t]*{?\\(?:lang *= *\\)?\\([^ \t\n;=,}]+\\)" 1) :head-mode 'host :tail-mode 'host) ( via https://polymode.github.io/defining-polymodes/ https://polymode.github.io/defining-polymodes/ )