A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://lists.gnu.org/archive/html/emacs-devel/2022-11/msg01084.html below:

Tree-sitter and major mode inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] From: Yuan Fu Subject: Tree-sitter and major mode inheritance Date: Wed, 16 Nov 2022 12:45:30 -0800
So I’m trying to merge css-ts-mode with css-mode. Scss-mode inherits css-mode, 
but if user enables tree-sitter for css-mode, scss-mode will inherit all that 
tree-sitter setup, and lose all the native css setup. Then if a user doesn’t 
want to enable tree-sitter in scss-mode, too bad: scss-mode breaks.

Essentially scss-mode needs to be able to control which parts of css-mode’s 
setup it wants to inherit—native setup or tree-sitter setup—regardless of 
whether css-mode enables tree-sitter or not.

I wonder if we can do something like this:

             css-mode
                 |
       +---------+-----+-----------+
       |               |           |
css-native-mode   css-ts-mode  scss-mode
                                   |
                              +----+------------+
                              |                 |
                        scss-native-mode   scss-ts-mode

css-mode: a virtual mode, only sets up basic things that both native and 
tree-sitter mode needs, like comment-start.
css-native-mode: native setup
css-ts-mode: tree-sitter setup

scss-mode: a virtual mode, inherits css-mode
scss-native-mode: native setup
scss-ts-mode: tree-sitter setup

And user could use major-mode-remap-alist to choose which mode they want:

(css-mode . css-ts-mode) for enabling tree-sitter
(css-mode . css-native-mode) for not enabling tree-sitter

This could also used for other modes, like c-mode: c-mode, c-native-mode 
(cc-mode), c-ts-mode.

Yuan


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4