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: Treesitter injection support Date: Sat, 4 Jan 2025 00:21:06 -0800 Message-ID: <30BA6520-0862-40A7-89BB-5AB020ADC7F9@gmail.com> References: <87ed1lb7bw.fsf@bauherren.ovh> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="17310"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Pranshu Sharma Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 04 09:22:16 2025 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 1tTzQG-0004MV-8i for ged-emacs-devel@m.gmane-mx.org; Sat, 04 Jan 2025 09:22:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tTzPW-0005fV-V4; Sat, 04 Jan 2025 03:21:30 -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 1tTzPQ-0005eq-EK for emacs-devel@gnu.org; Sat, 04 Jan 2025 03:21:27 -0500 Original-Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tTzPL-0000OW-HG for emacs-devel@gnu.org; Sat, 04 Jan 2025 03:21:21 -0500 Original-Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-21661be2c2dso165351435ad.1 for ; Sat, 04 Jan 2025 00:21:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735978878; x=1736583678; 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=zdzWC1i4p0gpZWPMTZUw3m7+EPezlw8haB9UDVmrxv8=; b=UozUIsHz2tHmLfHXjI+Qts9AhVunE7okTgyoMJDHWzpE+I38EqmioQuZ++7kWJjON/ I6eKez2a5wiSfV1+bExa/nTluTuuUxElrhpOf7vQkH2twYpBJvL90e9OV4LiCa9mSsad 6HNaM/R0cGvfMdDyqHV+SwBFuozau8lkC5JVFhRS40V9TGoEOZHvCnjifkOSpoLfVwBa opFVfRQuY9z/twYQa0oG1gEQVY6Z/1QUA998JeT8h2hzK58JjNtIzZeMYNtx1e/uXgLj obr9RbeAWg3dqB2qDnxvKoBmj9QkyIXSFnIQHijjxK996j5CpAPk7AKFjRKOp0isOsCs mRKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735978878; x=1736583678; 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=zdzWC1i4p0gpZWPMTZUw3m7+EPezlw8haB9UDVmrxv8=; b=YerH+Noz38PLPpSclnjGJb1sI2YGtwgIaHhmnEW8ybBW1VISVfmuiNc0+NdP969sMG 6HszkBqLK5fAnAQann/mTomFPViHDqxMh12aZ7/RLghxhcs555qvZCYobsYQffNOF+iD rfoOtMmmnQMX5Hk/oJRNkJglTQaag9WK4OEbiAt0NzXcgJZqALjTqdhntyk9Rhgddjl+ nLEaz9hMkc/SrHr8TOuw7OcssYgNZULCxly5as/Rb46vZHoZpwlRm1tu939Rd0jYER9u 7LNwQItQ9xB0H2hRfO77qmmIv0aDTMicZF/fWmFZpTisW0HeeRqvHfsDDR732chWayfN 3klg== X-Gm-Message-State: AOJu0YypENLgYc4621KKgi82snH9qJIU2T8vk4vo0dDN4z/B+xYJHjBr m/2PGabfcMah3hA6NzndWOgx+jN0EI07vCPZF2wcnP5Uhi+wlYw0zjUb1rnX X-Gm-Gg: ASbGncsmri2nZo/2GtnKFIu2i4/puk3SR/An/dRU256LBy7l9mcJnD6NpQ4Ei+iFPGe sb42FEOnu/QLeoZDG0wl+PuJUqsqKbaIzcRFt4eAfZkoKfymTzEjn417BWd3cQAjgq6jlNuyvvU S1mUZL3Dtc/+3BD2UXIZQJfaIMMXM8uL/FhIlSqA2tm3HC6Ag4aA7TQ+ornUtK9mrQLmWMcZ4Uj F3YwBlPdaFx1ZDV1FzRCg62QdW+MwkCAB51lRMAyLWLUZlzZ95c6HOFq9G9eUeZ9/434WVHANL2 YTmG X-Google-Smtp-Source: AGHT+IFnjubtVK0Tjr5SFg36QB89AEtLcaBdR7/DfbW/nhCWisPgkZb9lp5t3MCItdiGeY1lkW5KhA== X-Received: by 2002:a05:6a00:1152:b0:725:f4c6:6b71 with SMTP id d2e1a72fcca58-72abde9eb64mr82169298b3a.20.1735978877836; Sat, 04 Jan 2025 00:21:17 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:c496:8cdf:4c5d:3617]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8347d1sm28444584b3a.66.2025.01.04.00.21.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jan 2025 00:21:17 -0800 (PST) In-Reply-To: <87ed1lb7bw.fsf@bauherren.ovh> X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::641; envelope-from=casouri@gmail.com; helo=mail-pl1-x641.google.com X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, URIBL_DBL_SPAM=2.5 autolearn=no 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:327655 Archived-At: > On Jan 2, 2025, at 6:48=E2=80=AFAM, Pranshu Sharma = wrote: >=20 >=20 > I'm making cperl clone using treesitter, and have done all of > highlighting apart from regex and pod. >=20 > For regexp, I need different grammer to highlight it, and using the > treesit-parser-set-included-ranges doesn't work. An example: >=20 > preq knowledge: >=20 > 's/bi?g/small/' replaces instances of 'bg' and 'big' with 'small', and > 's/([0-9]+)/$1 + 1/e' incrimental all number (the 'e' at the end tells > perl to evaluate the code). >=20 > the parse tree of 's/([0-9]+)/$1 + 1/e' is: > (substitution_regexp operator: s ' > content: (regexp_content not-interpolated not-interpolated) ' > (replacement > (scalar $ (varname))) > ' modifiers: (substitution_regexp_modifiers)) >=20 > (replacement) needs to be conditionally parsed as perl over here = because > of the 'e' modifier. Now I cannot use range for this, because say if = I > had: >=20 > 's/(([0-9]+),)+/s#([0-9]+)#$1 + 1#e/e;' > ^^^^^^ Perl code > ^^^^^^^^^^^^^^^^^^^ Perl code >=20 >=20 > The replacement contains another replacment which contains perl code, = so > it overlaps >=20 > So I won't have any way to highlight. It seems making this work could > be possible using nested parsers with their own setting each using own > local treesit-range-settings, but this seems really hard with > treesit-range-settings being a buffer local variable. >=20 > --=20 > Pranshu Sharma Ok, so the problem is nested parsers. I don=E2=80=99t think the overlap = would cause any problem. Right now treesit-range-settings can only give = you one nested layer. I=E2=80=99ll need to make it support nesting a = parser inside a local parser of the same language. I=E2=80=99ll work on = that once I wrap up the thing I=E2=80=99m working on right now :-) Yuan=