From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Implementing cuda-ts-mode Date: Sat, 27 Jul 2024 16:22:18 -0700 Message-ID: <77366B28-8FDF-44AB-819B-B683C7FF5DD0@gmail.com> References: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37592"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Ergus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jul 28 01:23:22 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 1sXqkz-0009gU-S4 for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Jul 2024 01:23:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXqkF-0002DO-KS; Sat, 27 Jul 2024 19:22:35 -0400 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 1sXqkE-0002DB-CX for emacs-devel@gnu.org; Sat, 27 Jul 2024 19:22:34 -0400 Original-Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sXqkC-0006wX-JA for emacs-devel@gnu.org; Sat, 27 Jul 2024 19:22:34 -0400 Original-Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3db16129143so1328373b6e.0 for ; Sat, 27 Jul 2024 16:22:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722122551; x=1722727351; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=H2JrbcRCdURcw3L2xgXI5Oh4TupHRUDqPNFKyQOdL3I=; b=ZZaRWa0U+HZkLKGktPsTeRwabln3bHaXjPLe12oMVlySWVk+z894qj5jlohFIqFXtO oEERAcYiU89gR8nKKXHVcIsEAOVxt/AHHcLT7IcR+ifHe5O9bhKEFBH0jNSkMlka8Zg4 Qa0RWoqSEOEbtE5sw8fpS4IULRw1uYBH2SGQ5KCLjbPHKfPMeZg4OKm6x5pFjTAaPFqB 81jEEpFNOzDAsDEPwb1UrFQDdEdeYfuaUkOi5gKUy0zdHIm7riIMSw5F01ckIN4IcPeF 8R2RBSArKGSFMLFGzLVH8Y4NNQGewok653JeG1ao30dBE2JcOW5WSDCR9yVMaGbru2PO suTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722122551; x=1722727351; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H2JrbcRCdURcw3L2xgXI5Oh4TupHRUDqPNFKyQOdL3I=; b=qiIX6a5E0s5ayDb7QHh/knIHoZTDDZw605RzN7MrOvkxgVqjJo9k0nRsdEzKjONPS6 2b1CCazK4t0/1aLl2vv5uR3a0ZzL5TQRNhImsTV+33joHbpJlKmVWo2kdE6YHaC4PoUT 58lYQpiihDH/OPmX8WmU1WBRWP5EySeoJZbc6jg9dWGzMxstLoVz92RZCcMAvlLg6y+f MglEuHAMdsK1FxPybucHYuUIt1o0/xfIm+yz5mqyIlL3cU7rQegnHwaBnQIocDxsvxhb SIT+7QP5ocWz6J6atup9j9OEcIj0ZGeFJ/PLLzyVi5XyJ9tuVMoEN3ThugJOzSANz25S lBMw== X-Gm-Message-State: AOJu0YwSfhC3HuI8UtYG2D1kkOclEnc3NUQIu+R61ZEBQx/MzmxVadxn oHmqi5f6crXDb1VpRhFgAKW2qhy6o9QbbsSlqG28M8lyTbnsQxBO X-Google-Smtp-Source: AGHT+IFNgWzhxLcOZAP829hY9MGVGuK4Pbxgb9jMXDheJW8hfcFcp2UrzewYzvIcmEL38umNKm25jA== X-Received: by 2002:a05:6808:1495:b0:3d9:21bb:170d with SMTP id 5614622812f47-3db238bd70bmr5417808b6e.16.1722122550858; Sat, 27 Jul 2024 16:22:30 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:f9a7:9274:d0c2:c842]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f9fbd429sm4189267a12.74.2024.07.27.16.22.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jul 2024 16:22:30 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3774.600.62) Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=casouri@gmail.com; helo=mail-oi1-x236.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:322147 Archived-At: > On Jul 25, 2024, at 7:05=E2=80=AFAM, Ergus wrote: >=20 >=20 >=20 > On July 25, 2024 9:42:10 AM GMT+02:00, Yuan Fu = wrote: >>=20 >>=20 >>> On Jul 23, 2024, at 5:38=E2=80=AFAM, Ergus wrote: >>>=20 >>> Hi: >>>=20 >>> After a while and looking that the ts modules are getting mature I = was >>> planing to develop a `cuda-ts-mode'. >>>=20 >>> However after reading the documentation it is not totally clear to = me >>> how to proceed in this specific case because cuda is a sort of >>> "extension" over C++, so I expect that the cuda-ts-mode somehow >>> "inherits" from c++-ts-mode. >>>=20 >>> My initial idea was to replicate how I was expecting that = c++-ts-mode >>> should inherit from c-ts-mode, but it looks like this doesn't happen = in >>> a clear way. The modes are threated as independent and there is a = sort >>> of "mode" variable that is dynamically checked everywhere. >>>=20 >>> So the simple question is: >>>=20 >>> 1. The approach of trying to inherit from c++-ts-mode is correct? (I = mean, >>> is c++-ts-mode intended to be used like a "base" to inherit from?) >>>=20 >>> Some advise on this? >>=20 >> IIUC, tree-sitter-cuda is a separate grammar that is extended from = tree-sitter-cpp, right? Then inheriting c++-ts-mode won=E2=80=99t work = since it=E2=80=99ll setup everything using the cpp grammar. You=E2=80=99d = need to delete the cpp parser and add your cuda parser (doable), and = change everything that refers to =E2=80=98cpp to =E2=80=98cuda (very = hacky). >>=20 >> I guess we can add some map which tells Emacs to use the cuda grammar = in place of cpp. Kind of like treesit-load-name-override-list but more = dynamic. >>=20 >> Once we=E2=80=99re able to do that, you can define a new mode that = derives from c++-ts-mode and expect all the setup in c++-ts-mode to = work. >>=20 >> Yuan >=20 > Hi Yuan: >=20 > Now I understand why c++-ts-mode does not inherit from c-ts-mode. This = sort of inheritance is natural considering how tree sitter works. So I = am a bit surprised that nobody faced this before. I saw some derived = modes changes a while ago and I thought that it was related to this. >=20 > The extra features that the Cuda grammar adds to c++ are actually not = many, but some are important to not break the indentation.=20 >=20 > = >=20 > That's why, reimplementing the c++-ts-mode code substituting the = entries seems as unnecessary and overkill to me. So I will wait for the = new feature to be out before, then it will be more scalable and simple = to do a Cuda-ts-mode. >=20 > Best, > Ergus >=20 > PD: Do you want me to open a bug report to keep track of this? Yeah, that=E2=80=99ll be great. Thanks! I=E2=80=99ve implemented the = feature; once you create a bug report I=E2=80=99ll push to master for = you and others to try it out. Yuan=