Subject: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes

From: João Távora <[email-masked]>
Date: Tue, 9 Jan 2024 11:05:55 +0000

On Tue, Jan 9, 2024 at 3:55 AM Stefan Monnier <[email-masked]> wrote:

> The mapping from "language" to major mode can't be always reversible, so
> `major-mode-remap-alist` works to map "language" to "major-mode" but not
> the other way.
>
> The current bug-report *is* about "finding the language" but the code
> that needs that info luckily doesn't need "the language"

I must be out of luck, because Eglot does need "the language" to send
as the LSP "languageID" to the server.

> which I propose to solve with `derived-mode-p`, since
> that's what we've been using all these years.

Even before your patch and before TS modes, derived-mode-p leads
to exposing Eglot users looking to customize eglot-server-programs to
much more complicated concepts.

If I could reliably write `get-language-for-mode`, this is much closer to
what they are really after:

    (ocaml "ocamllsp")
    (reason "ocamllsp")

Instead of

   (((caml-mode :language-id "ocaml")
     (tuareg-mode :language-id "ocaml") reason-mode) . ("ocamllsp"))

which is what is currently found in the Eglot database.  In fact
even if LSP languageID wasn't a thing, I still think it's easier to
customize on those terms.

It's also a fair bit simpler to.  And it'd be much simpler for
Yasnippet too.

João