[Top][All Lists]

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

Re: Tree-sitter and major mode inheritance

From: Eli Zaretskii
Subject: Re: Tree-sitter and major mode inheritance
Date: Sun, 20 Nov 2022 09:05:12 +0200

> From: Yuan Fu <casouri@gmail.com>
> Date: Sat, 19 Nov 2022 13:45:41 -0800
> Cc: monnier@iro.umontreal.ca,
>  emacs-devel@gnu.org,
>  theo@thornhill.no
> > On Nov 19, 2022, at 9:52 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> > 
> >> From: Yuan Fu <casouri@gmail.com>
> >> Date: Sat, 19 Nov 2022 09:17:11 -0800
> >> Cc: Eli Zaretskii <eliz@gnu.org>,
> >> emacs-devel@gnu.org,
> >> theo@thornhill.no
> >> 
> >> If we are already renaming existing modes (cc-<foo>-mode), why don’t we 
> >> use the generic name <foo>-mode for the virtual parent mode? It would be 
> >> nicer if the generic mode (<foo>-mode) is an actual mode, with mode hooks, 
> >> keycaps, etc, rather than simply a dispatch function.
> > 
> > I already said that I prefer not to rename existing modes.  Such
> > renaming will break too many init files and other Lisp programs.
> I guess we can at least try it for a bit?

"Try" in what way?

> Because hook, keymaps, etc, should just work, that’s the point of major mode 
> inheritance, after all. C-native-mode will run all the setup for c-mode, plus 
> setup for c-native-mode.

Renaming public symbols is BAAAAD!  It causes breakage for many users and
Lisp programs.  It will either cause large-scale renaming of hooks, keymaps,
etc., which will break user init files; or it will cause confusion (because
a hook for cc-FOO-mode will be called cc-mode-hook and not the expected
cc-FOO-mode-hook).  And that is just the tip of the iceberg.

Why cannot we have the solution we already discussed and agreed upon:

  . modes that didn't exist before Emacs 29 will require tree-sitter
  . modes that existed before Emacs 29 will either
    - offer tree-sitter support as an optional feature, via a minor mode or
      a defcustom; or
    - add a completely new major mode with a different name that requires

If you need to add a FOO-base-mode to make it easier to share between
tree-sitter and non-tree-sitter modes features that are common to both, it's
fine with me to add such *-base-modes, but they should not be in any
auto-mode alist, and should generally be only an implementation detail
mostly hidden from users.

What is the problem with the above?  I thought we already agreed on that, so
how come this issue pops up time and again?

reply via email to

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