From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: acm@muc.de, Eli Zaretskii <eliz@gnu.org>, 74339@debbugs.gnu.org
Subject: bug#74339: 30.0.92; CC Mode stomps C TS Mode
Date: Fri, 15 Nov 2024 19:46:03 +0000 [thread overview]
Message-ID: <Zzek-8RzhDQb5Bb5@MAC.fritz.box> (raw)
In-Reply-To: <jwvplmwqqv0.fsf-monnier+emacs@gnu.org>
Hello, Stefan.
On Fri, Nov 15, 2024 at 14:01:26 -0500, Stefan Monnier wrote:
> > One can write, in the Local Variables: section
> > mode: c-ts
> FWIW, unless this file is personal, this is very bad practice, and not
> only because `c-ts-mode` may not be available (in older Emacsen or if
> the user didn't build Emacs with tree-sitter support or doesn't have the
> appropriate grammar installed): the choice between `c-mode` and
> `c-ts-mode` is a personal preference, so it's not the file's business to
> tell the user which mode to use, just like it's not the file's business
> to tell the user which editor to use.
> There might be special situations where such a setting might be
> warranted, but they're sufficiently hypothetical or rare that they
> should not drive our decisions, as long as the users can still get the
> behavior they want in such cases (which they can, regardless of what we
> do with `major-mode-remap-defaults`).
Here is a section of a test file sent to bug-cc-mode some while ago:
/*
** Local Variables:
** mode:c
** indent-tabs-mode:nil
** c-basic-offset:4
** End:
*/
Here it is evident that by "mode:c" the OP means C Mode, not whatever
random mode happens to have taken the symbol `c-mode'.
> > .. This will cause the buffer to start in c-ts-mode regardless of any
> > other current settings.
> Actually, no: `major-mode-remap-*` can also remap `c-ts-mode` to some
> other mode, such as `c-mode`.
Maybe I should have said "regardless of any non-crazy settings".
> > .. When that line is followed by setting other CC Mode variables (as is
> > surely common for any such use of the major mode setting) that will
> > signal some sort of error on opening the buffer, should c-mode have been
> > "remapped" to c-ts-mode. Or if it doesn't do that, those local variables
> > will be disregarded. This is a Bad Thing.
> If you really insist, we can add
> (add-to-list 'major-mode-remap-defaults '(c-ts-mode . c-mode))
> (add-to-list 'major-mode-remap-defaults '(c++-ts-mode . c++-mode))
> to your `cc-mode.el` together with corresponding removals in
> `c-ts-mode.el`, even though in my book file-local settings of
> `mode: c-ts-mode` in non-personal files are just bugs.
The problem is that entries in major-mode-remap-defaults (and the other
one) do not accurately represent user preferences.
As a value for mode: in C files, we need three distinct settings: for C
Mode, for c-ts-mode, and for any mode which handles C. Currently we've
only got two: c-mode and c-ts-mode. This can't work properly.
> > ... there will be no way for a user to specify c-mode unambiguously ...
> Where/when? AFAICT the only case where this might be true are the cases
> where it does not do any damage.
In an auto-mode-alist entry, for example. As already discussed, in a
Local Variables: section, for another example.
> > OK, thanks. He is proposing that the meaning of -*- c -*-, `c-mode'
> > as used in normal-mode, etc., should, from the user's point of view,
> > be changed in an opt-out fashion. He is proposing that there be no
> > way to specify C Mode in a local variables section. Such changes
> > should be opt-in, not opt-out. They would certainly need an entry in
> > NEWS. if there's not already one there.
> It is supposed to opt-in, indeed.
So, for a user trying out Emacs 30, with a desktop file containing at
least one file with major mode c-ts-mode; visiting a file with the above
Local Variables section will indeed start the buffer with C Mode?
I haven't looked just yet, but can I assume there's a recipe in the
Emacs 30 NEWS file telling users how to switch between old behaviour
(-*- c -*- always means C mode) and new behaviour (-*- c -*- can mean
c-ts-mode depending on other settings)? Is the default to keep the old
behaviour, as is customary with new features in Emacs?
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2024-11-15 19:46 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-13 14:00 bug#74339: 30.0.92; CC Mode stomps C TS Mode Eli Zaretskii
2024-11-13 15:13 ` Eli Zaretskii
2024-11-13 18:58 ` Alan Mackenzie
2024-11-13 20:13 ` Eli Zaretskii
2024-11-13 22:34 ` Alan Mackenzie
2024-11-13 22:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 6:59 ` Eli Zaretskii
2024-11-14 9:24 ` Dmitry Gutov
2024-11-14 10:05 ` Eli Zaretskii
2024-11-16 20:54 ` Andrea Corallo
2024-11-14 15:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 16:29 ` Dmitry Gutov
2024-11-14 16:49 ` Eli Zaretskii
2024-11-14 17:16 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:10 ` Eli Zaretskii
2024-11-14 19:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 16:20 ` Alan Mackenzie
2024-11-14 16:59 ` Eli Zaretskii
2024-11-14 17:45 ` Alan Mackenzie
2024-11-14 17:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:23 ` Eli Zaretskii
2024-11-14 19:53 ` Alan Mackenzie
2024-11-14 20:21 ` Eli Zaretskii
2024-11-14 20:38 ` Alan Mackenzie
2024-11-14 21:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 21:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 8:17 ` Eli Zaretskii
2024-11-15 16:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 8:13 ` Eli Zaretskii
2024-11-15 7:33 ` Eli Zaretskii
2024-11-15 13:04 ` Alan Mackenzie
2024-11-15 14:43 ` Eli Zaretskii
2024-11-15 17:58 ` Alan Mackenzie
2024-11-15 19:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 19:46 ` Alan Mackenzie [this message]
2024-11-15 20:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 10:25 ` Eli Zaretskii
2024-11-16 14:03 ` Stefan Kangas
2024-11-16 14:35 ` Eli Zaretskii
2024-11-15 20:58 ` Stefan Kangas
2024-11-15 21:56 ` Alan Mackenzie
2024-11-16 3:22 ` Stefan Kangas
2024-11-16 11:45 ` Eli Zaretskii
2024-11-16 18:17 ` Alan Mackenzie
2024-11-16 6:17 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 8:18 ` Eli Zaretskii
[not found] ` <Zzi86KPmTv1Qb3nw@MAC.fritz.box>
[not found] ` <86ttc7f7jo.fsf@gnu.org>
2024-11-16 21:56 ` Alan Mackenzie
2024-11-17 6:31 ` Eli Zaretskii
2024-11-16 9:52 ` Eli Zaretskii
2024-11-15 18:57 ` Dmitry Gutov
2024-11-21 7:57 ` Eli Zaretskii
2024-11-21 13:57 ` Alan Mackenzie
2024-11-21 19:02 ` Dmitry Gutov
2024-11-21 19:48 ` Eli Zaretskii
2024-11-23 19:40 ` Eli Zaretskii
2024-11-24 2:56 ` Dmitry Gutov
2024-11-24 5:27 ` Eli Zaretskii
2024-11-25 1:16 ` Dmitry Gutov
2024-11-25 12:11 ` Eli Zaretskii
2024-11-25 23:40 ` Dmitry Gutov
2024-11-26 14:26 ` Eli Zaretskii
2024-11-26 22:06 ` Dmitry Gutov
2024-11-27 3:28 ` Eli Zaretskii
2024-11-27 12:34 ` Dmitry Gutov
2024-11-28 14:56 ` Eli Zaretskii
2024-11-24 15:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 16:01 ` Christopher Dimech via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-24 16:30 ` Eli Zaretskii
2024-11-24 16:27 ` Eli Zaretskii
2024-11-24 16:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-25 0:57 ` Dmitry Gutov
2024-11-24 4:35 ` Richard Stallman
2024-11-24 7:41 ` Eli Zaretskii
2024-11-14 17:29 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 19:20 ` Eli Zaretskii
2024-11-14 19:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 20:37 ` Eli Zaretskii
2024-11-14 20:58 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 22:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 12:02 ` Eli Zaretskii
2024-11-15 7:58 ` Eli Zaretskii
2024-11-15 16:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 20:51 ` Andrea Corallo
2024-11-13 20:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-13 20:42 ` Eli Zaretskii
2024-11-13 20:46 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=Zzek-8RzhDQb5Bb5@MAC.fritz.box \
--to=acm@muc.de \
--cc=74339@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).