From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Wilhelm Hugo Kirschbaum Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter, using treesit-range-rules for embedded languages Date: Tue, 22 Nov 2022 21:52:45 +0200 Message-ID: <93179658.VN8fuaoyE4@melissa.local> References: <87o7syaon6.fsf@gmail.com> <158606F8-9A2E-4630-A441-2BEAA07EB137@gmail.com> Mime-Version: 1.0 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="12654"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 22 20:57:32 2022 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 1oxZOd-00035a-8o for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Nov 2022 20:57:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxZO1-0005uP-BB; Tue, 22 Nov 2022 14:56:53 -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 1oxZKA-0005aK-J8 for emacs-devel@gnu.org; Tue, 22 Nov 2022 14:52:54 -0500 Original-Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxZK8-0000jR-3T for emacs-devel@gnu.org; Tue, 22 Nov 2022 14:52:54 -0500 Original-Received: by mail-wr1-x436.google.com with SMTP id s5so9143102wru.1 for ; Tue, 22 Nov 2022 11:52:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=floatpays.co.za; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WNlZgIHKMnYEj3C/o0AmymixF4dO5uJoFdltKoZhig0=; b=lG9Kx2HMRbUNaH4Ry7VfxwT9FAPpPGd66LF2VWBLwyON42GdS8r+mG1XBzEXkFx6ZS poIU6EbBZzUcUYc2WBwv3xCVPlnhC7eypCw3a4O3sJ7/PumOiSqZImIKD/CnV89dhgef vR+/UsJcudBWnuBwtem8Vgj6B3kEfEzV7GwDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WNlZgIHKMnYEj3C/o0AmymixF4dO5uJoFdltKoZhig0=; b=Ijv4kAThe1BVQxLYabVOjuNB0M7POksGQ0HowwJpEeGdTpQfGOKvJvLX/vzZREjt4x BJ9oGuHIMkpjnvum9zp4JJ3LPlXaKYMfCD0n6W8FlU3Oe8tcS5VYb4t/WlvXXYh04qDG W35jbpd/V5G6zJpTSLf4Aud4EObosofvJdIZmSXgKDpG7xbphdluWIPr5PEM8VC7NMCT seftIgxAduPY3sQLWzxmoMXokZkMUcin2qSXP3gwqk7MuK4MEMVeClTVrPrDvVHhu/Pc HfE2hCmt11XVKTXZNZRZ/0Mut4p2FwVMPtSzgqKipPh/lGSwhTSkAYn9GsCffmV1B6QD hNNw== X-Gm-Message-State: ANoB5pnHNwg0JtNqEX8xQXskVlUCm9j/C2tvc3so00zJ/P+ZACK4eYVe IL17n6ML53kSuTNsg+VpnnECyw== X-Google-Smtp-Source: AA0mqf4msbRqbBj9yVPZsQ1Mu4+61LJVNXcQV96/lMQ1FMM1Z/Ro1sQxwYkXlYkGC7Z0P8/QMlsHog== X-Received: by 2002:adf:f782:0:b0:236:73fa:c56e with SMTP id q2-20020adff782000000b0023673fac56emr9253053wrp.432.1669146769849; Tue, 22 Nov 2022 11:52:49 -0800 (PST) Original-Received: from melissa.local ([2c0f:ef18:1431:0:b09:9616:db04:c248]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003cfbe1da539sm17883235wmc.36.2022.11.22.11.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 11:52:49 -0800 (PST) X-Google-Original-From: Wilhelm Hugo Kirschbaum In-Reply-To: <158606F8-9A2E-4630-A441-2BEAA07EB137@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=wilhelm@floatpays.co.za; helo=mail-wr1-x436.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, 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-Mailman-Approved-At: Tue, 22 Nov 2022 14:56:51 -0500 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:300349 Archived-At: On Tuesday, 22 November 2022 21:28:48 SAST Yuan Fu wrote: > > On Nov 22, 2022, at 9:24 AM, Wilhelm wrote: > >=20 > > Is there perhaps an example using treesit-range-rules? To following > > attempt to set treesit-range-settings does not seem to have the desired > > effect. > >=20 > > (defvar heex--treesit-range-rules > >=20 > > (treesit-range-rules > > =20 > > :embed 'elixir > > :host 'heex > > =20 > > '((directive (partial_expression_value) @cap) > > =20 > > (directive (expression_value) @cap) > > (expression (expression_value) @cap)))) > >=20 > > (setq-local treesit-range-settings heex--treesit-range-rules) > >=20 > > The following error also pops up when modifying the buffer when removing > > buffer content: > >=20 > > Error during redisplay: (jit-lock-function 1) signaled > > (treesit-range-invalid "RANGE is either overlapping, out-of-order or > > out-of-range" ((11 . 20))) > >=20 > > The full attempt is here: > > https://github.com/wkirschbaum/elixir-mode/blob/main/heex-mode.el > Thanks Wilhelm. It would be nice if you can provide some example source f= ile > of heex for me to experiment with. I tried to find some on the internet b= ut > didn=E2=80=99t get very far :-) >=20 > Yuan Thanks for having a look as I was not sure if this was meant to be used yet= =2E=20 A heex file can be as simple as this:=20 #sample.html.heex
<%=3D Enum.map([1, 2], &(&1 + 1)) %>
and the directive <%=3D (partial_expression_value) %> should then be elixir= =2E,=20 not heex. When checking with (treesit-language-at (point)) for the embed it still sh= ow. Wilhelm