Subject: bug#59498: 29.0.50; c++-ts-mode get wrong-type-argument error when enabled

From: Yuan Fu <[email-masked]>
Date: Sat, 26 Nov 2022 14:11:48 -0800

> On Nov 26, 2022, at 3:18 AM, Eli Zaretskii <[email-masked]> wrote:
> 
>> Cc: Yuan Fu <[email-masked]>, [email-masked],
>> Daniel Martín <[email-masked]>
>> Date: Thu, 24 Nov 2022 14:39:19 +0000
>> From: Randy Taylor <[email-masked]>
>> 
>> diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
>> index fc35d9aedda..48f504214e2 100644
>> --- a/lisp/progmodes/c-ts-mode.el
>> +++ b/lisp/progmodes/c-ts-mode.el
>> @@ -570,6 +570,8 @@ c++-ts-mode
>>   (setq-local comment-start "// ")
>>   (setq-local comment-start-skip "\\(?://+\\|/\\*+\\)\\s *")
>>   (setq-local comment-end "")
>> +  (setq-local treesit-comment-start (rx "/" (or (+ "/") (+ "*"))))
>> +  (setq-local treesit-comment-end (rx (+ (or "*")) "/"))
>> 
>>   (treesit-parser-create 'cpp)
> 
> Thanks, but this doesn't look right to me: why should c++-ts-mode set
> variables for treesit.el?  It is more likely that treesit.el should use the
> buffer-local values of comment-start and comment-end instead, and fall back
> on generic values (if they make sense) only if the local values are not set.
> 
> Yuan, WDYT?

I added treesit-comment-start/end to help indenting comments. So this is the correct way to use them. The following comment explains why I created new variables:

;; `comment-start' and `comment-end' assume there is only one type of
;; comment, and that the comment spans only one line.  So they are not
;; sufficient for our purpose.

Yuan