From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Turning on/off tree-sitter modes Date: Fri, 29 Nov 2024 09:05:05 +0200 Message-ID: <864j3qcyfy.fsf@gnu.org> References: <86v7wgnxlz.fsf@gnu.org> <01d83ec8-c02b-4806-8764-38dc89a89125@gutov.dev> <86ttbzojho.fsf@gnu.org> <930f5c8e-1481-43a5-8f1d-2c13a98df74f@gutov.dev> <86r072krq5.fsf@gnu.org> <8b907a41-aa08-4b61-bced-7d4d3fcef4b2@gutov.dev> <87frnhsvp3.fsf@mail.linkov.net> <0d1e2770-0889-4862-8105-8a5f4631b11c@gutov.dev> <87ed31gku5.fsf@mail.linkov.net> <86plmljbsm.fsf@gnu.org> <8734jgftif.fsf@mail.linkov.net> <86ttbwihp6.fsf@gnu.org> <4f8f8b97-6650-4a6f-b121-82964fec49cf@gutov.dev> <86o723ikga.fsf@gnu.org> <41e2710f-d612-40e2-9037-d8d388c5edc7@gutov.dev> <86ldx6gjai.fsf@gnu.org> <878qt588qb.fsf@mail.linkov.net> <277bed39-bad3-4464-8ca8-506428a5ba2e@gutov.dev> <878qt36a69.fsf@mail.linkov.net> <771f99be-efb9-44b2-9f3a-726336f25889@gutov.dev> <87r06vw3th.fsf@mail.linkov.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25328"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, johan.myreen@gmail.com, emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 29 08:06:05 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tGv4m-0006P2-LO for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Nov 2024 08:06:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGv41-0006DP-Sv; Fri, 29 Nov 2024 02:05:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGv3z-0006D1-2d for emacs-devel@gnu.org; Fri, 29 Nov 2024 02:05:15 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGv3x-0004eq-TF; Fri, 29 Nov 2024 02:05:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=0jQkhcGk7t/Pu8cLnrt/z2nN2bIUNvbGcdyxkljWQpY=; b=EAXFgitNsa/O er9sWurLoSsfCWiaGnE8zX4Y7pS2OEicatI5A5Rq+460hpE1UlluGziu+oRCR4JhClu2nEJmObKiP mEfhdpyvcjZeKfC0RMjbWjLGwZURniaWvhKrV113vIkOZH0O3r7THgTZNMIkzZMJCc0GJsgopU0d3 nEi42uZ4FUZuErT949zT+oSw9y1kRu3fUuScRoqe0tfRvH6Pvbad2H8CEXnJrjrBhfSIOulV45gho wrR+Aw1h/Va0FyT1rgTor0gk0o6k78dDwz8qgtOjC+O/8hQWtoKfPyJeLfcRMYcEDHd/qTJpg42Oi qm8pH2kkikozx1HjiC3WAA==; In-Reply-To: <87r06vw3th.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 28 Nov 2024 21:34:02 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325842 Archived-At: > From: Juri Linkov > Cc: Eli Zaretskii , johan.myreen@gmail.com, emacs-devel@gnu.org > Date: Thu, 28 Nov 2024 21:34:02 +0200 > > >>>>> Major Mode Remap Alist: > >>>>> List of remappings: > >>>>> INS DEL > >>>>> Remap from major mode: js-mode > >>>>> To mode (or function): js-ts-mode > >>>> Here mode names are nicely aligned, > >>>> so it's easier to read for users. > >>> > >> - :offset 12 > >> + :offset 9 > > > > Maybe 10? With 9, it still doesn't line up on my display (the buttons' > > margins drive the offset), but hangs over for like 0.5 character width. > > > > With 10, the result look more intentional, though I'm not sure if the > > original plan (in Emacs 25?) was to have a different indentation or not. > > And can't be aligned with proportional fonts anyway. > > There is even a wishlist item in wid-edit.el: > > ;; * Make indentation work with glyphs and proportional fonts. This should be solvable by using :align-to or :width 'display' space properties. > > >> + :options '((js-mode (function :value js-ts-mode)) > >> + (ruby-mode (function :value ruby-ts-mode))) > > > > This :options hunk is a nice illustration, but if it's a serious proposal > > I wonder which set of modes would be appropriate to have here. All or most > > ts modes? > > Probably the list of all ts-modes would be too long. > I can count 28 ts-modes in Emacs core. If the list starts with "All" and "None", the length of the rest is of secondary importance. But more generally, this clearly shows limitations of Customize for large or complex data structures. We should perhaps consider a user command that shows a dialog box or a child frame with checkbox for each remapping, letting users just click or press RET on those they want. > > Note we still won't be able to cover all tree-sitter modes this way because > > a large part of them doesn't have any corresponding "traditional" modes and > > so no existing auto-mode-alist entries. > > Such ts-modes can be associated with a non-ts placeholder > like this wishlist item in lisp/progmodes/go-ts-mode.el: > > ;; FIXME: Should we instead put `go-mode' in `auto-mode-alist' > ;; and then use `major-mode-remap-defaults' to map it to `go-ts-mode'? > (add-to-list 'auto-mode-alist '("\\.go\\'" . go-ts-mode)) Alternatively, we could use a command that allows to activate one or more tree-sitter modes, regardless of whether there are alternative modes. For modes which have no alternatives, such a command will just set up auto-mode-alist.