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 #364 received at 68246 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Stefan Kangas <stefankangas <at> gmail.com>
Cc: 68246 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, casouri <at> gmail.com,
 joaotavora <at> gmail.com
Subject: Re: bug#68246: 30.0.50; Add non-TS mode as extra parent of TS modes
Date: Wed, 17 Jan 2024 05:45:34 +0200
On 16/01/2024 04:32, Stefan Monnier via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
>>> Please don't call it "language".  That'd be confusing.  LSP is about
>>> programming languages, so "language" is natural there.  But in Emacs,
>>> a major mode is more general than that.  For example, it is not
>>> unthinkable to consider mail-mode to be the extra-parent of
>>> message-mode (or vice versa) -- but what is the "language" in that
>>> case?
>> Isn't the language for such modes in this paradigm just the empty set?
> 
> I'm not too worried about those cases, indeed.
> I'm more worried about the taxonomy of languages.
> We currently have the taxonomy of major modes, with which we're pretty
> familiar, and we've had many years to learn about its downsides,
> complexity, as well as how to deal with them, but for languages we're
> only familiar with the easy cases, which makes us judge the idea in
> a way that may prove naive.

Some of us perhaps familiar with more cases than others.

> IME, deciding what is the type of the content of a buffer is usually
> trivial but with some notable caveats, such as XPM or Postscript files,
> or "container formats" (like `.deb` or `.odt`, as well as things like
> DocBook which can be considered either as their own format or as XML),

Sounds like DocBook could be viewed using different major modes. I'm not 
sure whether they should be classified as different languages in general 
in such cases, but here is sounds like :doc_book vs :xml.

> or "sublanguages" such as C being a subset of C++, or Javascript being
> a subset of Typescript.  And I suspect the info we need will not always
> be quite the same.

So far my understanding is that "languages" would not have a hierarchy - 
no relation of being a "subset" or etc, because different applications 
will likely need different relations between such languages. Or none at 
all, most of the time.

When a major mode is suitable for a number of languages, it can be 
expressed externally, e.g. using several entries in major-mode-alist-alist.

> So while there might be a good case to be made to add some API functions
> to query the language/type(s) of a given buffer (I'm not sure we'd need
> the language of a given major mode, OTOH), or to find the preferred
> mode(s) for a given language/type, I think it's worthwhile to try and
> tweak our major mode taxonomy because it is information we must have
> and information we know we will always have, so we should strive to make
> it as good as we can.
> 
> It shouldn't make it any harder to add language/type API functionality.
> On the contrary it should make it easier.
> 
> [ As suggested elsewhere in this thread, we could even try and merge
>    those taxonomies, e.g. using extra parents of the form `LANG-lang`.  ]

Inserting an extra parent called LANG-lang could work to contain the 
(mode->lang) mapping, but only if we decide that a mode can correspond 
to only one language, or if we are not going to run the language hook in 
the mode function. But if we don't, the extra complexity seems not worth 
it: we'll need the lang->mode mapping somewhere else anyway. And looking 
there (in major-mode-remap-alist) we could fetch the reverse relation 
just as well.

This also wouldn't bring any of the other features I enumerated together 
with my patch.




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.