unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Randy Taylor <dev@rjt.dev>
To: Theodor Thornhill <theo@thornhill.no>
Cc: Yuan Fu <casouri@gmail.com>,
	59833@debbugs.gnu.org, jostein@kjonigsen.net
Subject: bug#59833: 29.0.60; json-ts-mode fontifies everything as string
Date: Mon, 05 Dec 2022 14:42:37 +0000	[thread overview]
Message-ID: <BPRmJYgr6L_VCd6CiqsamX8fMCw-z9OJl3xJpJ1_sZaCQvGTqHxMeF-Fuaa6FEaHoHqxxjBheWtZqWTRxvcwJZyqW_bIE4oI2Dzkzgo01Tg=@rjt.dev> (raw)
In-Reply-To: <87sfhuvt0h.fsf@thornhill.no>

On Monday, December 5th, 2022 at 09:12, Theodor Thornhill <theo@thornhill.no> wrote:
> 
> 
> Randy Taylor dev@rjt.dev writes:
> 
> > On Monday, December 5th, 2022 at 08:52, Randy Taylor dev@rjt.dev wrote:
> > 
> > > On Monday, December 5th, 2022 at 06:24, Theodor Thornhill theo@thornhill.no wrote:
> > > 
> > > > Jostein Kjønigsen jostein@secure.kjonigsen.net writes:
> > > > 
> > > > > Hey everyone.
> > > > > 
> > > > > When opening a JSON-file in a build from emacs git emacs-29
> > > > > release-branch, Emacs still defaults to json-mode.
> > > > > 
> > > > > Fontification in json-mode looks correct and proper.
> > > > > 
> > > > > When trying to insteas use json-ts-mode, literally everything is
> > > > > fontified as strings.
> > > > > 
> > > > > When I change the code to disable the string-fontification rule, this
> > > > > yields a buffer where everything is fontified using default-face. That
> > > > > is, no other fontification is taking place.
> > > > > 
> > > > > Have this mode really been tested? Should it be working? Or is there an
> > > > > error on my end?
> > > > > 
> > > > > Could someone else please give json-ts-mode a try?
> > > > 
> > > > Yeah, you are correct. It seems we've had a regression in this commit,
> > > > 0ed313642227afdeccf48057eea458edca9d2962.
> > > > 
> > > > I believe this is the offending commit - what do you think, Randy?
> > > > 
> > > > Specifically the lhs should be fontified differently than the rhs, so
> > > > not everything is a string.
> > > > 
> > > > Do you want to do that, Randy, or should I?
> > > > 
> > > > Theo
> > > 
> > > Can someone show me an example JSON file that shows this problem? Everything looks the same for me in json-mode and json-ts-mode, except for the json-ts-mode extras (even with Theo's patch) both with my own Emacs config and 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.

I was even restarting and it wasn't picking up the changes for some reason.

> 
> > Looks good to me (although it would be nice to keep treesit-font-lock-feature-list alphabetized Theo ;)).
> 
> 
> See new patch!

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 highlighted 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.

> 
> > json-mode still fontifies pretty much everything as a string though (at least for me).
> 
> 
> Not for me. I get number-face, bracket-face, constant-face,
> warning-face. Don't you?

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.

> 
> Will you commit this, Yuan?
> 
> Theo





  reply	other threads:[~2022-12-05 14:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 10:40 bug#59833: 29.0.60; json-ts-mode fontifies everything as string Jostein Kjønigsen
2022-12-05 11:24 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 11:35   ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 11:53     ` Jostein Kjønigsen
2022-12-05 12:06       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 13:52   ` Randy Taylor
2022-12-05 13:58     ` Randy Taylor
2022-12-05 14:12       ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 14:42         ` Randy Taylor [this message]
2022-12-05 14:52           ` Jostein Kjønigsen
2022-12-05 15:00             ` Eli Zaretskii
2022-12-05 15:01             ` Randy Taylor
2022-12-05 15:03             ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 15:35               ` Randy Taylor
2022-12-05 15:37                 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 19:57                   ` Yuan Fu
2022-12-05 20:14                     ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05 20:19                       ` Randy Taylor
2022-12-05 20:22                         ` Yuan Fu
2022-12-05 20:38                           ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BPRmJYgr6L_VCd6CiqsamX8fMCw-z9OJl3xJpJ1_sZaCQvGTqHxMeF-Fuaa6FEaHoHqxxjBheWtZqWTRxvcwJZyqW_bIE4oI2Dzkzgo01Tg=@rjt.dev' \
    --to=dev@rjt.dev \
    --cc=59833@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=jostein@kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).