* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. [not found] <87h6et6550.fsf.ref@aol.com> @ 2024-05-19 18:14 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-19 18:36 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-19 18:14 UTC (permalink / raw) To: 71070 Following up the conversation in the develops mailing list I will report this issue still happening: In c++-ts-mode, the namespaces are not fontified like in c++-mode (i.e in std::string the `std` used to have font-lock-constant-face while `string` used to have font-lock-type-face). It seems like tresitter identifies them properly like (namespace_identifier) and (type_identifier), but the fontification rule is wrong. There was an attempt to fix it in c6a5aae3da17459be7550c but the issue is still there. Best, Ergus ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-19 18:14 ` bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-19 18:36 ` Eli Zaretskii 2024-05-19 19:00 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-05-19 18:36 UTC (permalink / raw) To: Ergus, Yuan Fu; +Cc: 71070 > Date: Sun, 19 May 2024 20:14:19 +0200 > From: Ergus via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> > > > Following up the conversation in the develops mailing list I will report > this issue still happening: > > In c++-ts-mode, the namespaces are not fontified like in c++-mode > > (i.e in std::string the `std` used to have font-lock-constant-face while > `string` used to have font-lock-type-face). Why do you think std should be in font-lock-constant-face? The name of a namespace is not a constant, it's an identifier. ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-19 18:36 ` Eli Zaretskii @ 2024-05-19 19:00 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-19 19:13 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-19 19:00 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Yuan Fu, 71070 On Sun, May 19, 2024 at 09:36:07PM GMT, Eli Zaretskii wrote: >> Date: Sun, 19 May 2024 20:14:19 +0200 >> From: Ergus via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org> >> >> >> Following up the conversation in the develops mailing list I will report >> this issue still happening: >> >> In c++-ts-mode, the namespaces are not fontified like in c++-mode >> >> (i.e in std::string the `std` used to have font-lock-constant-face while >> `string` used to have font-lock-type-face). > >Why do you think std should be in font-lock-constant-face? The name >of a namespace is not a constant, it's an identifier. Hi Eli: That's how namespaces are fontified in the c++-mode. Not telling it is correct, wrong or if needs improvement; just that c++-ts-mode is not doing in the same way. Try this: ```main.cpp const std::string a; class myclass { std::time::timespec var; }; int main() { std::string b = 1; } ``` and then M-x c++-ts-mode you will see the difference. ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-19 19:00 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-19 19:13 ` Eli Zaretskii 2024-05-19 21:36 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-05-19 19:13 UTC (permalink / raw) To: Ergus; +Cc: casouri, 71070 > Date: Sun, 19 May 2024 21:00:42 +0200 > From: Ergus <spacibba@aol.com> > Cc: Yuan Fu <casouri@gmail.com>, 71070@debbugs.gnu.org > > >Why do you think std should be in font-lock-constant-face? The name > >of a namespace is not a constant, it's an identifier. > > Hi Eli: > > That's how namespaces are fontified in the c++-mode. Not telling it is > correct, wrong or if needs improvement; just that c++-ts-mode is not > doing in the same way. > > Try this: > > ```main.cpp > > const std::string a; > > class myclass { > std::time::timespec var; > }; > > int main() > { > std::string b = 1; > > > } > ``` > > and then M-x c++-ts-mode you will see the difference. No one said that what c++-mode does is necessarily correct. maybe it is, maybe it isn't. How do other C++ IDEs fontify namespace names? ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-19 19:13 ` Eli Zaretskii @ 2024-05-19 21:36 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-20 11:11 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-19 21:36 UTC (permalink / raw) To: Eli Zaretskii; +Cc: casouri, 71070 On Sun, May 19, 2024 at 10:13:45PM GMT, Eli Zaretskii wrote: >> Date: Sun, 19 May 2024 21:00:42 +0200 >> From: Ergus <spacibba@aol.com> >> Cc: Yuan Fu <casouri@gmail.com>, 71070@debbugs.gnu.org >> >> >Why do you think std should be in font-lock-constant-face? The name >> >of a namespace is not a constant, it's an identifier. >> >> Hi Eli: >> >> That's how namespaces are fontified in the c++-mode. Not telling it is >> correct, wrong or if needs improvement; just that c++-ts-mode is not >> doing in the same way. >> >> Try this: >> >> ```main.cpp >> >> const std::string a; >> >> class myclass { >> std::time::timespec var; >> }; >> >> int main() >> { >> std::string b = 1; >> >> >> } >> ``` >> >> and then M-x c++-ts-mode you will see the difference. > >No one said that what c++-mode does is necessarily correct. maybe it >is, maybe it isn't. > >How do other C++ IDEs fontify namespace names? Hi Eli: Every editor-ide has its own approach for this. But emacs has it own flavor and the ts-* intention was to keep it as close as possible to the status-quo; that's why I am reporting it here. There are many details missing in the c/c++-ts-mode compared to c-mode... but I understand that some of them are WIP while others are just too complex to port. My main concern here is that this seemed like a simple issue considering that treesitter recognizes the namespace correctly. But the Yuan's fix didn't work; so maybe there is a detail we are missing here, or that needs extra documentation? Or in the worst case some detail/issue broken in the ts api? Best, Ergus ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-19 21:36 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-20 11:11 ` Eli Zaretskii 2024-05-21 23:27 ` Dmitry Gutov 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-05-20 11:11 UTC (permalink / raw) To: Ergus; +Cc: casouri, 71070 > Date: Sun, 19 May 2024 23:36:41 +0200 > From: Ergus <spacibba@aol.com> > Cc: casouri@gmail.com, 71070@debbugs.gnu.org > > On Sun, May 19, 2024 at 10:13:45PM GMT, Eli Zaretskii wrote: > >No one said that what c++-mode does is necessarily correct. maybe it > >is, maybe it isn't. > > > >How do other C++ IDEs fontify namespace names? > > Hi Eli: > > Every editor-ide has its own approach for this. But emacs has it own > flavor and the ts-* intention was to keep it as close as possible to the > status-quo; that's why I am reporting it here. > > There are many details missing in the c/c++-ts-mode compared to > c-mode... but I understand that some of them are WIP while others are > just too complex to port. I understand all that, but still: can you (or someone else) answer my question about the accepted practices of IDEs in this matter: do they highlight the namespace identifiers differently than other identifiers, or do they use the same highlighting? It is IMO important to know what are the accepted practices, to deal with this issue in a proper perspective. > My main concern here is that this seemed like a simple issue considering > that treesitter recognizes the namespace correctly. But the Yuan's fix > didn't work; so maybe there is a detail we are missing here, or that > needs extra documentation? Or in the worst case some detail/issue broken > in the ts api? I don't know. In particular, I don't know what specific aspects of this did Yuan try to fix. Yuan is CC'ed and will hopefully chime in and answer these questions. Meanwhile we should make up our minds regarding the desired behavior, which is mostly independent of what Yuan tried to do and even of what c++-mode does. Thanks. ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-20 11:11 ` Eli Zaretskii @ 2024-05-21 23:27 ` Dmitry Gutov 2024-05-22 6:23 ` Yuan Fu 2024-05-22 12:17 ` Eli Zaretskii 0 siblings, 2 replies; 16+ messages in thread From: Dmitry Gutov @ 2024-05-21 23:27 UTC (permalink / raw) To: Eli Zaretskii, Ergus; +Cc: casouri, 71070 [-- Attachment #1: Type: text/plain, Size: 748 bytes --] Hi Eli, On 20/05/2024 14:11, Eli Zaretskii wrote: >> Every editor-ide has its own approach for this. But emacs has it own >> flavor and the ts-* intention was to keep it as close as possible to the >> status-quo; that's why I am reporting it here. >> >> There are many details missing in the c/c++-ts-mode compared to >> c-mode... but I understand that some of them are WIP while others are >> just too complex to port. > I understand all that, but still: can you (or someone else) answer my > question about the accepted practices of IDEs in this matter: do they > highlight the namespace identifiers differently than other > identifiers, or do they use the same highlighting? Does the attached screenshot answer the question? It's from VS Code. [-- Attachment #2: Screenshot from 2024-05-22 02-24-26.png --] [-- Type: image/png, Size: 47027 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-21 23:27 ` Dmitry Gutov @ 2024-05-22 6:23 ` Yuan Fu 2024-05-22 12:17 ` Eli Zaretskii 1 sibling, 0 replies; 16+ messages in thread From: Yuan Fu @ 2024-05-22 6:23 UTC (permalink / raw) To: Dmitry Gutov; +Cc: Eli Zaretskii, Ergus, 71070 > On May 21, 2024, at 4:27 PM, Dmitry Gutov <dmitry@gutov.dev> wrote: > > Hi Eli, > > On 20/05/2024 14:11, Eli Zaretskii wrote: >>> Every editor-ide has its own approach for this. But emacs has it own >>> flavor and the ts-* intention was to keep it as close as possible to the >>> status-quo; that's why I am reporting it here. >>> >>> There are many details missing in the c/c++-ts-mode compared to >>> c-mode... but I understand that some of them are WIP while others are >>> just too complex to port. >> I understand all that, but still: can you (or someone else) answer my >> question about the accepted practices of IDEs in this matter: do they >> highlight the namespace identifiers differently than other >> identifiers, or do they use the same highlighting? > > Does the attached screenshot answer the question? It's from VS Code.<Screenshot from 2024-05-22 02-24-26.png> I went ahead and made c++-ts-mode fontify namespaces in constant face. But feel free to revert or change my commit. (It’d be better if someone can add a new builtin face for namespace and make it inherit from constant face, like what we did for property face, etc.) Yuan ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-21 23:27 ` Dmitry Gutov 2024-05-22 6:23 ` Yuan Fu @ 2024-05-22 12:17 ` Eli Zaretskii 2024-05-22 13:33 ` Dmitry Gutov 1 sibling, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-05-22 12:17 UTC (permalink / raw) To: Dmitry Gutov; +Cc: spacibba, casouri, 71070 > Date: Wed, 22 May 2024 02:27:08 +0300 > Cc: casouri@gmail.com, 71070@debbugs.gnu.org > From: Dmitry Gutov <dmitry@gutov.dev> > > > I understand all that, but still: can you (or someone else) answer my > > question about the accepted practices of IDEs in this matter: do they > > highlight the namespace identifiers differently than other > > identifiers, or do they use the same highlighting? > > Does the attached screenshot answer the question? It's from VS Code. Thanks. Not sure I get it completely. It seems like namespace names are fontified like class names? They are not fontified like constants. ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-22 12:17 ` Eli Zaretskii @ 2024-05-22 13:33 ` Dmitry Gutov 2024-06-06 5:28 ` Yuan Fu 0 siblings, 1 reply; 16+ messages in thread From: Dmitry Gutov @ 2024-05-22 13:33 UTC (permalink / raw) To: Eli Zaretskii; +Cc: spacibba, casouri, 71070 On 22/05/2024 15:17, Eli Zaretskii wrote: >> Date: Wed, 22 May 2024 02:27:08 +0300 >> Cc:casouri@gmail.com,71070@debbugs.gnu.org >> From: Dmitry Gutov<dmitry@gutov.dev> >> >>> I understand all that, but still: can you (or someone else) answer my >>> question about the accepted practices of IDEs in this matter: do they >>> highlight the namespace identifiers differently than other >>> identifiers, or do they use the same highlighting? >> Does the attached screenshot answer the question? It's from VS Code. > Thanks. Not sure I get it completely. It seems like namespace names > are fontified like class names? They are not fontified like > constants. Seems like it (although some themes might use some additional colors to differentiate between these two, the default theme does not). Perhaps it is done so that the expression foo::class_name reads naturally (in one color). ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-05-22 13:33 ` Dmitry Gutov @ 2024-06-06 5:28 ` Yuan Fu 2024-06-06 20:16 ` Dmitry Gutov 0 siblings, 1 reply; 16+ messages in thread From: Yuan Fu @ 2024-06-06 5:28 UTC (permalink / raw) To: Dmitry Gutov; +Cc: Eli Zaretskii, Ergus, 71070 [-- Attachment #1: Type: text/plain, Size: 1172 bytes --] > On May 22, 2024, at 6:33 AM, Dmitry Gutov <dmitry@gutov.dev> wrote: > > On 22/05/2024 15:17, Eli Zaretskii wrote: >>> Date: Wed, 22 May 2024 02:27:08 +0300 >>> Cc:casouri@gmail.com,71070@debbugs.gnu.org >>> From: Dmitry Gutov<dmitry@gutov.dev> >>> >>>> I understand all that, but still: can you (or someone else) answer my >>>> question about the accepted practices of IDEs in this matter: do they >>>> highlight the namespace identifiers differently than other >>>> identifiers, or do they use the same highlighting? >>> Does the attached screenshot answer the question? It's from VS Code. >> Thanks. Not sure I get it completely. It seems like namespace names >> are fontified like class names? They are not fontified like >> constants. > > Seems like it (although some themes might use some additional colors to differentiate between these two, the default theme does not). > > Perhaps it is done so that the expression foo::class_name reads naturally (in one color). Am I missing something? I got the exact opposite conclusion from the screenshot: it seems the effect is that namespaces are colored differently from class names: [-- Attachment #2: Screenshot 2024-06-05 at 10.27.31 PM.png --] [-- Type: image/png, Size: 21703 bytes --] [-- Attachment #3: Type: text/plain, Size: 6 bytes --] Yuan ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-06-06 5:28 ` Yuan Fu @ 2024-06-06 20:16 ` Dmitry Gutov 2024-06-15 8:34 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Dmitry Gutov @ 2024-06-06 20:16 UTC (permalink / raw) To: Yuan Fu; +Cc: Eli Zaretskii, Ergus, 71070 On 06/06/2024 08:28, Yuan Fu wrote: >> Seems like it (although some themes might use some additional colors to differentiate between these two, the default theme does not). >> >> Perhaps it is done so that the expression foo::class_name reads naturally (in one color). > Am I missing something? I got the exact opposite conclusion from the screenshot: it seems the effect is that namespaces are colored differently from class names: The class names I meant are A and B on my screenshot. Maybe tree-sitter doesn't see them as class names specifically, just non-primitive identifiers in type position. ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-06-06 20:16 ` Dmitry Gutov @ 2024-06-15 8:34 ` Eli Zaretskii 2024-06-19 6:27 ` Yuan Fu 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-06-15 8:34 UTC (permalink / raw) To: casouri, Dmitry Gutov; +Cc: spacibba, 71070 Ping! Can we please make some progress here? > Date: Thu, 6 Jun 2024 23:16:18 +0300 > Cc: Eli Zaretskii <eliz@gnu.org>, Ergus <spacibba@aol.com>, > 71070@debbugs.gnu.org > From: Dmitry Gutov <dmitry@gutov.dev> > > On 06/06/2024 08:28, Yuan Fu wrote: > >> Seems like it (although some themes might use some additional colors to differentiate between these two, the default theme does not). > >> > >> Perhaps it is done so that the expression foo::class_name reads naturally (in one color). > > Am I missing something? I got the exact opposite conclusion from the screenshot: it seems the effect is that namespaces are colored differently from class names: > > The class names I meant are A and B on my screenshot. > > Maybe tree-sitter doesn't see them as class names specifically, just > non-primitive identifiers in type position. > ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-06-15 8:34 ` Eli Zaretskii @ 2024-06-19 6:27 ` Yuan Fu 2024-06-19 11:52 ` Eli Zaretskii 0 siblings, 1 reply; 16+ messages in thread From: Yuan Fu @ 2024-06-19 6:27 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Dmitry Gutov, Ergus, 71070 > On Jun 15, 2024, at 1:34 AM, Eli Zaretskii <eliz@gnu.org> wrote: > > Ping! Can we please make some progress here? As for the original reported bug, I’ve fixed that (now c++-ts-mode fontifies namespaces in constant face). Perhaps namespaces could be fontified in type face instead. I don’t have any opinion on that. My take is that we could add a namespace/module face and make it inherit from either type or constant. Yuan ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-06-19 6:27 ` Yuan Fu @ 2024-06-19 11:52 ` Eli Zaretskii 2024-06-21 1:53 ` Yuan Fu 0 siblings, 1 reply; 16+ messages in thread From: Eli Zaretskii @ 2024-06-19 11:52 UTC (permalink / raw) To: Yuan Fu; +Cc: dmitry, spacibba, 71070 > From: Yuan Fu <casouri@gmail.com> > Date: Tue, 18 Jun 2024 23:27:47 -0700 > Cc: Dmitry Gutov <dmitry@gutov.dev>, > Ergus <spacibba@aol.com>, > 71070@debbugs.gnu.org > > > > > On Jun 15, 2024, at 1:34 AM, Eli Zaretskii <eliz@gnu.org> wrote: > > > > Ping! Can we please make some progress here? > > As for the original reported bug, I’ve fixed that (now c++-ts-mode fontifies namespaces in constant face). Perhaps namespaces could be fontified in type face instead. I don’t have any opinion on that. My take is that we could add a namespace/module face and make it inherit from either type or constant. So you are basically saying that this bug should be closed, and if there are more requests, they should open a new bug report? ^ permalink raw reply [flat|nested] 16+ messages in thread
* bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification. 2024-06-19 11:52 ` Eli Zaretskii @ 2024-06-21 1:53 ` Yuan Fu 0 siblings, 0 replies; 16+ messages in thread From: Yuan Fu @ 2024-06-21 1:53 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Dmitry Gutov, Ergus, 71070-done > On Jun 19, 2024, at 4:52 AM, Eli Zaretskii <eliz@gnu.org> wrote: > >> From: Yuan Fu <casouri@gmail.com> >> Date: Tue, 18 Jun 2024 23:27:47 -0700 >> Cc: Dmitry Gutov <dmitry@gutov.dev>, >> Ergus <spacibba@aol.com>, >> 71070@debbugs.gnu.org >> >> >> >>> On Jun 15, 2024, at 1:34 AM, Eli Zaretskii <eliz@gnu.org> wrote: >>> >>> Ping! Can we please make some progress here? >> >> As for the original reported bug, I’ve fixed that (now c++-ts-mode fontifies namespaces in constant face). Perhaps namespaces could be fontified in type face instead. I don’t have any opinion on that. My take is that we could add a namespace/module face and make it inherit from either type or constant. > > So you are basically saying that this bug should be closed, and if > there are more requests, they should open a new bug report? Yes, this bug is resolved. Closing the report. Yuan ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-06-21 1:53 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <87h6et6550.fsf.ref@aol.com> 2024-05-19 18:14 ` bug#71070: 30.0.50; c++-ts-mode namespace wrong fontification Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-19 18:36 ` Eli Zaretskii 2024-05-19 19:00 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-19 19:13 ` Eli Zaretskii 2024-05-19 21:36 ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-20 11:11 ` Eli Zaretskii 2024-05-21 23:27 ` Dmitry Gutov 2024-05-22 6:23 ` Yuan Fu 2024-05-22 12:17 ` Eli Zaretskii 2024-05-22 13:33 ` Dmitry Gutov 2024-06-06 5:28 ` Yuan Fu 2024-06-06 20:16 ` Dmitry Gutov 2024-06-15 8:34 ` Eli Zaretskii 2024-06-19 6:27 ` Yuan Fu 2024-06-19 11:52 ` Eli Zaretskii 2024-06-21 1:53 ` Yuan Fu
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).