unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Tree-sitter and major mode inheritance
@ 2022-11-16 20:45 Yuan Fu
  2022-11-18 21:54 ` Suggesting that feature/tree-sitter be merged (was Re: Tree-sitter and major mode inheritance) Jostein Kjønigsen
  2022-11-19  9:41 ` Tree-sitter and major mode inheritance Yuan Fu
  0 siblings, 2 replies; 60+ messages in thread
From: Yuan Fu @ 2022-11-16 20:45 UTC (permalink / raw)
  To: emacs-devel

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


^ permalink raw reply	[flat|nested] 60+ messages in thread

end of thread, other threads:[~2022-11-20 22:57 UTC | newest]

Thread overview: 60+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-16 20:45 Tree-sitter and major mode inheritance Yuan Fu
2022-11-18 21:54 ` Suggesting that feature/tree-sitter be merged (was Re: Tree-sitter and major mode inheritance) Jostein Kjønigsen
2022-11-18 22:34   ` Philip Kaludercic
2022-11-18 22:58     ` Yuan Fu
2022-11-18 23:36       ` Stefan Monnier
2022-11-19  7:09       ` Philip Kaludercic
2022-11-19 14:07         ` Standardized access to a REPL (was: Suggesting that feature/tree-sitter be merged) Stefan Monnier
2022-11-19 15:03           ` Standardized access to a REPL Philip Kaludercic
2022-11-19 16:07             ` Stefan Monnier
2022-11-19 16:10               ` Philip Kaludercic
2022-11-19 16:18                 ` Eli Zaretskii
2022-11-19 22:31                   ` Stefan Monnier
2022-11-20  9:25                     ` Philip Kaludercic
2022-11-19  8:29     ` Suggesting that feature/tree-sitter be merged (was Re: Tree-sitter and major mode inheritance) Eli Zaretskii
2022-11-19 10:46       ` Philip Kaludercic
2022-11-19 11:36         ` Eli Zaretskii
2022-11-19 12:15           ` Philip Kaludercic
2022-11-19 13:05             ` Eli Zaretskii
2022-11-19 21:34         ` Dmitry Gutov
2022-11-18 22:52   ` Yuan Fu
2022-11-19  5:21     ` Theodor Thornhill
2022-11-19 18:35       ` Eli Zaretskii
2022-11-19 18:46         ` Theodor Thornhill
2022-11-19 18:51           ` Eli Zaretskii
2022-11-19 18:59             ` Theodor Thornhill
2022-11-19  7:36     ` Stefan Kangas
2022-11-19  8:09       ` Eli Zaretskii
2022-11-19 11:25         ` Stefan Kangas
2022-11-19 11:49           ` Theodor Thornhill
2022-11-19 12:03           ` Eli Zaretskii
2022-11-19  8:16   ` Eli Zaretskii
2022-11-19  9:41 ` Tree-sitter and major mode inheritance Yuan Fu
2022-11-19 10:26   ` Eli Zaretskii
2022-11-19 10:29     ` Po Lu
2022-11-19 15:19     ` Stefan Monnier
2022-11-19 17:17       ` Yuan Fu
2022-11-19 17:52         ` Eli Zaretskii
2022-11-19 21:45           ` Yuan Fu
2022-11-20  7:05             ` Eli Zaretskii
2022-11-20  0:38       ` Po Lu
2022-11-19 21:39     ` Dmitry Gutov
2022-11-19 21:49       ` Yuan Fu
2022-11-19 22:03         ` Dmitry Gutov
2022-11-19 22:36           ` Dmitry Gutov
2022-11-19 23:36             ` Yuan Fu
2022-11-19 23:42               ` Dmitry Gutov
2022-11-20  7:28                 ` Eli Zaretskii
2022-11-20 13:22                   ` Dmitry Gutov
2022-11-20 14:49                     ` Eli Zaretskii
2022-11-20 15:24                       ` Dmitry Gutov
2022-11-20  7:11           ` Eli Zaretskii
2022-11-20  9:19             ` Yuan Fu
2022-11-20 10:02               ` Eli Zaretskii
2022-11-20 22:57                 ` Yuan Fu
2022-11-20  7:05         ` Eli Zaretskii
2022-11-20 17:12           ` Dmitry Gutov
2022-11-20 17:34             ` Eli Zaretskii
2022-11-20  6:51       ` Eli Zaretskii
2022-11-20 12:45         ` Dmitry Gutov
2022-11-20 14:42           ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).