Juri Linkov <juri@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 1 Apr 2025 17:23:04 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 01 13:23:03 2025 Received: from localhost ([127.0.0.1]:50877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzfKJ-0005Ix-Au for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 13:23:03 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:41247) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tzfKH-0005H7-4j; Tue, 01 Apr 2025 13:23:01 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 993892047C; Tue, 1 Apr 2025 17:22:50 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#77255: Treesit font-lock override for embed ranges In-Reply-To: <277C71F3-7D42-47D8-A07B-0379BDFA06A4@HIDDEN> Organization: LINKOV.NET References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> <87v7ruqor9.fsf@HIDDEN> <B771FEBB-420F-437F-8960-14074A0BA44C@HIDDEN> <87iknpus7l.fsf@HIDDEN> <277C71F3-7D42-47D8-A07B-0379BDFA06A4@HIDDEN> Date: Tue, 01 Apr 2025 20:18:36 +0300 Message-ID: <87frirdclu.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukeeffeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepgedprhgtphhtthhopegtohhnthhrohhlseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvhdrphhuphhilhhlohesghhmrghilhdrtghomhdprhgtphhtthhopeejjedvheehseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomh X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) close 77255 31.0.50 thanks >> liquid -> html -> js -> jsdoc >> liquid -> html -> css >> liquid -> yaml > > Awesome! So now added to treesit-x.el and closed.
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 1 Apr 2025 17:22:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 01 13:22:59 2025 Received: from localhost ([127.0.0.1]:50872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzfKE-0005Ho-PS for submit <at> debbugs.gnu.org; Tue, 01 Apr 2025 13:22:59 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:35501) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tzfKB-0005GW-RO for 77255 <at> debbugs.gnu.org; Tue, 01 Apr 2025 13:22:56 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 74FE944357; Tue, 1 Apr 2025 17:22:46 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Vincenzo Pupillo <v.pupillo@HIDDEN> Subject: Re: bug#77255: Treesit font-lock override for embed ranges In-Reply-To: <1963203.7Z3S40VBb9@fedora> Organization: LINKOV.NET References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <1963203.7Z3S40VBb9@fedora> Date: Tue, 01 Apr 2025 20:17:58 +0300 Message-ID: <87msczdcmx.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukeeffeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopegtrghsohhurhhisehgmhgrihhlrdgtohhmpdhrtghpthhtohepjeejvdehheesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopehvrdhpuhhpihhllhhosehgmhgrihhlrdgtohhm X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Yuan Fu <casouri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) > However, we could modify treesit-replace-font-lock-feature-settings to check > the language in addition to the feature. Thanks for the suggestion. So I modified treesit-replace-font-lock-feature-settings to check the language as well.
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 1 Apr 2025 00:38:23 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 31 20:38:23 2025 Received: from localhost ([127.0.0.1]:43583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzPe1-00086t-FY for submit <at> debbugs.gnu.org; Mon, 31 Mar 2025 20:38:22 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:51640) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1tzPdy-00085s-1H for 77255 <at> debbugs.gnu.org; Mon, 31 Mar 2025 20:38:18 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2260c91576aso79710655ad.3 for <77255 <at> debbugs.gnu.org>; Mon, 31 Mar 2025 17:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743467892; x=1744072692; darn=debbugs.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=9S+vNbD6ws87cN/WfFzOIy1WgllnvMxAoHq0v4gZNWI=; b=HdWb+S6NSZbK0pvEtbRpMQIIsxH8oXBc1mTBrDtvwaMzy8EZim9AWg4mir5JgSXFYh XKN2XvtI2M7eS/rGPWmTeuGuwm2EgVWW+6tJsharX57maTWDA/rDa0MWxdvOdVhvT8P6 SnO/YIHPgPn36RrX9lrVZ7m8Gc++GIBUgaexAxT5Cw37fNjLyPXkEAa1sFUE4oB237lw B9+7dhybl3CRZYnoecvbRoQDSTe9DRjcJNY50RR3JqYECWE3A97giLYqb/w4xPjAOHQg NsLd+pgFSVSPHT/2sWLUWXpxOVtmMu3XLpe4ECvMHYAVg7ysuoiXI+VSg2p1PHZkRx80 7i6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743467892; x=1744072692; 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=9S+vNbD6ws87cN/WfFzOIy1WgllnvMxAoHq0v4gZNWI=; b=QmQXsLDDNf8sbB86mxuFoEIyuVm6ddHwdJB0qJZ2lpzT9+rE/CiduGBzKB0tnDTX/b 7KZh+sRafWqOY7sIJ+KRZ7AZxib7hGqQN9Z9QsQH5tY3wNKmfPEvuaInoxGlwgr8Nccp 330NVr3Z0SzQeUKKxhcGAFhjeQtKIrGpbUSE3iePIuAWt/TgvaA7X1x3cey1jKvJ4K9i EHvJC/nBmwSnGMlhajs8fh1ETRxNc99mzHmaDLBOu6bbZ6+B9bbrE6lxYBiCdaJKwEwA J8YXsrOeRJJoiBvubHy7PLE4+D3UDafFVdw+eS/dQRniG9RyMKa5zvSzgd9rTDropveC kgJg== X-Gm-Message-State: AOJu0Yye1DEyjhCnMHc1Kl9uJcdPmgMvmFRa2VZO0KmWNK9n0s32vTOZ iNtNC6WG0uSqfYkh3vaFU3zH5QhdZjuAsxGqf2OCQjLcGwReyzWQ X-Gm-Gg: ASbGncuaQFJ/b+YM6GaBj2xz05EVVFR0DHq3g4RELfRgW6ETGK71f/nEFVGIKiZgZbM Ac5a8bkVXW8gQeo64ZsgWvjWnFEFJwO/HRCfJpvsn4bwvPFiyOZPY6pmnMn3UanpI3d/hspQbYq 2qD4pOVfHG9WyISOpPhviUeU6yHuBkrKc7TUEMfwT9rO+QH3W86ZOl0OF6LbHBEQAi6T0yuIm62 m//RbIf6StS6O4rvqs/ipMyUY6sQOBPAwsao9BfWOs9BlyXaNHr0PzCwtHKbLVZ0ylz2suKRGpg LTyqqqqV+e2wYMjAmpKeEfYgd0nmZ96fluHVUgRIWsofkwYBOQpDTjEXks9WI2KFq7E= X-Google-Smtp-Source: AGHT+IERio4bXV1+gMVUIaVUw1N0pqaI0lSBLbO8ROrm2w7vVy8N48GyBb2gVQGs04OF9qmXnFD6EQ== X-Received: by 2002:a17:903:98f:b0:224:6ee:ad with SMTP id d9443c01a7336-2292f9eb6f2mr203107915ad.44.1743467892010; Mon, 31 Mar 2025 17:38:12 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:7c76:5133:615:6915]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf632sm75139985ad.125.2025.03.31.17.38.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2025 17:38:11 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\)) Subject: Re: bug#77255: Treesit font-lock override for embed ranges From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <87iknpus7l.fsf@HIDDEN> Date: Mon, 31 Mar 2025 17:38:00 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <277C71F3-7D42-47D8-A07B-0379BDFA06A4@HIDDEN> References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> <87v7ruqor9.fsf@HIDDEN> <B771FEBB-420F-437F-8960-14074A0BA44C@HIDDEN> <87iknpus7l.fsf@HIDDEN> To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3826.400.131.1.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Mar 31, 2025, at 9:57=E2=80=AFAM, Juri Linkov <juri@HIDDEN> = wrote: >=20 >>>> Looks reasonable to me. But if it=E2=80=99s a minor mode, we might = need to >>>> have a way to negate the change made to treesit-font-lock-settings? >>>> OTOH if we use :override, we might run into an override arm race = when >>>> enabling multiple minor modes, etc. >>>=20 >>> We could declare that the last minor mode wins. But indeed still = need >>> a way to restore the original treesit-font-lock-settings after = disabling >>> the minor mode. >=20 > I'm convinced now that minor modes should be avoided since it's not > straightforward to revert the original settings when they are = disabled. >=20 > Everything works nicely in the attached example of the liquid major = mode > where liquid is the primary parser. Currently it copies settings > from mhtml-ts-mode. But later I'll try to inherit from mhtml-ts-mode. >=20 >>> BTW, I found another problem. Please confirm if the range rules = allow >>> only one query per embed language, or I'm doing something wrong? >>=20 >> That=E2=80=99s curious, even if you included multiple patterns in the = query, it=E2=80=99s >> still one query; and the range functions support multiple captured = ranges >> when setting up ranges. So something is wrong here. (See >> treesit-query-range) I can look into this, but give me a few days. >=20 > Multiple captured ranges are not needed anymore for the attached = example. >=20 >>> This revealed another problem. Actually, Liquid is a preprocessor. >>> Since it can be embedded everywhere in every html node, not = depending on >>> the structure in the html parser, it would be more correct first to = use >>> the liquid parser, and then allow html+js+css parsers to handle >>> remaining parts. But both liquid and html parsers should apply >>> on the whole file. The only difference is that liquid has a higher >>> precedence to decide what overlapping parts belong to the liquid = parser. >>> Or maybe it makes sense to have two primary parsers? They both = could >>> add own highlighting. And in regard to navigation, one of primary >>> parsers could have a precedence. >>=20 >> IMO preprocessor definitely should be the primary parser and let HTML = embed >> in it. In the case of Liquid, it happens to uses a syntax that=E2=80=99= s compatible >> to HTML; that=E2=80=99s fine, but it=E2=80=99s worth it or even = necessary to add support >> for multiple primary parsers because of it. As for precedence, it can = be >> customized by treesit-language-at-point-function. >=20 > Thanks for the suggestion to use the preprocessor as the primary = parser. > So multiple primary parsers are not required anymore since other = parsers > are embedded to the primary parser ('define-treesit-generic-mode' sets > the primary parser). And everything works for any embedded level: >=20 > liquid -> html -> js -> jsdoc > liquid -> html -> css > liquid -> yaml >=20 Awesome!
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 31 Mar 2025 17:05:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 31 13:05:05 2025 Received: from localhost ([127.0.0.1]:42668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tzIZM-00009H-71 for submit <at> debbugs.gnu.org; Mon, 31 Mar 2025 13:05:05 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]:52743) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tzIZ3-00006Y-Jz for 77255 <at> debbugs.gnu.org; Mon, 31 Mar 2025 13:04:46 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 26753444F7; Mon, 31 Mar 2025 17:04:33 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#77255: Treesit font-lock override for embed ranges In-Reply-To: <B771FEBB-420F-437F-8960-14074A0BA44C@HIDDEN> Organization: LINKOV.NET References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> <87v7ruqor9.fsf@HIDDEN> <B771FEBB-420F-437F-8960-14074A0BA44C@HIDDEN> Date: Mon, 31 Mar 2025 19:57:18 +0300 Message-ID: <87iknpus7l.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukedtgeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgfgsehtkeertddtreejnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuggftrfgrthhtvghrnhepiedvvefggfetudeklefggfeugeehheeuueffudelieelveehkeelffdtudetgeelnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopehvrdhpuhhpihhllhhosehgmhgrihhlrdgtohhmpdhrtghpthhtohepjeejvdehheesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthhopegtrghsohhurhhisehgmhgrihhlrdgtohhm X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) >>> Looks reasonable to me. But if it’s a minor mode, we might need to >>> have a way to negate the change made to treesit-font-lock-settings? >>> OTOH if we use :override, we might run into an override arm race when >>> enabling multiple minor modes, etc. >> >> We could declare that the last minor mode wins. But indeed still need >> a way to restore the original treesit-font-lock-settings after disabling >> the minor mode. I'm convinced now that minor modes should be avoided since it's not straightforward to revert the original settings when they are disabled. Everything works nicely in the attached example of the liquid major mode where liquid is the primary parser. Currently it copies settings from mhtml-ts-mode. But later I'll try to inherit from mhtml-ts-mode. >> BTW, I found another problem. Please confirm if the range rules allow >> only one query per embed language, or I'm doing something wrong? > > That’s curious, even if you included multiple patterns in the query, it’s > still one query; and the range functions support multiple captured ranges > when setting up ranges. So something is wrong here. (See > treesit-query-range) I can look into this, but give me a few days. Multiple captured ranges are not needed anymore for the attached example. >> This revealed another problem. Actually, Liquid is a preprocessor. >> Since it can be embedded everywhere in every html node, not depending on >> the structure in the html parser, it would be more correct first to use >> the liquid parser, and then allow html+js+css parsers to handle >> remaining parts. But both liquid and html parsers should apply >> on the whole file. The only difference is that liquid has a higher >> precedence to decide what overlapping parts belong to the liquid parser. >> Or maybe it makes sense to have two primary parsers? They both could >> add own highlighting. And in regard to navigation, one of primary >> parsers could have a precedence. > > IMO preprocessor definitely should be the primary parser and let HTML embed > in it. In the case of Liquid, it happens to uses a syntax that’s compatible > to HTML; that’s fine, but it’s worth it or even necessary to add support > for multiple primary parsers because of it. As for precedence, it can be > customized by treesit-language-at-point-function. Thanks for the suggestion to use the preprocessor as the primary parser. So multiple primary parsers are not required anymore since other parsers are embedded to the primary parser ('define-treesit-generic-mode' sets the primary parser). And everything works for any embedded level: liquid -> html -> js -> jsdoc liquid -> html -> css liquid -> yaml #+begin_src emacs-lisp (define-treesit-generic-mode liquid-generic-ts-mode "Tree-sitter generic mode for Liquid templates." :lang 'liquid :source "https://github.com/hankthetank27/tree-sitter-liquid" :mode-remap '(html-mode mhtml-mode html-ts-mode mhtml-ts-mode) :name "Liquid" ;; TODO: :parent mhtml-ts-mode (treesit-parser-create 'html) (treesit-parser-create 'css) (treesit-parser-create 'javascript) (setq-local treesit-range-settings (treesit-range-rules :embed 'html :host 'liquid '(((template_content) @cap)) :embed 'javascript :host 'liquid '(((js_content) @cap)) :embed 'css :host 'liquid '(((style_content) @cap)) :embed 'javascript :host 'html '((script_element (start_tag (tag_name)) (raw_text) @cap)) :embed 'css :host 'html '((style_element (start_tag (tag_name)) (raw_text) @cap)))) (when (treesit-ready-p 'yaml t) (treesit-parser-create 'yaml) (setq-local treesit-range-settings (append treesit-range-settings (treesit-range-rules :embed 'yaml :host 'liquid '(((front_matter) @cap)))))) (setq-local treesit-font-lock-settings (append treesit-font-lock-settings html-ts-mode--font-lock-settings js--treesit-font-lock-settings (treesit-replace-font-lock-feature-settings (treesit-font-lock-rules :language 'css :override t :feature 'variable '((plain_value) @mhtml-ts-mode--colorize-css-value (color_value) @mhtml-ts-mode--colorize-css-value)) css--treesit-settings))) (setq-local treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list html-ts-mode--treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list js--treesit-font-lock-feature-list css--treesit-font-lock-feature-list)))) (when (treesit-ready-p 'jsdoc t) (treesit-parser-create 'jsdoc) (setq-local treesit-range-settings (append treesit-range-settings (treesit-range-rules :embed 'jsdoc :host 'javascript :local t `(((comment) @cap (:match ,js--treesit-jsdoc-beginning-regexp @cap))))))) (setq treesit-thing-settings (append `((liquid (sexp (not ,(rx bos (or "program") eos))) (list ,(rx bos (or "range" "if_statement" "for_loop_statement" "case_statement" "unless_statement" "capture_statement" "form_statement" "tablerow_statement" "paginate_statement") eos)))) mhtml-ts-mode--treesit-thing-settings)) (setq-local treesit-aggregated-outline-predicate `((liquid . ,(rx bos (or "if_statement" "for_loop_statement") eos)) (html . ,#'html-ts-mode--outline-predicate) (javascript . ,js-ts-mode--outline-predicate) (css . ,css-ts-mode--outline-predicate)))) #+end_src
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 29 Mar 2025 08:24:08 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 29 04:24:08 2025 Received: from localhost ([127.0.0.1]:56681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tyRU7-0000sg-PQ for submit <at> debbugs.gnu.org; Sat, 29 Mar 2025 04:24:08 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:54376) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1tyRU5-0000s5-9b for 77255 <at> debbugs.gnu.org; Sat, 29 Mar 2025 04:24:06 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-223a7065ff8so26901725ad.0 for <77255 <at> debbugs.gnu.org>; Sat, 29 Mar 2025 01:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743236639; x=1743841439; darn=debbugs.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=7d72sgwbOkJ+PLvj499S4DLrp+2xFl74WhSurNJ4vN8=; b=PvmD1/kGJCOxuiMyV5+vxAXN5PWEFDZFlyg6nFWzwpF3c7fdnZ/1LZmpTRngBtYvgk eTCDeGIb58r52Muzu4La8rVYAScETtJsr8yJpMVuITXtlRn65m4KzLQ82b34qiBUEwck OCvsg8xhRRx6ZSSrcACY+24lADooMoYI+QK84QQBiaxaokY9m2uMIVKTe9p8VKD+scF/ YFwLr17VC8Gg+EiBJdGP37jR1etFdPcCYjIT9sbJIyCmjvBGuXNNWSIzLpepvwWy/ofh z9xMl8Jr8VdfH42tv4xKW+v5S1sZLXJtao3yRVqCpi16QepsSa3YyUACUOU2DVUxtL6T WGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743236639; x=1743841439; 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=7d72sgwbOkJ+PLvj499S4DLrp+2xFl74WhSurNJ4vN8=; b=vr4SYaHGHGzvAHko3Q4pWhphiPkgxT+sAX8tul0wXiyeeFgcY9JEpA0QnugA93161f 8/UXcbolXArGqWNarJLUh4zehz4KNvnZVJPfBG1WtE/JZ6SNZlyRT/huWWzDZDD6fW4i 8lp86jqc89UkEpUJhpwn7fGmZxDycVjnewbrJgJKpKHLCXCP1/TakYWPEpg6O2fjBzBK 8PhYogBc4Xui3+/yRsssuj0Q2ifYvx7f/UHY3d4OeLA6LvFxutDdSC13QiaakAKe9oe/ om82bBwckHTQCIE0dAqj/A6DOtjhShWprPaOmGSGGH5TXUZkmqqaF5glgxyGNXV3Po8y /jgA== X-Gm-Message-State: AOJu0YyQnDUErQpDrhRN02kVFoTDJOdTgtzFff1Lvvsi0isL+3hVq98l 85Btkw1YIgn3+YaHmqBvkFZ4qfAhiWMLdV8+3t8NYRrDOjWpqgl7 X-Gm-Gg: ASbGncsSLHCENR9Etho8G4c+vxqiMntrfprK0MZI0uxSmv0SbUhV45pIK1BA9dqrleE lwRUswjekzN6AO4534zC9vHADEEtp671BI2Vx/8BoJ4JBmzmvhayStQkCVB1hBz2PPpJ3m2CRJv Dw6SvtT0wiOxg1sj4IKFn59XjolVNVTKsvCyCwRrm/TtW0V6GC51829uGDY6yKea/HSvEUqM5hQ FhqmbcoSBH4KX/D9DrjSlMoqcijaT/pzBYMR77qc/I8Z8wolIXOo64FhWxokj3QV3/CyEJ8koA4 kcgQaZ0ML4Xhr0ScuaPnagH9+5XpOLGhT/6a5pH+2f1VPajT7O5JyLgcW1fKtYtYSI9c X-Google-Smtp-Source: AGHT+IH8OayMm5CqBs6tEaQ30O800NUUCHp2ZzwdNAzmaWIg7YHl3kw/iMtlOPT1Q6y2xUfSdC7Emw== X-Received: by 2002:a17:903:228c:b0:224:1acc:14db with SMTP id d9443c01a7336-2292f974a50mr32357615ad.29.1743236638987; Sat, 29 Mar 2025 01:23:58 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:35ac:e739:c2c2:c415]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2291f1cf8f3sm30833505ad.120.2025.03.29.01.23.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Mar 2025 01:23:58 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\)) Subject: Re: bug#77255: Treesit font-lock override for embed ranges From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <87v7ruqor9.fsf@HIDDEN> Date: Sat, 29 Mar 2025 01:23:47 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <B771FEBB-420F-437F-8960-14074A0BA44C@HIDDEN> References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> <87v7ruqor9.fsf@HIDDEN> To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3826.400.131.1.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Mar 27, 2025, at 12:04=E2=80=AFPM, Juri Linkov <juri@HIDDEN> = wrote: >=20 >>> The commented out code shows attempts to use a negated :match >>> that is not supported. Also it seems a lambda for :pred is >>> also not supported. So needed to add a separate function: >>>=20 >>> #+begin_src emacs-lisp >>> (defun mhtml-ts-mode--not-match (node) >>> (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) >>> (treesit-node-text node t)))) >>> #+end_src >>>=20 >>> Then everything works: all HTML attributes are highlighted >>> except those that should highlight js code in them. >>=20 >> Looks reasonable to me. But if it=E2=80=99s a minor mode, we might = need to >> have a way to negate the change made to treesit-font-lock-settings? >> OTOH if we use :override, we might run into an override arm race when >> enabling multiple minor modes, etc. >=20 > We could declare that the last minor mode wins. But indeed still need > a way to restore the original treesit-font-lock-settings after = disabling > the minor mode. >=20 > BTW, I found another problem. Please confirm if the range rules allow > only one query per embed language, or I'm doing something wrong? That=E2=80=99s curious, even if you included multiple patterns in the = query, it=E2=80=99s still one query; and the range functions support = multiple captured ranges when setting up ranges. So something is wrong = here. (See treesit-query-range) I can look into this, but give me a few = days. > I tried two queries to enable the liquid parser in html nodes 'text' > and also in html attributes 'attribute_value': >=20 > #+begin_src emacs-lisp > (setq-local treesit-range-settings > (append treesit-range-settings > (treesit-range-rules > :embed 'liquid > :host 'html > `(((text) @cap1 > (:match ,(rx (or "{{" "}}" "{%" "%}")) @cap1)) > ((quoted_attribute_value > (attribute_value) @cap2) > (:match ,(rx (or "{{" "}}" "{%" "%}")) = @cap2)))))) > #+end_src >=20 > But it handles only one of these queries: when I remove the rule > for (text), it handles attribute_value, but when I remove the rule > for (attribute_value), it enables the liquid parser only for text. >=20 > This revealed another problem. Actually, Liquid is a preprocessor. > Since it can be embedded everywhere in every html node, not depending = on > the structure in the html parser, it would be more correct first to = use > the liquid parser, and then allow html+js+css parsers to handle > remaining parts. But both liquid and html parsers should apply > on the whole file. The only difference is that liquid has a higher > precedence to decide what overlapping parts belong to the liquid = parser. > Or maybe it makes sense to have two primary parsers? They both could > add own highlighting. And in regard to navigation, one of primary > parsers could have a precedence. IMO preprocessor definitely should be the primary parser and let HTML = embed in it. In the case of Liquid, it happens to uses a syntax that=E2=80= =99s compatible to HTML; that=E2=80=99s fine, but it=E2=80=99s worth it = or even necessary to add support for multiple primary parsers because of = it. As for precedence, it can be customized by = treesit-language-at-point-function. Yuan=
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 27 Mar 2025 19:08:44 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 15:08:44 2025 Received: from localhost ([127.0.0.1]:51376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txsap-0005gG-N7 for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 15:08:44 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:dc4:8::223]:59793) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1txsal-0005fy-Mu for 77255 <at> debbugs.gnu.org; Thu, 27 Mar 2025 15:08:40 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 1A6A120452; Thu, 27 Mar 2025 19:08:28 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: Yuan Fu <casouri@HIDDEN> Subject: Re: bug#77255: Treesit font-lock override for embed ranges In-Reply-To: <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> Organization: LINKOV.NET References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> Date: Thu, 27 Mar 2025 21:04:10 +0200 Message-ID: <87v7ruqor9.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieelvdduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgfgsehtkeertddtreejnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecuggftrfgrthhtvghrnhepieffteejgeehffejuedtiefhudekgeejteekiefgveeuheetvdefgeekkeevkedunecukfhppeeluddruddvledruddthedruddujeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeeluddruddvledruddthedruddujedphhgvlhhopehmrghilhdrghgrnhguihdrnhgvthdpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnsggprhgtphhtthhopeefpdhrtghpthhtohepvhdrphhuphhilhhlohesghhmrghilhdrtghomhdprhgtphhtthhopeejjedvheehseguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomh X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) >> The commented out code shows attempts to use a negated :match >> that is not supported. Also it seems a lambda for :pred is >> also not supported. So needed to add a separate function: >> >> #+begin_src emacs-lisp >> (defun mhtml-ts-mode--not-match (node) >> (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) >> (treesit-node-text node t)))) >> #+end_src >> >> Then everything works: all HTML attributes are highlighted >> except those that should highlight js code in them. > > Looks reasonable to me. But if it’s a minor mode, we might need to > have a way to negate the change made to treesit-font-lock-settings? > OTOH if we use :override, we might run into an override arm race when > enabling multiple minor modes, etc. We could declare that the last minor mode wins. But indeed still need a way to restore the original treesit-font-lock-settings after disabling the minor mode. BTW, I found another problem. Please confirm if the range rules allow only one query per embed language, or I'm doing something wrong? I tried two queries to enable the liquid parser in html nodes 'text' and also in html attributes 'attribute_value': #+begin_src emacs-lisp (setq-local treesit-range-settings (append treesit-range-settings (treesit-range-rules :embed 'liquid :host 'html `(((text) @cap1 (:match ,(rx (or "{{" "}}" "{%" "%}")) @cap1)) ((quoted_attribute_value (attribute_value) @cap2) (:match ,(rx (or "{{" "}}" "{%" "%}")) @cap2)))))) #+end_src But it handles only one of these queries: when I remove the rule for (text), it handles attribute_value, but when I remove the rule for (attribute_value), it enables the liquid parser only for text. This revealed another problem. Actually, Liquid is a preprocessor. Since it can be embedded everywhere in every html node, not depending on the structure in the html parser, it would be more correct first to use the liquid parser, and then allow html+js+css parsers to handle remaining parts. But both liquid and html parsers should apply on the whole file. The only difference is that liquid has a higher precedence to decide what overlapping parts belong to the liquid parser. Or maybe it makes sense to have two primary parsers? They both could add own highlighting. And in regard to navigation, one of primary parsers could have a precedence.
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 27 Mar 2025 04:20:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 27 00:20:58 2025 Received: from localhost ([127.0.0.1]:46188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txeje-0002DZ-Li for submit <at> debbugs.gnu.org; Thu, 27 Mar 2025 00:20:57 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:49402) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <casouri@HIDDEN>) id 1txejZ-0002CJ-4d for 77255 <at> debbugs.gnu.org; Thu, 27 Mar 2025 00:20:52 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-22622ddcc35so16103395ad.2 for <77255 <at> debbugs.gnu.org>; Wed, 26 Mar 2025 21:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743049243; x=1743654043; darn=debbugs.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=GOYstLcz8ONpMJM5uVTHkggW2iEO58FYgcGnWzJHhPE=; b=AAoT462QQqD4xmVtICkqu5jbWtNnsgdAw58OOnNAgmNibDkzakYrLQT+npo+4jACM3 TQVvUhJr6e3DNtzMXJUIiGK8iPs7DrnE5N6Qoffq62Sms0TepQeZ27LlmOGuVsM+WGUz RCCSNcGQgO9PqDmD2UB3cPW4Ve+e3DhUHb8ieNJ10ivrd/Zy1/Ct1Tf2OVlz2vyRzzEM kkSZpCbJSk2b1Rqfpr1Yrna8gN2sKD+v8ZySGzuzRsu+RUIGs0HTKOOQJWtZmSPHEy6w RSDUnECrsrEz6ucuigA0NOVx3wHb3TCWrZpqACQTGXqbDHYglHgdAhEFD3g6Aa1tAfL9 fOBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743049243; x=1743654043; 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=GOYstLcz8ONpMJM5uVTHkggW2iEO58FYgcGnWzJHhPE=; b=nPiQUUwvUfu9R67Joj7eECSNnN/Q8ir3GjSQFtaKtCFyqju8wlSclaKbBLELaatEYV ImfTZshLS30zWxN0j7OPRI6A0DZJWyJL4LYmIByt3+TzFae09fnZ6xRTsO2RovqW9mgy Zd6opbT5oU4szFn9duKf9AmvWjTR04rm7vqYR1Ssj9D3WGJcHdfiiZHttwN6PDA3QI2E Lp3SKe0c5RzY/PcPljhDRuWf/CZtbWaBZ4zdaiQCFqr979xAqdJE1OlLeATAyfJk5ml/ 3okCJJQXXSMzZxz39n4uRUfn3cEjN2xtSiL0d4lX/pwEECSSOqSjdw5OGmGs3+fYuG4G NWag== X-Gm-Message-State: AOJu0YxphZOXvyhuHhbjk8W6GJK4qq/XJ8MWbGtlwYI+LhR0f6C1CzdU 97EeyJVEMKO7tE01N5mxyOLVzKAqvWvlM0897UZJGkV42C2FtM2y X-Gm-Gg: ASbGnctT9StVy8DmTdVLlyuy/A4s4R/yMRGB88Dqu2N/2nP17U4aaSN+jpKwyNt3gW2 GgS38VqzZaglRLCoEhCyY4Af/9Gg4Ofd9a9ceJXeN1/DexziuNOBf5U8mqn5li3LaANyCv58lPE Iaza8cFX5l/hYf1POL+f6+FZJiCd3P4iz/6RJ/SLJjJ/lnlC4OmIe6nYbf8sljAO+QAO13rucnP jFlcndnF8wWUnAGfrCLFSUFwjIOL6QdoV6mQ5q+1ebDgmqtekkNEPT6x56stfkmE8ROgD2mix3o IO+XNwa4sl0bN0IEYP6bmB5EWdJZmY5AP+1JJ7JB/LGHWz7vDKsjWdEiACJPx/lrSFD8 X-Google-Smtp-Source: AGHT+IHiHK4LuIBTE8JauqUOLHv2AVnLqjwoK522RsjJbpto5E3Bq9brFRuuwU1YEUzO/ZZncDzEVA== X-Received: by 2002:a17:903:1c1:b0:210:f706:dc4b with SMTP id d9443c01a7336-228048ab247mr24937475ad.13.1743049242834; Wed, 26 Mar 2025 21:20:42 -0700 (PDT) Received: from smtpclient.apple ([2601:646:8f81:6120:b008:a4e4:1666:e0f6]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22780f4d606sm118727075ad.103.2025.03.26.21.20.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2025 21:20:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\)) Subject: Re: bug#77255: Treesit font-lock override for embed ranges From: Yuan Fu <casouri@HIDDEN> In-Reply-To: <87wmcc1cbx.fsf@HIDDEN> Date: Wed, 26 Mar 2025 21:20:31 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <A7E70567-FD85-418F-AFA2-61C1DD911959@HIDDEN> References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> To: Juri Linkov <juri@HIDDEN> X-Mailer: Apple Mail (2.3826.400.131.1.6) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77255 Cc: 77255 <at> debbugs.gnu.org, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) > On Mar 26, 2025, at 12:27=E2=80=AFAM, Juri Linkov <juri@HIDDEN> = wrote: >=20 >> It looks like we need a new keyword like ':override t' for >> 'treesit-range-rules' that would override host font-lock rules. >=20 > Or maybe not. I managed to do this without any changes in core. > Also not sure if such functions as = treesit-merge-font-lock-feature-list > and treesit-replace-font-lock-feature-settings could be used here. >=20 > The solution below works simply by replacing the html rule with > another rule that matches only HTML attributes that don't contain > js code: >=20 > #+begin_src emacs-lisp > (setq-local treesit-range-settings > (append treesit-range-settings > (treesit-range-rules > :embed 'javascript > :host 'html > :local t > `((attribute > (attribute_name) @_name > (:match ,(rx (or "x-data" "x-bind" = "x-text")) @_name) > (quoted_attribute_value > (attribute_value) @cap)))))) >=20 > (setq-local treesit-font-lock-settings > (mapcar (lambda (s) > (if (and (eq (treesit-query-language > = (treesit-font-lock-setting-query s)) > 'html) > (eq = (treesit-font-lock-setting-feature s) > 'string)) > (car (treesit-font-lock-rules > :language 'html > :override t > :feature 'string > `((attribute > (attribute_name) @_name > ;; (:match (not ,(rx (or = "x-data" "x-bind" "x-text"))) @_name) > ;; (:pred (lambda (node) > ;; (not = (string-match-p (rx (or "x-data" "x-bind" "x-text")) > ;; = (treesit-node-text node t)))) > ;; @_name) > (:pred mhtml-ts-mode--not-match = @_name) > (quoted_attribute_value) = @font-lock-string-face)))) > s)) > treesit-font-lock-settings)) > #+end_src >=20 > The commented out code shows attempts to use a negated :match > that is not supported. Also it seems a lambda for :pred is > also not supported. So needed to add a separate function: >=20 > #+begin_src emacs-lisp > (defun mhtml-ts-mode--not-match (node) > (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) > (treesit-node-text node t)))) > #+end_src >=20 > Then everything works: all HTML attributes are highlighted > except those that should highlight js code in them. Looks reasonable to me. But if it=E2=80=99s a minor mode, we might need = to have a way to negate the change made to treesit-font-lock-settings? = OTOH if we use :override, we might run into an override arm race when = enabling multiple minor modes, etc. Yuan=
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 26 Mar 2025 16:08:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 26 12:08:10 2025 Received: from localhost ([127.0.0.1]:44022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txTIY-0006oh-5E for submit <at> debbugs.gnu.org; Wed, 26 Mar 2025 12:08:10 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:50382) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <v.pupillo@HIDDEN>) id 1txTIU-0006nz-DH for 77255 <at> debbugs.gnu.org; Wed, 26 Mar 2025 12:08:06 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ac3b12e8518so296069066b.0 for <77255 <at> debbugs.gnu.org>; Wed, 26 Mar 2025 09:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743005280; x=1743610080; darn=debbugs.gnu.org; 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=NT58r+Zt7yZtjfGOYGDcYZ+VzqVFFuv2+fXlXvolwag=; b=TD2lPSLIzRz3gazTZL/irctJgOEtHvaLvOfn2r+3dxPpHI4x6RSvuaqw5/0wAU6ZBV oshjaXR1sqyPrrJEItA7PeQi00qA33SWtVleTs+Ag/DSeu/+YJlBPbKD3PVWR95YKU3w 3/n7r5dkETDNGoGvAPRu/keUmjYWbQpAb8MK39Co025dOvsUTp1u7aiNYXQ+rHGBsop2 ZZPratXVts76+VeLXmHq0EFXATtDkT4wMxePC117j1+hHQKGbF/opAk0bhy++QyXGxGe Jes76HN3OR6xomsAmp7FYC1RvdOQaL7FNnPTT05sEhJOvJpSPR9cApe4vzBt467fedJY 0Zew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743005280; x=1743610080; 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=NT58r+Zt7yZtjfGOYGDcYZ+VzqVFFuv2+fXlXvolwag=; b=c7yaoNjNvdDPeFeq5SCBMoy1at8njtuKG5xINbhmCCg/yCJZWb6yKrXA90EeV/rlpf Wlf3bLGGMBG2O6MkEAq7uCvf/Hq+57qKRv7Z+nBgHensYnMX+rzjUlsToS2lRuSzE129 xy3FZDwxqpw14BY2aiOR2CxpAlGSuJfq8d+IAtzTT5tx6I0X2wDD7NWUCxKUzoUMgu5c yrRxh9xb+Z7RmiOPadEp/I3/jbfaD0yqM4+9X4DEgnpGskJ3RAmtoT7fwdI4ctF6BLLH xG6xOJ3SoPNBGT/hQZCWRPt/Leyw2jsP47KGVQadJuFel0OGN4YZwu0UY/wGZGwqiKks XlyQ== X-Gm-Message-State: AOJu0Yz1e4WjXtlL52D3dwLkyZAoehjl8kwEYkyHIYbB1EWQYaljw7db aXYRKuX/1RAAPBKjE6dBn46QbgpGtR++JU05+gOZTj8mrfKFXobMHPt+ikcm X-Gm-Gg: ASbGncspxMg42V8yLU9igaygYR81iWy7NgvIhIr7xZvtcBa/IR4fUvXAmTdVIP22sJ3 YanO825hi5ohohqn7Z9gGhoeO+tUzDPPvcKR8n85nAoLCiGtdG3+Iib7EanPLlMPnJWQWArREnM 71+I0EgPyV5ug0sbGLwTkmowCtA318HhQn3LsdOuYl+9GoOL1NIh+JFkipASTZEqo54TH4zqR7F QPmU3G3Ox2LNi1P5DgFzRS+CS//FSTyQLhRegZHkyDjh5cuoVEYxANhg8c0BGCd56TjkW1ER5V0 FwihNhJ0DLAu6fM3A7Y8x/3py9/V2dMyJT288He3LlLqHVv6gRzbsvryNOpbyCml/DIsqQpcDZM SefQ6F8AN+lhNH9hPmkQ= X-Google-Smtp-Source: AGHT+IHGhQ2Ehrrd45FgU8yQLz7Azl0MqrNv0bN+DdfzUDhAlIv8KwjO7xm36MLBbTB+iahx6CD4iA== X-Received: by 2002:a17:906:4795:b0:ac3:b372:6d10 with SMTP id a640c23a62f3a-ac3f2081eaamr1923702766b.4.1743005279761; Wed, 26 Mar 2025 09:07:59 -0700 (PDT) Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac404959f47sm902768666b.170.2025.03.26.09.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Mar 2025 09:07:59 -0700 (PDT) From: Vincenzo Pupillo <v.pupillo@HIDDEN> To: 77255 <at> debbugs.gnu.org, Juri Linkov <juri@HIDDEN> Subject: Re: bug#77255: Treesit font-lock override for embed ranges Date: Wed, 26 Mar 2025 17:07:58 +0100 Message-ID: <1963203.7Z3S40VBb9@fedora> In-Reply-To: <87wmcc1cbx.fsf@HIDDEN> References: <87tt7h0xyq.fsf@HIDDEN> <87wmcc1cbx.fsf@HIDDEN> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 77255 Cc: Yuan Fu <casouri@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Caio Juri, In data mercoled=C3=AC 26 marzo 2025 08:27:14 Ora standard dell=E2=80=99Eur= opa centrale,=20 Juri Linkov ha scritto: > > It looks like we need a new keyword like ':override t' for > > 'treesit-range-rules' that would override host font-lock rules. >=20 > Or maybe not. I managed to do this without any changes in core. > Also not sure if such functions as treesit-merge-font-lock-feature-list > and treesit-replace-font-lock-feature-settings could be used here. >=20 treesit-replace-font-lock-feature-settings works reliably only if the=20 replacement is done for rules of the same language. So something like: #+begin_src emacs-lisp (setq-local liquid-ts-mode--font-lock-feature-list (treesit-replace-font-lo= ck- feature-settings (treesit-font-lock-rules :language 'html :override t :feature 'string `((attribute (attribute_name) @_name (:pred mhtml-ts-mode--not-match @_name) (quoted_attribute_value) @font-lock-string-face))) html-ts-mode--treesit-font-lock-settings) #+end_src Then: =20 (defvar mhtml-ts-mode--treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list liquid-ts-mode--treesit-font-lock-feature-list (treesit-merge-font-lock-feature-list js--treesit-font-lock-feature-list css--treesit-font-lock-feature-list)) "Settings for `treesit-font-lock-feature-list'.") However, we could modify treesit-replace-font-lock-feature-settings to chec= k=20 the language in addition to the feature. Vincenzo > The solution below works simply by replacing the html rule with > another rule that matches only HTML attributes that don't contain > js code: >=20 > #+begin_src emacs-lisp > (setq-local treesit-range-settings > (append treesit-range-settings > (treesit-range-rules >=20 > :embed 'javascript > :host 'html > :local t >=20 > `((attribute > (attribute_name) @_name > (:match ,(rx (or "x-data" "x-bind" "x-text")) > @_name) (quoted_attribute_value > (attribute_value) @cap)))))) >=20 > (setq-local treesit-font-lock-settings > (mapcar (lambda (s) > (if (and (eq (treesit-query-language > (treesit-font-lock-setting-query = s)) > 'html) > (eq (treesit-font-lock-setting-feature= s) > 'string)) > (car (treesit-font-lock-rules >=20 > :language 'html > :override t > :feature 'string >=20 > `((attribute > (attribute_name) @_name > ;; (:match (not ,(rx (or "x-data" > "x-bind" "x-text"))) @_name) ;; (:pred (lambda (node) > ;; (not (string-match-p = (rx > (or "x-data" "x-bind" "x-text")) ;; (treesit-node-text no= de > t)))) ;; @_name) > (:pred mhtml-ts-mode--not-match > @_name) (quoted_attribute_value) @font-lock-string-face)))) s)) > treesit-font-lock-settings)) > #+end_src >=20 > The commented out code shows attempts to use a negated :match > that is not supported. Also it seems a lambda for :pred is > also not supported. So needed to add a separate function: >=20 > #+begin_src emacs-lisp > (defun mhtml-ts-mode--not-match (node) > (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) > (treesit-node-text node t)))) > #+end_src >=20 > Then everything works: all HTML attributes are highlighted > except those that should highlight js code in them.
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at 77255) by debbugs.gnu.org; 26 Mar 2025 07:30:14 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 26 03:30:14 2025 Received: from localhost ([127.0.0.1]:41085 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1txLDK-00023o-6K for submit <at> debbugs.gnu.org; Wed, 26 Mar 2025 03:30:14 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:60093) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1txLDH-000205-6v for 77255 <at> debbugs.gnu.org; Wed, 26 Mar 2025 03:30:12 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id D4E2644346; Wed, 26 Mar 2025 07:30:01 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: 77255 <at> debbugs.gnu.org Subject: Re: bug#77255: Treesit font-lock override for embed ranges In-Reply-To: <87tt7h0xyq.fsf@HIDDEN> Organization: LINKOV.NET References: <87tt7h0xyq.fsf@HIDDEN> Date: Wed, 26 Mar 2025 09:27:14 +0200 Message-ID: <87wmcc1cbx.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieegleefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufgjohhffffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeffgeetfeevlefhleejfeeuheeiudeitdffhfdutdekfeffgffhveehteegueekheenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepfedprhgtphhtthhopehvrdhpuhhpihhllhhosehgmhgrihhlrdgtohhmpdhrtghpthhtoheptggrshhouhhrihesghhmrghilhdrtghomhdprhgtphhtthhopeejjedvheehseguvggssghughhsrdhgnhhurdhorhhg X-GND-Sasl: juri@HIDDEN X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 77255 Cc: Yuan Fu <casouri@HIDDEN>, Vincenzo Pupillo <v.pupillo@HIDDEN> X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) > It looks like we need a new keyword like ':override t' for > 'treesit-range-rules' that would override host font-lock rules. Or maybe not. I managed to do this without any changes in core. Also not sure if such functions as treesit-merge-font-lock-feature-list and treesit-replace-font-lock-feature-settings could be used here. The solution below works simply by replacing the html rule with another rule that matches only HTML attributes that don't contain js code: #+begin_src emacs-lisp (setq-local treesit-range-settings (append treesit-range-settings (treesit-range-rules :embed 'javascript :host 'html :local t `((attribute (attribute_name) @_name (:match ,(rx (or "x-data" "x-bind" "x-text")) @_name) (quoted_attribute_value (attribute_value) @cap)))))) (setq-local treesit-font-lock-settings (mapcar (lambda (s) (if (and (eq (treesit-query-language (treesit-font-lock-setting-query s)) 'html) (eq (treesit-font-lock-setting-feature s) 'string)) (car (treesit-font-lock-rules :language 'html :override t :feature 'string `((attribute (attribute_name) @_name ;; (:match (not ,(rx (or "x-data" "x-bind" "x-text"))) @_name) ;; (:pred (lambda (node) ;; (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) ;; (treesit-node-text node t)))) ;; @_name) (:pred mhtml-ts-mode--not-match @_name) (quoted_attribute_value) @font-lock-string-face)))) s)) treesit-font-lock-settings)) #+end_src The commented out code shows attempts to use a negated :match that is not supported. Also it seems a lambda for :pred is also not supported. So needed to add a separate function: #+begin_src emacs-lisp (defun mhtml-ts-mode--not-match (node) (not (string-match-p (rx (or "x-data" "x-bind" "x-text")) (treesit-node-text node t)))) #+end_src Then everything works: all HTML attributes are highlighted except those that should highlight js code in them.
bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 25 Mar 2025 18:29:53 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 25 14:29:53 2025 Received: from localhost ([127.0.0.1]:39973 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tx928-0002kS-88 for submit <at> debbugs.gnu.org; Tue, 25 Mar 2025 14:29:52 -0400 Received: from lists.gnu.org ([2001:470:142::17]:48496) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1tx922-0002k1-QG for submit <at> debbugs.gnu.org; Tue, 25 Mar 2025 14:29:50 -0400 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 <juri@HIDDEN>) id 1tx91w-0006PN-Nf for bug-gnu-emacs@HIDDEN; Tue, 25 Mar 2025 14:29:40 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1tx91r-0008Gr-TX for bug-gnu-emacs@HIDDEN; Tue, 25 Mar 2025 14:29:40 -0400 Received: by mail.gandi.net (Postfix) with ESMTPSA id 81824442B7 for <bug-gnu-emacs@HIDDEN>; Tue, 25 Mar 2025 18:29:30 +0000 (UTC) From: Juri Linkov <juri@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: Treesit font-lock override for embed ranges Organization: LINKOV.NET X-Debbugs-Cc: Yuan Fu <casouri@HIDDEN>, Vincenzo Pupillo <v.pupillo@HIDDEN> Date: Tue, 25 Mar 2025 20:25:17 +0200 Message-ID: <87tt7h0xyq.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-GND-State: clean X-GND-Score: 0 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduieeffeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecunecujfgurhephffvufhofffkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucggtffrrghtthgvrhhnpeejgffgtddthfelteejkeejueegvdekgfdufffgtdehvddtkeetveehgfffjeeuteenucfkphepledurdduvdelrddutdehrdduudejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledurdduvdelrddutdehrdduudejpdhhvghlohepmhgrihhlrdhgrghnughirdhnvghtpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhgspghrtghpthhtohepuddprhgtphhtthhopegsuhhgqdhgnhhuqdgvmhgrtghssehgnhhurdhorhhg X-GND-Sasl: juri@HIDDEN Received-SPF: pass client-ip=217.70.183.198; envelope-from=juri@HIDDEN; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) It looks like we need a new keyword like ':override t' for 'treesit-range-rules' that would override host font-lock rules. I'm trying to create a generic minor mode for AlpineJS framework where some known HTML attributes contain JS code. For example: <div x-data="{ open: false }"> <div x-bind:class="! open ? 'hidden' : ''"> <span x-text="new Date().getFullYear()"> This works nicely with this code added for testing to mhtml-ts-mode: #+begin_src emacs-lisp (setq-local treesit-range-settings (append treesit-range-settings (treesit-range-rules :embed 'javascript :host 'html :local t `((attribute (attribute_name) @_name (:match ,(rx (or "x-data" "x-bind" "x-text")) @_name) (quoted_attribute_value (attribute_value) @cap)))))) #+end_src But the problem is that its highlighting is not visible because host html-ts-mode font-lock overrides embedded js-ts-mode font-lock. html-ts-mode--font-lock-settings contains: :language 'html :override t :feature 'string `((quoted_attribute_value) @font-lock-string-face) So only the whole attribute is highlighted by font-lock-string-face that overrides js highlighting. Probably there is no way to add ':override t' to all 'javascript' rules in 'js--treesit-font-lock-settings', like ':override t' is already added to all 'jsdoc' rules in 'js--treesit-font-lock-settings'.
Juri Linkov <juri@HIDDEN>
:casouri@HIDDEN, v.pupillo@HIDDEN, bug-gnu-emacs@HIDDEN
.
Full text available.casouri@HIDDEN, v.pupillo@HIDDEN, bug-gnu-emacs@HIDDEN
:bug#77255
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.