From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Filippo Argiolas Newsgroups: gmane.emacs.devel Subject: Re: A few questions about c++-ts-mode. Date: Thu, 9 May 2024 07:34:58 +0200 Message-ID: References: <865xvoa0jr.fsf@gnu.org> <86jzk38tm7.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2415"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Ergus , emacs-devel@gnu.org, casouri@gmail.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu May 09 07:36:14 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 1s4wRx-0000Yz-KK for ged-emacs-devel@m.gmane-mx.org; Thu, 09 May 2024 07:36:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4wR8-0002UD-K2; Thu, 09 May 2024 01:35:23 -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 1s4wR1-0002Tk-Be for emacs-devel@gnu.org; Thu, 09 May 2024 01:35:16 -0400 Original-Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s4wQz-0001aO-87; Thu, 09 May 2024 01:35:15 -0400 Original-Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6f447976de7so503758b3a.1; Wed, 08 May 2024 22:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715232910; x=1715837710; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0bz/evAKOItR1N9Jlq7V3Nmqd2K0pmqGNux/iJha6bA=; b=mMCI5PcapCYR5a1BcmyvqsfBnp615ZYFgz/nQ07R1EA1oCgGc3g3pYOqRg6FeIX6gB pJH/RXEQtqAQA/Cp42YgwPcLcGsB+a2OcV0x/t41JFEkWHyf2PCdH0LzGgz/eyxbFqLb tOtEuMP4VHgmSIDf5oLrx6AQVQY17+FGGIgRWVpExxOubTA2EwSiBmmRtKJ3CUpP5mCg PV1+jWcfcnK2hIlL5+EmKFvfZV9cA6vJGysYTolFGpjhE3EPxA/m81sJ7bTQdO4A/nX2 ERhuHI4p/xWoJEDwTArNQ/MgmD0T+V3TSsO3FMxZY/ZYW96nuh6zCPVooTjieh/0m4Hs pOFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715232910; x=1715837710; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0bz/evAKOItR1N9Jlq7V3Nmqd2K0pmqGNux/iJha6bA=; b=KfgRZCoS/4OeZ0Rvqt1W+RzW47MwFswN2xzKLRAqmtOm3U8rCMwz2OsuAFryCK7iKu q6wGiQpPa4AM13jSIHYQc/Q3jNTMwvvlUl/fwYD3MrG3nPY/l3ATnu+KZw7qsnxtRzSC sDpKXszx2bXqAALiEgpiu/zt4kd9qEqJFhZgJTLfKZuDHB2bihE9kMmvWPyQjAb+fc2u +W42c8TrvYk+c9I1kIMDfRf3JAI0vNU0JjA2Y5yxHcq6EyldQv/zSXDRo5xOTV+HOkON nNIThsd5pTo0DPyKPfjBnY/f6F3nGIY8h4B0iRj/pKV0cXGe5ZO/Yakkh0U5SzYS5Hy5 YniA== X-Forwarded-Encrypted: i=1; AJvYcCVrcgFNME6u//Ba+Ud/ZF78ocLZ0tRHzwr77rb4K8eYPIgjfHlrbG8rrcUbXxaxvay8o0ypx1HLtM/kDCW/2IWHCdhF X-Gm-Message-State: AOJu0YwxABca7dnmQPBJi7rOXL78b9iGdRAMY9/Q8hy/JgvpmWPx5UDC bklIRfwdj2+S5g+8W7vZnSZWOAspdFvltMrskEO/MqQhGd/ya/I3trfVZDVroRcxzDS399KtrUY t9n6W0x1z+pKVvGHZPRW317j5N5GUgw== X-Google-Smtp-Source: AGHT+IGF27/J59GE+rnnIePvLqjbwo+uKCAsREaPAnY9//vD/rx3EQ1krmCAnFk0U7uaXJwoiRcGHS9286Z18mXMeE8= X-Received: by 2002:a05:6a20:96c1:b0:1a8:4254:5cdf with SMTP id adf61e73a8af0-1afc8d78a89mr4786331637.22.1715232910220; Wed, 08 May 2024 22:35:10 -0700 (PDT) In-Reply-To: <86jzk38tm7.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=filippo.argiolas@gmail.com; helo=mail-pf1-x433.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:319041 Archived-At: > > It looks like tree sitter already supports this using language injection: > > > > > > > > I am not sure if we can handle this same way in emacs. Or if it is a better or worst approach than using a made in home workaround. > > If the only solution is language injection, then doing that our usual > way (with regexps etc.) is easier and more flexible. I thought I saw > some commits in the C++ grammar that actually support that in the > grammar itself. If there is such support, we should use it, IMO. > Sorry to intrude, may I ask what's the problem with language injection? it seems the perfect use case for this. According to Yuan this should already be supported with emacs (at least the parser part, you would probably need to add some specific rule for fontification). Yuan, a complete example would be great! Another use case in c-ts-mode would be fontifying format strings in printf functions. There was some discussion about doing that in the Go grammar and there too they concluded injections was the canonical treesitter way for stuff like this and dropped the pull request. Thanks, Filippo