GNU bug report logs - #72388
31.0.50; Use tree-sitter-cuda grammar but with tree-sitter-cpp's font-lock/indentation rules

Previous Next

Package: emacs;

Reported by: Yuan Fu <casouri <at> gmail.com>

Date: Wed, 31 Jul 2024 00:07:01 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Ergus <spacibba <at> aol.com>
Cc: 72388 <at> debbugs.gnu.org
Subject: bug#72388: 31.0.50; Use tree-sitter-cuda grammar but with tree-sitter-cpp's font-lock/indentation rules
Date: Fri, 17 Jan 2025 17:04:23 -0800

> On Jan 16, 2025, at 11:35 AM, Ergus <spacibba <at> aol.com> wrote:
> 
> Hi Yuan:
> 
> It has been a long time since this emails.. But today finally I made my
> serious attempt to make a `cuda-ts-mode`.
> 
> While the treesit-language-remap-alist helped to reuse an important part
> of the code, there were a few issues I needed to manage manually and
> maybe they could be improved somehow:
> 
> 1. The indentation rules still uses the 'cpp prefix, so I had to
> manually tune the code:
> 
> ```
> (defun cuda-ts-mode--simple-indent-rules ()
>  (let ((cpp-rules (c-ts-mode--simple-indent-rules
>    'cpp c-ts-mode-indent-style)))
>    `((cuda . ,(alist-get 'cpp cpp-rules)))))
> 
> 
> (setq-local treesit-simple-indent-rules
> (cuda-ts-mode--simple-indent-rules))
> ```
> 
> In order to manage it properly
> 
> 2. I see that font-lock is working, but the fontlock rules check is
> using the cpp parser.
> 
> That's because the c-ts-mode--font-lock-settings still receives cpp as input.
> I am trying to find a way to get it from c++ and then change the
> :language cpp
> with
> :language cuda
> because if I call
> (c-ts-mode--font-lock-settings 'cuda) I obviously get an error.
> 
> Is there some way to go around these in a cleaner way?

Thanks Ergus, once you map a language to another, it should be transparent, and you shouldn’t need to change cpp to cuda. It’s most likely a bug somewhere. I’ll fix it.

Yuan



This bug report was last modified 135 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.