From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Turning on/off tree-sitter modes Date: Wed, 4 Dec 2024 03:47:00 +0200 Message-ID: <56d7b33e-9b95-48ef-9c6d-c5bd14c824af@gutov.dev> References: <9cd17f8b-f88c-49f6-9024-0b6d297e18ac@gutov.dev> <867c8xsmri.fsf@gnu.org> <566ac897-ea5e-4141-bcb3-306d43c9118a@gutov.dev> <865xohrvfa.fsf@gnu.org> <86wmgwnyle.fsf@gnu.org> <178dfc7f-bc2d-4e3b-8417-a616ccc0eef3@gutov.dev> <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> <27a62624-387c-4233-b995-170270e26efd@gutov.dev> <86iks245q0.fsf@gnu.org> <86bjxt2avf.fsf@gnu.org> <86wmgg26rt.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11777"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird Cc: emacs-devel@gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 04 02:47:56 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 1tIeUd-0002vr-G4 for ged-emacs-devel@m.gmane-mx.org; Wed, 04 Dec 2024 02:47:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIeTu-0000Mx-TA; Tue, 03 Dec 2024 20:47:10 -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 1tIeTs-0000Ml-O3 for emacs-devel@gnu.org; Tue, 03 Dec 2024 20:47:09 -0500 Original-Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIeTq-00048H-Ss; Tue, 03 Dec 2024 20:47:08 -0500 Original-Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.stl.internal (Postfix) with ESMTP id ED0232540102; Tue, 3 Dec 2024 20:47:03 -0500 (EST) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Tue, 03 Dec 2024 20:47:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1733276823; x=1733363223; bh=w6YokbFJx0XXvCZr6xAX3L6CtLgt/+g7U6ftXnQ8q7E=; b= ZpaaczlJCDHbN+T7aJGGLVy582ld1Rfu+v55bQI1XC4VfxQDC+3Mt7bGEJrZoRJs ocYhKrkREopdsjhTE6D1xNzXenG/xJ6a7cidQ1wwqac7VRnRc0ioAuWza5g7gflo Td37EP/2/ZFfsqP62nTzz9wtgBY8SRMhOiXBf39NMRBCY+TjNQ94cZB0Ep9A57KV 59UwCNco9ZQGsBTQIt8z1cP1eqqec4pUjowKlZ1IxAkmyTAg+Jr0QknUv6ME8Xm2 sNFWP9gVRnyZbguk8gB0UEjntXOA8jO5QlDNSoFMRvAHCMuIyfK2Kc+hcw+eOa7h aDeSaqVEelgeAu8ypB+i3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733276823; x= 1733363223; bh=w6YokbFJx0XXvCZr6xAX3L6CtLgt/+g7U6ftXnQ8q7E=; b=f 0gwzUWfyzNYxm7/rHCfGMww9N0V6FqmkjZEPu+2TDnBsqJ+COCToXVg5a3SwQ60g r/iLZK7cOlh1/EEfNN4IbPaa4Mhp9BC43KbmwCFTekNONvzL1H3pT079aWL6AV/7 zZNQrBC1fP7/z2EozNmQqxdhSXb6hAizbAaOQ+cV4rQ7Lbkpebzi3PmT5Ig4JvBw 0mKo2DNgcegWlBplOL5IZLcwJp0ahB5k1G5psg9/yrzUdvlBdaOGAjEK/pY5EMJ4 zQIhVOionM+zm8JmULoB/kcusQ24OQXg/sde6c9gvUqX7DG/wjE88lblk4Xlj5IT tXfUDSb5xE2j8xC/L6LCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrieeggdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeen ucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvg hvqeenucggtffrrghtthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedt vddtveefhfdvveegudejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohep fedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepmhhonhhnihgvrhesihhrohdruh hmohhnthhrvggrlhdrtggrpdhrtghpthhtohepvghlihiisehgnhhurdhorhhgpdhrtghp thhtohepvghmrggtshdquggvvhgvlhesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Dec 2024 20:47:02 -0500 (EST) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=202.12.124.156; envelope-from=dmitry@gutov.dev; helo=fhigh-b5-smtp.messagingengine.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_SBL_A=0.1 autolearn=ham autolearn_force=no X-Spam_action: no action 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:326011 Archived-At: On 03/12/2024 16:55, Stefan Monnier wrote: > +;;;###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)))) Should we do this switch if the grammar is not available? We could stay with the tree-sitter mode if it doesn't anything bad. Take for example rust-ts-mode, or dockerfile-ts-mode: the body of the major mode function is wrapped in (when (treesit-ready-p 'dockerfile) ... ) which checks for the grammar, emits the warning and does nothing otherwise. So dockerfile-ts-mode behaves like prog-mode in this case, even highlighting strings using the default syntax table. If there are downsides, they would probably be limited to having the mm keymap enabled, or dockerfile-ts-mode-hook run, which could be good too - depending on what the user expects to happen.