emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree sitter: Should *-ts-modes derive from a common base?


From: João Távora
Subject: Re: Tree sitter: Should *-ts-modes derive from a common base?
Date: Sat, 25 Mar 2023 09:16:22 +0000

On Wed, Mar 22, 2023 at 7:32 AM Dmitry Gutov <dgutov@yandex.ru> wrote:
>
> On 21/03/2023 11:30, Phil Sainty wrote:
> > 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.
>
> How would you refactor it? We don't have multiple inheritance.

There are many mechanisms of code reuse besides inheritance.
In lisp-based modes there is the the lisp-mode-variables, for
example.  So IMO it's fine to use a combination of single
inheritance and such a mechanism.

Phil's idea is very pertinent and should be addressed sooner
not later, because the potential for messy duplicated code or
just misinheritance is high later down the road.  The lisp-mode
fiasco comes to mind.

João



reply via email to

[Prev in Thread] Current Thread [Next in Thread]