From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dmitry@gutov.dev, emacs-devel@gnu.org
Subject: Re: Turning on/off tree-sitter modes
Date: Tue, 03 Dec 2024 09:55:55 -0500 [thread overview]
Message-ID: <jwvjzcgesel.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <86wmgg26rt.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 03 Dec 2024 16:14:14 +0200")
>> >> Do you have a concrete example?
>> >
>> > cmake-ts-mode, dockerfile-ts-mode, elixir-ts-mode, lua-ts-mode, to
>> > name just a few. Basically any FOO-ts-mode for which we don't have a
>> > corresponding FOO-mode.
>>
>> Let's take the `cmake-ts-mode` as an example, then.
>> I consider it currently broken:
>>
>> emacs -Q foo.cmake
>>
>> should put you in `cmake-ts-mode` when you have the CMake
>> tree-sitter grammar installed, but instead it remains in
>> fundamental-mode.
>>
>> Until this is fixed I don't see any sense in discussing how the users
>> can specify whether they prefer `cmake-mode` or `cmake-ts-mode`.
>
> I think we are mis-communicating. This thread's Subject is "Turning
> on/off tree-sitter modes", so I'm asking: what we will tell users to
> to do if they want to turn ON cmake-ts-mode?
And the answer depends on how we fix the current breakage, but most
likely it will be "same as for other modes, except doing nothing works
as well"?
> I didn't mean to say anything about the imaginary cmake-mode, I meant
> to point out that it doesn't exist in Emacs, so our solution to this
> cannot be based solely on major-mode-remap-defaults/alist.
Why not?
One way to fix the current breakage is with a patch like the one below,
after which the way to choose which CMake mode to use is the same as for
any other mode.
Stefan
diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el
index 597ef69d9b8..bf713fff2ae 100644
--- a/lisp/progmodes/cmake-ts-mode.el
+++ b/lisp/progmodes/cmake-ts-mode.el
@@ -245,8 +245,22 @@ cmake-ts-mode
(derived-mode-add-parents 'cmake-ts-mode '(cmake-mode))
(if (treesit-ready-p 'cmake)
- (add-to-list 'auto-mode-alist
- '("\\(?:CMakeLists\\.txt\\|\\.cmake\\)\\'" . cmake-ts-mode)))
+ (add-to-list 'major-mode-remap-defaults '(cmake-mode . cmake-ts-mode)))
+
+;;;###autoload (add-to-list 'auto-mode-alist
+;;;###autoload '("\\(?:CMakeLists\\.txt\\|\\.cmake\\)\\'"
+;;;###autoload . cmake-mode))
+
+;;;###autoload (add-to-list 'major-mode-remap-defaults
+;;;###autoload '(cmake-mode . cmake-ts-mode-maybe))
+
+;;;###autoload
+(defun cmake-ts-mode-maybe ()
+ "Enable `cmake-ts-mode' if available."
+ (cond
+ ((treesit-ready-p 'cmake) (cmake-ts-mode))
+ ((fboundp 'cmake-mode) (cmake-mode))
+ (t (fundamental-mode))))
(provide 'cmake-ts-mode)
next prev parent reply other threads:[~2024-12-03 14:55 UTC|newest]
Thread overview: 182+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-06 7:32 An anonymous IRC user's opinion Abraham S.A.H. via Emacs development discussions.
2024-10-06 8:10 ` Emanuel Berg
2024-10-06 8:44 ` Dr. Arne Babenhauserheide
2024-10-06 9:01 ` Emanuel Berg
2024-10-06 9:09 ` Emanuel Berg
2024-10-06 9:32 ` Abraham S.A.H. via Emacs development discussions.
2024-10-06 11:28 ` Dr. Arne Babenhauserheide
2024-10-06 13:10 ` Emanuel Berg
2024-10-06 12:55 ` Emanuel Berg
2024-10-09 3:29 ` Richard Stallman
2024-10-09 20:20 ` Emanuel Berg
2024-10-10 8:57 ` Dr. Arne Babenhauserheide
2024-10-09 3:30 ` Richard Stallman
2024-10-09 6:48 ` Dr. Arne Babenhauserheide
2024-10-09 20:22 ` Emanuel Berg
2024-10-09 11:09 ` Johan Myréen
2024-10-09 13:13 ` Eli Zaretskii
2024-10-09 13:38 ` tomas
2024-10-09 16:02 ` Dr. Arne Babenhauserheide
2024-10-09 16:22 ` Eli Zaretskii
2024-10-09 21:55 ` Emanuel Berg
2024-10-10 7:25 ` Eli Zaretskii
2024-10-10 9:35 ` Dr. Arne Babenhauserheide
2024-10-10 10:42 ` Eli Zaretskii
2024-10-13 3:29 ` Richard Stallman
2024-10-10 6:07 ` Emanuel Berg
2024-10-09 16:06 ` Johan Myréen
2024-10-09 16:12 ` Ship Mints
2024-10-09 16:25 ` Eli Zaretskii
2024-10-09 21:25 ` Dmitry Gutov
2024-10-10 4:56 ` Eli Zaretskii
2024-10-10 5:14 ` Xiyue Deng
2024-10-10 6:36 ` Eli Zaretskii
2024-10-10 6:59 ` Xiyue Deng
2024-10-11 20:30 ` Dmitry Gutov
2024-10-12 7:34 ` Eli Zaretskii
2024-10-12 20:27 ` Dmitry Gutov
2024-10-12 21:00 ` Dr. Arne Babenhauserheide
2024-10-13 4:53 ` Eli Zaretskii
2024-10-13 6:28 ` Dr. Arne Babenhauserheide
2024-10-13 4:41 ` Eli Zaretskii
2024-10-13 9:37 ` Dmitry Gutov
2024-10-13 10:39 ` Eli Zaretskii
2024-10-13 15:31 ` Dmitry Gutov
2024-10-13 15:53 ` Eli Zaretskii
2024-10-14 9:32 ` Dmitry Gutov
2024-10-14 11:09 ` Alan Mackenzie
2024-10-15 1:41 ` Dmitry Gutov
2024-10-14 14:16 ` Eli Zaretskii
2024-10-15 1:36 ` Dmitry Gutov
2024-10-15 12:03 ` Eli Zaretskii
2024-11-03 3:10 ` Dmitry Gutov
2024-11-03 6:37 ` Eli Zaretskii
2024-11-03 19:24 ` Dmitry Gutov
2024-11-04 12:04 ` Eli Zaretskii
2024-11-04 12:11 ` Eli Zaretskii
2024-11-04 17:41 ` Dmitry Gutov
2024-11-04 19:18 ` Eli Zaretskii
2024-11-04 20:59 ` Dmitry Gutov
2024-11-05 12:11 ` Eli Zaretskii
2024-11-05 17:05 ` Dmitry Gutov
2024-11-05 17:28 ` Eli Zaretskii
2024-11-05 19:40 ` Dmitry Gutov
2024-11-05 19:53 ` Eli Zaretskii
2024-11-05 20:59 ` Dmitry Gutov
2024-11-06 12:15 ` Eli Zaretskii
2024-11-06 12:46 ` Dmitry Gutov
2024-11-06 13:25 ` Eli Zaretskii
2024-11-06 16:07 ` Dmitry Gutov
2024-11-06 17:14 ` Eli Zaretskii
2024-11-19 2:44 ` Dmitry Gutov
2024-11-19 15:41 ` Eli Zaretskii
2024-11-19 16:13 ` Dmitry Gutov
2024-11-19 17:10 ` Eli Zaretskii
2024-11-19 17:40 ` Dmitry Gutov
2024-11-19 17:47 ` Eli Zaretskii
2024-11-19 17:56 ` Dmitry Gutov
2024-11-19 19:01 ` Eli Zaretskii
2024-11-19 20:12 ` Dmitry Gutov
2024-11-20 12:59 ` Eli Zaretskii
2024-11-20 18:38 ` Dmitry Gutov
2024-11-20 19:01 ` Eli Zaretskii
2024-11-20 19:23 ` Dmitry Gutov
2024-11-20 19:55 ` Eli Zaretskii
2024-11-20 19:57 ` Dmitry Gutov
2024-11-21 5:46 ` Eli Zaretskii
2024-11-21 19:47 ` Dmitry Gutov
2024-11-21 20:03 ` Eli Zaretskii
2024-11-21 20:11 ` Dmitry Gutov
2024-11-21 20:24 ` Eli Zaretskii
2024-11-21 20:56 ` Dmitry Gutov
2024-11-22 6:44 ` Eli Zaretskii
2024-11-22 15:08 ` Dmitry Gutov
2024-11-23 13:24 ` Turning on/off tree-sitter modes (was: An anonymous IRC user's opinion) Eli Zaretskii
2024-11-23 16:26 ` Turning on/off tree-sitter modes Dmitry Gutov
2024-11-23 16:36 ` Eli Zaretskii
2024-11-24 2:40 ` Dmitry Gutov
2024-11-24 13:59 ` Steinar Bang
2024-11-23 17:51 ` Juri Linkov
2024-11-23 18:50 ` Eli Zaretskii
2024-11-23 19:23 ` Juri Linkov
2024-11-24 2:21 ` Dmitry Gutov
2024-11-24 15:28 ` Stefan Monnier
2024-11-24 5:32 ` Commands that change user options? [was: Turning on/off tree-sitter modes] Drew Adams
2024-11-24 10:23 ` Turning on/off tree-sitter modes Stephen Berman
2024-11-24 2:29 ` Dmitry Gutov
2024-11-24 7:29 ` Juri Linkov
2024-11-24 8:06 ` Eli Zaretskii
2024-11-24 17:29 ` Juri Linkov
2024-11-24 18:56 ` Eli Zaretskii
2024-11-25 0:44 ` Dmitry Gutov
2024-11-25 7:24 ` Juri Linkov
2024-11-25 12:09 ` Eli Zaretskii
2024-11-26 0:35 ` Dmitry Gutov
2024-11-26 0:40 ` Dmitry Gutov
2024-11-26 14:30 ` Eli Zaretskii
2024-11-26 14:29 ` Eli Zaretskii
2024-11-26 18:42 ` Dmitry Gutov
2024-11-26 18:45 ` Dmitry Gutov
2024-11-26 20:16 ` Eli Zaretskii
2024-11-26 21:36 ` Dmitry Gutov
2024-11-26 20:16 ` Eli Zaretskii
2024-11-26 20:32 ` Dmitry Gutov
2024-11-27 7:27 ` Juri Linkov
2024-11-27 12:36 ` Dmitry Gutov
2024-11-28 7:58 ` Juri Linkov
2024-11-28 18:50 ` Dmitry Gutov
2024-11-28 19:34 ` Juri Linkov
2024-11-28 19:51 ` Dmitry Gutov
2024-11-29 7:17 ` Juri Linkov
2024-11-29 7:05 ` Eli Zaretskii
2024-11-26 4:54 ` Turning on/off tree-sitter modes (was: An anonymous IRC user's opinion) Richard Stallman
2024-11-26 15:17 ` Eli Zaretskii
2024-11-29 18:09 ` Turning on/off tree-sitter modes Stefan Monnier via Emacs development discussions.
2024-11-30 3:26 ` Dmitry Gutov
2024-11-30 7:38 ` Eli Zaretskii
2024-11-30 18:49 ` Stefan Monnier
2024-12-02 2:04 ` Dmitry Gutov
2024-12-02 2:58 ` Stefan Monnier
2024-12-02 12:46 ` Eli Zaretskii
2024-12-02 12:41 ` Eli Zaretskii
2024-12-03 3:30 ` Stefan Monnier
2024-12-03 12:45 ` Eli Zaretskii
2024-12-03 13:26 ` Stefan Monnier
2024-12-03 14:14 ` Eli Zaretskii
2024-12-03 14:55 ` Stefan Monnier [this message]
2024-12-03 16:45 ` Eli Zaretskii
2024-12-03 17:10 ` Stefan Monnier
2024-12-03 17:14 ` Eli Zaretskii
2024-12-04 1:47 ` Dmitry Gutov
2024-12-04 2:14 ` Stefan Monnier
2024-12-04 12:56 ` Eli Zaretskii
2024-12-04 13:12 ` Dmitry Gutov
2024-11-30 18:24 ` Juri Linkov
2024-11-19 17:59 ` An anonymous IRC user's opinion Juri Linkov
2024-11-19 19:52 ` Dmitry Gutov
2024-11-20 16:47 ` Philip Kaludercic
2024-11-20 17:36 ` Juri Linkov
2024-11-20 18:07 ` Dmitry Gutov
2024-11-05 13:21 ` Dr. Arne Babenhauserheide
2024-11-05 13:47 ` Eli Zaretskii
2024-11-05 16:52 ` Dr. Arne Babenhauserheide
2024-11-05 17:22 ` Eli Zaretskii
2024-11-05 17:49 ` Philip Kaludercic
2024-11-05 19:23 ` Dr. Arne Babenhauserheide
2024-11-06 0:09 ` Philip Kaludercic
2024-11-06 9:35 ` Dr. Arne Babenhauserheide
2024-11-06 9:59 ` Philip Kaludercic
2024-11-07 14:16 ` Automatic Suggestion of Packages Philip Kaludercic
2024-11-07 16:07 ` Visuwesh
2024-11-07 21:50 ` Philip Kaludercic
2024-11-08 4:15 ` Visuwesh
2024-11-08 4:29 ` Visuwesh
2024-11-08 14:02 ` Philip Kaludercic
2024-11-08 15:44 ` Visuwesh
2024-11-08 16:23 ` Philip Kaludercic
2024-11-11 20:07 ` Mekeor Melire
2024-11-12 3:00 ` Philip Kaludercic
2024-10-13 10:52 ` An anonymous IRC user's opinion Dr. Arne Babenhauserheide
2024-10-10 13:58 ` Richard Stallman
2024-10-10 14:45 ` Dr. Arne Babenhauserheide
2024-10-12 3:19 ` Richard Stallman
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=jwvjzcgesel.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
--cc=emacs-devel@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).