From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59833: 29.0.60; json-ts-mode fontifies everything as string Date: Mon, 05 Dec 2022 15:12:46 +0100 Message-ID: <87sfhuvt0h.fsf@thornhill.no> References: <87sfhudrfu.fsf@thornhill.no> <_KSXcXGtjgQ4mzy-Ml9kIV0QngRcfhNomsCAtEhd7ZAP6ih86_WavpD-qSNN-MnXBLi0VACZ57_Ig4MkuoD5FB5qk80Y7C-LYaZrZRvSdK8=@rjt.dev> <4pslNusoayXbQq867kk1hbmFpD9rInmrKFngvhWbFFEFg-V1SrZLqJ47TyJDGrFal86hf7cLAGAD_KiCUyCEh52J45_tu4wAQ9HXpkIiFzI=@rjt.dev> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18493"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 59833@debbugs.gnu.org, jostein@kjonigsen.net To: Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 05 15:13:18 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1p2CDd-0004ap-J8 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Dec 2022 15:13:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2CDS-0006ZA-Ui; Mon, 05 Dec 2022 09:13:06 -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 1p2CDP-0006Yi-Cg for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 09:13:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p2CDP-0002P6-24 for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 09:13:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2CDO-0001JE-CN for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 09:13:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Dec 2022 14:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59833 X-GNU-PR-Package: emacs Original-Received: via spool by 59833-submit@debbugs.gnu.org id=B59833.16702495745024 (code B ref 59833); Mon, 05 Dec 2022 14:13:02 +0000 Original-Received: (at 59833) by debbugs.gnu.org; 5 Dec 2022 14:12:54 +0000 Original-Received: from localhost ([127.0.0.1]:36240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2CDF-0001Iy-O5 for submit@debbugs.gnu.org; Mon, 05 Dec 2022 09:12:54 -0500 Original-Received: from out2.migadu.com ([188.165.223.204]:22157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2CDB-0001Ir-Qs for 59833@debbugs.gnu.org; Mon, 05 Dec 2022 09:12:52 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1670249568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Zqo2tddyBPFn2eATg/8YloGwGNLSwhtZJ1+vwP0D0WU=; b=x+82siGDN9ZNEf1nshuX4pJNindL90Kf+bYTw0plYmJhi8zoRMpcmDzHy0Xi4Gp9RA5dHq 2vlOvBxP1+OxNVJH5id+D6vgX7Q0AwfE10yx4SDyRrOszjgXoZIRgvWsdmAxlQQL1LpfFi B+OS2fC6ZUBpGM85NLerk+1vuMS+oHorB4gzBEO+UTi76xc71vWILHwQI5ZPUmE5um4zOT shXSVSzZnd9Jx9nL9x8S8jTI0KyOKmS95pSISzJ5ztkp27mRrWgTkIkLasfKj0pmeBjbJP nHyaf7WUgXa4ddCDzEnb5xEYr+lhzdv3LhcEu7L6Kr1HBt7gCUsISwb4HXgA0Q== In-Reply-To: <4pslNusoayXbQq867kk1hbmFpD9rInmrKFngvhWbFFEFg-V1SrZLqJ47TyJDGrFal86hf7cLAGAD_KiCUyCEh52J45_tu4wAQ9HXpkIiFzI=@rjt.dev> X-Migadu-Flow: FLOW_OUT X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250028 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Randy Taylor writes: > On Monday, December 5th, 2022 at 08:52, Randy Taylor wrote: >>=20 >> On Monday, December 5th, 2022 at 06:24, Theodor Thornhill theo@thornhill= .no wrote: >>=20 >> > Jostein Kj=C3=B8nigsen jostein@secure.kjonigsen.net writes: >> >=20 >> > > Hey everyone. >> > >=20 >> > > When opening a JSON-file in a build from emacs git emacs-29 >> > > release-branch, Emacs still defaults to json-mode. >> > >=20 >> > > Fontification in json-mode looks correct and proper. >> > >=20 >> > > When trying to insteas use json-ts-mode, literally everything is >> > > fontified as strings. >> > >=20 >> > > When I change the code to disable the string-fontification rule, this >> > > yields a buffer where everything is fontified using default-face. Th= at >> > > is, no other fontification is taking place. >> > >=20 >> > > Have this mode really been tested? Should it be working? Or is there= an >> > > error on my end? >> > >=20 >> > > Could someone else please give json-ts-mode a try? >> >=20 >> > Yeah, you are correct. It seems we've had a regression in this commit, >> > 0ed313642227afdeccf48057eea458edca9d2962. >> >=20 >> > I believe this is the offending commit - what do you think, Randy? >> >=20 >> > Specifically the lhs should be fontified differently than the rhs, so >> > not everything is a string. >> >=20 >> > Do you want to do that, Randy, or should I? >> >=20 >> > Theo >>=20 >>=20 >> Can someone show me an example JSON file that shows this problem? Everyt= hing looks the same for me in json-mode and json-ts-mode, except for the js= on-ts-mode extras (even with Theo's patch) both with my own Emacs config an= d emacs -Q. I must be doing something very silly. > > Scratch that, I got Theo's patch working, needed to rebuild. No need to rebuild. Just C-M-x the defvar and revert buffer. > Looks good to me (although it would be nice to keep treesit-font-lock-fea= ture-list alphabetized Theo ;)). > See new patch! > json-mode still fontifies pretty much everything as a string though (at l= east for me). Not for me. I get number-face, bracket-face, constant-face, warning-face. Don't you? Will you commit this, Yuan? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-back-in-font-locking-for-pair-in-json-ts-mode.patch >From 60b9dfeaec8d194c0b162f3eaa4ae4a4736d68e9 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 5 Dec 2022 12:34:08 +0100 Subject: [PATCH] Add back in font-locking for pair in json-ts-mode * lisp/progmodes/json-ts-mode.el (json-ts-mode--font-lock-settings): Add back in removed pair font-lock code. Also alphabetize features. (json-ts-mode): Use the new feature. (bug#59833) --- lisp/progmodes/json-ts-mode.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..0ce820bafb 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -78,24 +78,30 @@ json-ts-mode--font-lock-settings '((["[" "]" "{" "}"]) @font-lock-bracket-face) :language 'json :feature 'constant + :override t '([(null) (true) (false)] @font-lock-constant-face) :language 'json :feature 'delimiter '((["," ":"]) @font-lock-delimiter-face) :language 'json - :feature 'number - '((number) @font-lock-number-face) - :language 'json - :feature 'string - '((string) @font-lock-string-face) + :feature 'error + :override t + '((ERROR) @font-lock-warning-face) :language 'json :feature 'escape-sequence :override t '((escape_sequence) @font-lock-escape-face) :language 'json - :feature 'error + :feature 'number :override t - '((ERROR) @font-lock-warning-face)) + '((number) @font-lock-number-face) + :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face)) + :language 'json + :feature 'string + '((string) @font-lock-string-face)) "Font-lock settings for JSON.") (defun json-ts-mode--imenu-1 (node) @@ -156,7 +162,7 @@ json-ts-mode ;; Font-lock. (setq-local treesit-font-lock-settings json-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '((constant number string) + '((constant number string pair) (escape-sequence) (bracket delimiter error))) -- 2.34.1 --=-=-=--