unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: rms@gnu.org
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Unifying "foo-mode"s and "foo-ts-mode"s
Date: Sun, 01 Jan 2023 09:28:39 +0200	[thread overview]
Message-ID: <83358u4st4.fsf@gnu.org> (raw)
In-Reply-To: <E1pBodf-0004h5-Mr@fencepost.gnu.org> (message from Richard Stallman on Sat, 31 Dec 2022 22:03:55 -0500)

> From: Richard Stallman <rms@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Sat, 31 Dec 2022 22:03:55 -0500
> 
> The use of tree-sitter logically ought to be a minor mode.

We tried to do it this way at first.  It didn't work well and had
significant difficulties, so we decided a separate major mode is a
better idea.  See below for some details; they were all discussed here
at the time (in October).

> We don't define c-mode and c-fl-mode to specify whether to enable Font
> Lock mode in a file of C code.  Rather, We have c-mode, plus another
> orthogonal command, font-lock-mode.

That is not the whole picture, as you know.  font-lock-mode just
activates the fontifications; the definitions of what to fontify and
how are the responsibility of the major mode.  These definitions are
completely different for tree-sitter based fontifications, as they are
not based on regexps and syntax tables.

And the features based on tree-sitter are not limited to
fontifications, they also support indentation, navigation by defun and
other language-dependent program components, and Imenu indices of
functions, structures, etc.  Each one of these needs to change quite a
few functions and variables of the particular major mode to switch
between tree-sitter and the "traditional" ways, and we also needed to
introduce a lot of new data structures that are not needed for the
"traditional" modes.

Adding all that to the existing modes would mean significant
complication of those existing modes (thus risking destabilizing
them), and would require no less than enthusiastic support from the
maintainers of those modes to get this done cleanly, safely, and in a
reasonable time.  I considered that to be "a bridge too far", and
instead decided to go with a safer, simpler alternative that we have
now.  This allowed us to add tree-sitter supported modes for quite a
few languages and file types in a very short time, and to do that
relatively cleanly.  Most importantly, those additions almost never
touch the modes for the same languages that existed before, thus
allowing us to introduce this new technology in a smooth way, leaving
it to the users to decide whether and when they want to try these new
modes.  This opt-in way is very important given the fact that distros
seem to not yet be organized well enough for providing the relevant
libraries for end-user installation.

> Likewise, the Emacs user interface ought to have another minor-mode
> command, tree-sitter-mode.
> 
> How it "really works" under the hood is another issue.
> 
> Users will be able to control the default for enabling tree-sitter in
> various major modes with the existing general mechanism that is used
> to control whether to enable Font Lodk mode and other minor modes: the
> major mode's mode hook.

This idealistic vision turned out not to work well enough in practice,
especially for large and complex major modes such as CC mode.  Many
settings and sub-features of the original mode make n o sense when
tree-sitter is used, and a huge amount of code based on regexps,
syntax-ppss, and ad-hoc algorithms needs to be bypassed or switched
off with tree-sitter.  It is impractical to do all that in a way that
both takes some reasonably short time and avoids a high risk of
breaking modes that have been working reasonably well for decades,
thus annoying users who may not even want to use tree-sitter.  I
couldn't allow such risky changes in Emacs 29, and I didn't want to
delay this to Emacs 30, which means another year r two.

So instead of turning on a local minor mode, users will have to invoke
a command that actually turns on a major mode.  FWIW, I don't see the
significant difference between these two alternatives, for the user
POV.  And it is quite possible that we will eventually decide to make
these minor modes, if we find a good way of combining them with the
major mode for the specific programming language.  But this is in the
future; we need first to collect user and maintenance experience,
without which there are too many questions and issues (some of which
are being raised already on this list) for which we have no good,
solid answers, only opinions based on information and experience
outside of Emacs, which from my POV are not necessarily valid for us.



  reply	other threads:[~2023-01-01  7:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29 17:08 Need for "-ts-mode" modes Philip Kaludercic
2022-12-29 17:42 ` Eli Zaretskii
2022-12-29 18:26   ` Philip Kaludercic
2022-12-29 19:27     ` Yuan Fu
2022-12-29 19:42       ` Eli Zaretskii
2022-12-30  4:05         ` Richard Stallman
2022-12-30  8:49           ` Eli Zaretskii
2022-12-29 19:57     ` Eli Zaretskii
2022-12-29 20:23       ` Eli Zaretskii
2022-12-30 10:58       ` Unifying "foo-mode"s and "foo-ts-mode"s Philip Kaludercic
2022-12-30 12:50         ` Theodor Thornhill
2022-12-30 13:08           ` Philip Kaludercic
2022-12-30 13:19             ` Theodor Thornhill
2022-12-30 15:02               ` Philip Kaludercic
2022-12-30 15:24                 ` Theodor Thornhill
2022-12-30 15:45                   ` Philip Kaludercic
2022-12-30 15:42                 ` Eli Zaretskii
2022-12-30 15:57                   ` Philip Kaludercic
2022-12-30 16:20                     ` Eli Zaretskii
2022-12-30 16:39                       ` Philip Kaludercic
2022-12-30 17:05                         ` Eli Zaretskii
2022-12-31  0:13                           ` Philip Kaludercic
2022-12-31  6:38                             ` Eli Zaretskii
2022-12-30 15:02         ` Eli Zaretskii
2022-12-30 15:20           ` Philip Kaludercic
2022-12-30 15:52             ` Eli Zaretskii
2022-12-30 16:09               ` Philip Kaludercic
2022-12-30 16:30                 ` Stefan Monnier
2022-12-30 17:03                   ` Eli Zaretskii
2023-01-01  3:03                   ` Richard Stallman
2023-01-01  7:28                     ` Eli Zaretskii [this message]
2023-01-03  4:07                       ` Richard Stallman
2023-01-03 12:11                         ` Eli Zaretskii
2023-01-05  3:34                           ` Richard Stallman
2022-12-30 17:10                 ` Gregory Heytings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83358u4st4.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).