GNU bug report logs - #68246
30.0.50; Add non-TS mode as extra parent of TS modes

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Thu, 4 Jan 2024 22:12:01 UTC

Severity: wishlist

Found in version 30.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #68 received at 68246 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 68246 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Yuan Fu <casouri <at> gmail.com>, monnier <at> iro.umontreal.ca
Subject: Re: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes
Date: Fri, 5 Jan 2024 23:37:46 +0000
On Fri, Jan 5, 2024 at 7:03 PM Stefan Kangas <stefankangas <at> gmail.com> wrote:
>
> João Távora <joaotavora <at> gmail.com> writes:
>
> > In summary, my position is that regardless of Stefan's patch, which
> > I'm not opposed to, we should:
> >
> > 1. Use add-derived-mode-parents sparingly and consider foo-base-mode when
> > possible.
>
> I agree that inheriting from a `foo-base-mode' is a good way to reuse
> code between different modes.  It's easy to think of examples of where
> this will be useful: looking up some documentation, running a REPL,
> interacting with a debugger, and so on and so forth.

Exactly.  It's much cleaner and I am happy to see exactly what
I had idealized is already in the tree.

> But even if we added all the base modes today (as empty stubs), AFAIU it
> wouldn't solve the exact problem that Monnier's patch is addressing,
> namely to make packages and customizations work in both foo-mode and
> foo-ts-mode even if they only say:
>
>     (derived-mode-p 'foo-mode)

That's why these packages should be changed to say

  (derived-mode-p 'foo-base-mode)

Or maybe

   (cl-some #'derived-mode-p '(foo-mode foo-base-mode))

I'm not sure there is a problem in doing that, is there?  I can confirm
there isn't in Eglot and Yasnippet, two packages that use major-mode
how Stefan Monnier described it.  How many more are there
and is it really so hard to change them?

Or is it that we're deliberately trying to establish that
'foo-mode' is the canonical symbol designating a family
of potentially many major modes -- including, somewhat
confusingly, 'foo-mode' itself -- that are used for editing foo
source code?

If so, fine, but this should be very well documented.  And yes,
definitely called out in *Help*.  The concept of "major-mode family"
could emerge, perhaps.

> So I'm not sure doing one excludes the other, or that one should be
> considered preferred over the other.  IOW, I'm not sure about the
> recommendation to use `add-derived-mode-parents' sparingly, as that
> would seem to defeat the point.

Indeed one may not exclude the other, depending on how feasible
it is for extensions to start using the foo-base-mode.

Maybe it depends what are these many packages that
use "major-mode" in such ways.

João




This bug report was last modified 1 year and 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.