[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tree sitter: Should *-ts-modes derive from a common base?
From: |
Phil Sainty |
Subject: |
Tree sitter: Should *-ts-modes derive from a common base? |
Date: |
Tue, 21 Mar 2023 22:30:52 +1300 |
User-agent: |
Orcon Webmail |
WRT
https://emacs.stackexchange.com/questions/76400/how-do-i-check-if-the-current-buffer-has-a-treesit-parser
I wondered whether derived-mode-p could conveniently establish
some kind of base ts-mode, but that doesn't appear to be the case
(or at least not for the examples I looked at).
I was pondering something like this:
(define-derived-mode prog-ts-mode prog-mode "Prog(TS)"
"Major mode for editing source code with tree-sitter support.")
And then all the *-ts-mode derivatives of prog-mode changed like so:
- (define-derived-mode cmake-ts-mode prog-mode "CMake"
+ (define-derived-mode cmake-ts-mode prog-ts-mode "CMake"
The case I've spotted thus far which wouldn't work is the CSS modes,
where we have this:
(define-derived-mode css-base-mode prog-mode "CSS"
(define-derived-mode css-mode css-base-mode "CSS"
(define-derived-mode css-ts-mode css-base-mode "CSS"
That could be refactored if this idea was a sensible one.
Apologies if this has been discussed before... it seems like
something which might have come up, but I couldn't find anything
relevant. I'm not across the tree-sitter work in general though,
and maybe this is a bad idea for some reason.
-Phil
- Tree sitter: Should *-ts-modes derive from a common base?,
Phil Sainty <=