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 16:03:43 +0100 Message-ID: <87o7shx580.fsf@thornhill.no> References: <87sfhudrfu.fsf@thornhill.no> <_KSXcXGtjgQ4mzy-Ml9kIV0QngRcfhNomsCAtEhd7ZAP6ih86_WavpD-qSNN-MnXBLi0VACZ57_Ig4MkuoD5FB5qk80Y7C-LYaZrZRvSdK8=@rjt.dev> <4pslNusoayXbQq867kk1hbmFpD9rInmrKFngvhWbFFEFg-V1SrZLqJ47TyJDGrFal86hf7cLAGAD_KiCUyCEh52J45_tu4wAQ9HXpkIiFzI=@rjt.dev> <87sfhuvt0h.fsf@thornhill.no> <3b83163d-1add-bf14-1376-60e391370d1a@secure.kjonigsen.net> 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="4390"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 59833@debbugs.gnu.org, jostein@kjonigsen.net To: Jostein =?UTF-8?Q?Kj=C3=B8nigsen?= , Randy Taylor Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 05 16:04:37 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 1p2D1I-0000tK-CR for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Dec 2022 16:04:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p2D1B-0007RC-Sk; Mon, 05 Dec 2022 10:04:29 -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 1p2D0k-0007OA-PJ for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 10:04: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 1p2D0k-00053b-H3 for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 10:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p2D0k-0004BF-8x for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2022 10:04: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 15:04: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.167025262916063 (code B ref 59833); Mon, 05 Dec 2022 15:04:02 +0000 Original-Received: (at 59833) by debbugs.gnu.org; 5 Dec 2022 15:03:49 +0000 Original-Received: from localhost ([127.0.0.1]:36563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2D0X-0004B1-87 for submit@debbugs.gnu.org; Mon, 05 Dec 2022 10:03:49 -0500 Original-Received: from out-18.mta0.migadu.com ([91.218.175.18]:17292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p2D0U-0004Av-ME for 59833@debbugs.gnu.org; Mon, 05 Dec 2022 10:03:48 -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=1670252624; 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=q0DWaT4i+z5/tOm1yiaggFAQUbuMZVvPRms6jr3u0Ac=; b=JMIDHSVWATut3WVDbZVjR6rEMqPrY0rV6kKjij+q1QNnqRJCJA7151LOI5TlkqakTYChei whi5qYfkiu/R/9EFnjXdcVdqymFqs9T6+0tt9T0TW8pu/JBbFicPRJDNAYkrnP5ONaZs5T +lD6msLwqAzhDcvPui5gM7YUVbgyYCWqvzs1DB00W0aMfiz70ubSMRkD2q8BjYs7quZgRw ixt1AufacrGuyF4vf0FSn1cZ9MENZKdg86J8Yq+3nVKQZ/jHV7QixQ1tkPR9ai5gVfrc48 lHjbmFjVJfJlv/vrlGrT+emnZNLw0fNtWnfsWyl8cf9uAKGwhQGJWunp8o7ViA== In-Reply-To: <3b83163d-1add-bf14-1376-60e391370d1a@secure.kjonigsen.net> 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:250039 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jostein Kj=C3=B8nigsen writes: > On 05.12.2022 15:42, Randy Taylor wrote: >> >> Thanks, I meant just the treesit-font-lock-feature-list variable :) (so = moving pair before string). >> >> Having the font-lock settings alphabetized too is great, but I remember = running into some highlighting issues depending on the order of things. >> For example, since error is above number, the number face will not be hi= ghlighted as error when an error occurs. >> >> Try: >> { >> "test": 2 >> } >> >> and remove the colon. Before your patch, the entire line is red. After, = only "test" is red. >> >> So in general, I think we should stick all :overrides at the bottom >> of that list (with error being the ultimate one), and keep everything >> above and below alphabetized, but separately, which is how I >> organized json-ts-mode. > Good observation. Agreed. Yes ok ok ;-) >> >> Are you guys talking about the json-mode package? Jostein mentioned >> "Emacs still defaults to json-mode", but when I open a JSON file I >> get js-json-mode, which is what I assumed he meant. js-json-mode is >> what I was trying to match in json-ts-mode. > > I've never heard of js-json-mode until today. I always use json-mode=20 > (which AFAIK) is still the default for json-files, unless overridden in=20 > your own .emacs setup. > > I can see that in Emacs git right now, json-ts-mode behaves closely to=20 > js-json-mode. I honestly expected it to match the Emacs-default=20 > json-mode though, and found the current highlighting ... somewhat=20 > unexpected. > > IMO, yes the keys are technically speaking strings, but the are=20 > predominantly and semantically keys, and IMO should be highlighted as=20 > such. Just like json-mode does. > > I realise this is somewhat subjective and preferential, but as far as my= =20 > preference goes, I clearly prefer json-mode over js-json-mode, and as=20 > such also prefer the current patch-sets for json-ts-mode which Theo has=20 > submitted. > > (On my part we can avoid side-tracking related to why there are multiple= =20 > json-modes, unless has a deep need to contextualize these changes=20 > related to those ;) ) > Yeah js-json-mode is a lot simpler, and is imo too simple. The json-mode is not infact default in emacs, but there are two, one in melpa and one in elpa, IIRC. Anyway, last patch for now - are you both satisfied with this one? Theo --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-back-in-font-locking-for-pair-in-json-ts-mode.patch >From ff88a7ca0d331b25579b5bbd7f90e2a7e31d109f Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 5 Dec 2022 15:59:41 +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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/json-ts-mode.el b/lisp/progmodes/json-ts-mode.el index 101e873cf6..440ffb3128 100644 --- a/lisp/progmodes/json-ts-mode.el +++ b/lisp/progmodes/json-ts-mode.el @@ -93,6 +93,10 @@ json-ts-mode--font-lock-settings :override t '((escape_sequence) @font-lock-escape-face) :language 'json + :feature 'pair + :override t + `((pair key: (_) @font-lock-variable-name-face)) + :language 'json :feature 'error :override t '((ERROR) @font-lock-warning-face)) @@ -156,7 +160,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 pair string) (escape-sequence) (bracket delimiter error))) -- 2.34.1 --=-=-=--