unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: 71784@debbugs.gnu.org, spacibba@aol.com
Subject: bug#71784: 31.0.50; Inconsistent fontification for field_identifier in c++-ts-mode
Date: Sun, 04 Aug 2024 10:13:55 +0300	[thread overview]
Message-ID: <86ikwgu5e4.fsf@gnu.org> (raw)
In-Reply-To: <FD316A3D-A4A7-44B1-B28A-B78A9E96C072@gmail.com> (message from Yuan Fu on Tue, 16 Jul 2024 23:27:37 -0700)

tags 71784 wontfix
close 71784
thanks

> Cc: 71784@debbugs.gnu.org
> From: Yuan Fu <casouri@gmail.com>
> Date: Tue, 16 Jul 2024 23:27:37 -0700
> 
> 
> 
> > On Jun 27, 2024, at 7:33 AM, Ergus <spacibba@aol.com> wrote:
> > 
> > Hi Yuan:
> > 
> > Very thanks for replying
> > 
> > On Thu, Jun 27, 2024 at 12:16:13AM GMT, Yuan Fu wrote:
> >> 
> >> 
> >>> On Jun 26, 2024, at 7:13 AM, Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs@gnu.org> wrote:
> >>> 
> >>> 
> >>> Hi:
> >>> 
> >>> Using the c++-ts-mode I found that there is some inconsistent
> >>> fontification for the `fields_identifier`:
> >>> 
> >>> See the fontification in this example with `emacs -Q`.
> >>> 
> >>> ```test.cpp
> >>> 
> >>> std::string key;
> >>> bool inserted;
> >>> 
> >>> struct name_t {
> >>> std::string key;
> >>> bool inserted;
> >>> };
> >>> 
> >>> name_t keys = {"aaa", true};
> >>> 
> >>> keys.inserted = false;
> >>> bool a = keys.inserted;
> >>> ```
> >>> 
> >>> 1. The `keys.inserted` values are shown differently before or after the
> >>> = (the inserted word is fontified is some cases, but not in all)
> >> 
> >> What’s the value of treesit-font-lock-level for you? If it’s 4, they
> >> should be fontified the same. On level 3, only LHS is fontified.
> >> 
> > You are right; it is 3 in my system.
> > 
> > However I would expect that treesit-font-lock-level will be equivalent
> > somehow to using font-lock-maximum-decoration with similar value.
> 
> It is, level 3 for treesit-font-lock generally try to be equivalent to the existing major modes; and level 4 adds additional fontification that’s usually only possible with tree-sitter. At least that’s the suggestion, I don’t know if major mode writers out there are following this suggestion.
> 
> > 
> > I think it is confusing having two different fontifications for the same
> > variable due to their position. The colors are supposed to be a sort of
> > hint or help for the programmer eyes; not just a decoration right?
> 
> True, but: Highlighting all occurrences of properties/fields is a bit too much highlight IMO, and it isn’t done in most major modes, so I put it on level 4. On the default font-lock level, it’s helpful to highlight variable assignment/definition. You’re free to enable the property feature and disable assignment feature, which should get you what you want; but for the default, I think the current configuration is more appropriate.
> 
> > 
> >>> 
> >>> 2. The variable names are fontified differently outside or
> >>> inside the struct.
> >> 
> >> I mean, the “variable name” inside a structure is a field, not a
> >> variable, so it makes sense that they are fontified
> >> differently. Variable has font-lock-variable-name-face, field has
> >> font-lock-field-name-face. Also variable and field face are the same in
> >> the default theme, so they should look the same nevertheless.
> >> 
> > Probably what annoys me is the difference with the previous behavior in
> > this case. A field is also a variable in some sense for C++. There is
> > not much difference with a variable in a namespace or a static variable
> > in a class... 
> > Does it makes sense not to colorize these "field" and LHS on level 3
> > (like it used to be in c++-mode)? But put the new fontifications all
> > together in level 4? In that way everything will be fontified in level 4
> > and will become immediately consistent.
> 
> I’m sure this makes sense to you, but the nature of these things is that different people has different senses, so what makes sense to you might not make sense to others, and vice versa. To me, highlighting assignments is useful, and I don’t really notice the mismatch that bothers you. Unless many people complain about it, I don’t want to change the default behavior because of the reason I mentioned earlier. Again, this thing is highly personal and I don’t think there’s a fit-all solution.
> 
> >>> 
> >>> 3. The escape sequence (\t) is fontified differently to the rest of the
> >>> text inside the string. I don't know if that is intentional or not. If
> >>> it is intentional, just ignore this comment.
> >> 
> >> Yeah it’s intentional.
> >> 
> > Ok, good! Again, (just as a suggestion) it makes sense to move this new
> > fontification to level 4 as well?
> 
> IIRC many major modes do highlight escapes, so I put it on level 3.
> 
> >>> 
> >>> The inconsistencies 1 and 2 are not only different to c++-mode but they
> >>> are semantically incorrect.
> >> 
> >> Yuan
> > 
> > 
> > Just to mention: I am not wondering about the match/compatibility with
> > c++-mode. I am only concerned about the semantic coherence of the
> > fontification; which is supposed to be somehow helpful, not confusing.
> 
> I definitely appreciate the perspective you provided; however, unless there are enough people cares to complain about this, I don’t want to change the defaults. Plus it’s quite easy to remove: just disable the assignment feature.

No further comments, so I think we don't want to make this change, and
I'm therefore closing this bug.

Thanks.





      reply	other threads:[~2024-08-04  7:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87pls394h0.fsf.ref@aol.com>
2024-06-26 14:13 ` bug#71784: 31.0.50; Inconsistent fontification for field_identifier in c++-ts-mode Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-26 15:46   ` Eli Zaretskii
2024-06-26 22:24     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-27  7:16   ` Yuan Fu
2024-06-27 14:33     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-17  6:27       ` Yuan Fu
2024-08-04  7:13         ` Eli Zaretskii [this message]

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=86ikwgu5e4.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=71784@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=spacibba@aol.com \
    /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).