From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: luangruo@yahoo.com, 63323@debbugs.gnu.org
Subject: bug#63323: c-ts-mode does not know about `restrict'
Date: Sat, 6 May 2023 15:54:32 -0700 [thread overview]
Message-ID: <61B53D25-0E51-4B4C-9890-10E9B97E1840@gmail.com> (raw)
In-Reply-To: <83v8h5fya0.fsf@gnu.org>
> On May 6, 2023, at 5:19 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> Cc: 63323@debbugs.gnu.org
>> Date: Sat, 06 May 2023 13:31:03 +0300
>> From: Eli Zaretskii <eliz@gnu.org>
>>
>> It looks like c-ts-mode thinks type qualifiers are possible only in
>> C++?
>>
>> :feature 'type
>> `((primitive_type) @font-lock-type-face
>> (type_identifier) @font-lock-type-face
>> (sized_type_specifier) @font-lock-type-face
>> ,@(when (eq mode 'cpp) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> '((type_qualifier) @font-lock-type-face
>>
>> (qualified_identifier
>> scope: (namespace_identifier) @font-lock-type-face)
>>
>> (operator_cast) type: (type_identifier) @font-lock-type-face))
>> [,@c-ts-mode--type-keywords] @font-lock-type-face)
>>
>> The tree-sitter library returns a type_qualifier node for 'restrict':
>>
>> (parameter_declaration type: (type_identifier)
>> declarator:
>> (pointer_declarator *
>> (type_qualifier restrict)
>> declarator: (identifier)))
>>
>> Yuan, can you look into fixing this, please?
>
> Actually, it looks like we recognize the type qualifiers in C as
> keywords, via a separate list. So I've just added to that list the
> two missing qualifiers: 'restrict' and '_Atomic', and that fixes this
> bug for me.
>
> Yuan, is that the right fix? I've installed it on the emacs-29
> branch.
I check tree-sitter-c’s grammar and it defines type_qualifier [1], so if you move (type_qualifier) @font-lock-type-face out of the check for cpp, if would work. Recognizing them as keywords also works. So both are technically correct. C-mode uses keyword face, so I think your fix is a-ok.
[1] you probably know this, but for completeness:
type_qualifier: $ => choice(
'const',
'volatile',
'restrict',
'_Atomic'
),
Yuan
next prev parent reply other threads:[~2023-05-06 22:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87r0rtkh2j.fsf.ref@yahoo.com>
2023-05-06 8:19 ` bug#63323: c-ts-mode does not know about `restrict' Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-06 10:31 ` Eli Zaretskii
2023-05-06 12:19 ` Eli Zaretskii
2023-05-06 22:54 ` Yuan Fu [this message]
2023-05-07 5:14 ` Eli Zaretskii
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=61B53D25-0E51-4B4C-9890-10E9B97E1840@gmail.com \
--to=casouri@gmail.com \
--cc=63323@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.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).