all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Randy Taylor <dev@rjt.dev>
To: Eason Huang <aqua0210@foxmail.com>
Cc: "Yuan Fu" <casouri@gmail.com>,
	59498@debbugs.gnu.org, "Daniel Martín" <mardani29@yahoo.es>
Subject: bug#59498: 29.0.50; c++-ts-mode get wrong-type-argument error when enabled
Date: Thu, 24 Nov 2022 14:39:19 +0000	[thread overview]
Message-ID: <6_5zC6qq_eQV2whwZ7epZMUlEN-yk5iOlJBLuVnNDLzl4RUGCPFnbIN12pG-DyNvCAYlRJTTopEe_RxX2_B7nSJQyBCJrzo915uBA51qW8A=@rjt.dev> (raw)
In-Reply-To: <tencent_5B8F5CDFCB4A491D92D8861678E1DADCE606@qq.com>

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

On Wednesday, November 23rd, 2022 at 05:53, Eason Huang <aqua0210@foxmail.com> wrote:

> 
> 
> But when I try to indent code,
> it will raise the error (Wrong type argument: stringp, nil) again.
> It should be a different bug.
> 
> Steps to reproduce:
> 
> After the step 4, try to type the code as below:
> 
> int main(){
> <-- put you cursor at the first colum 1, and then hit TAB(indent-for-tab-command)
> 
> }
> 
> after you hit TAB at the above code, you will get the backtrace error as
> below:
> 
> Debugger entered--Lisp error: (wrong-type-argument stringp nil)
> looking-at(nil t)
> #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)(nil #<treesit-node (compound_statement) in 11-15> 13)
> 
> #f(compiled-function (fn) #<bytecode 0x188c898311f019af>)(#f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>))
> 
> mapcar(#f(compiled-function (fn) #<bytecode 0x188c898311f019af>) (#f(compiled-function (n parent &rest _) #<bytecode 0x149caa867664fee9>) #f(compiled-function (&rest _) #<bytecode 0x18b0dfc57c56ebd8>)))
> 
> #f(compiled-function (node parent bol &rest _) #<bytecode -0xb869f433d8fc770>)(nil #<treesit-node (compound_statement) in 11-15> 13)
> 
> treesit--simple-indent-eval(((and (parent-is "comment") comment-end) nil #<treesit-node (compound_statement) in 11-15> 13))
> 
> treesit-simple-indent(nil #<treesit-node (compound_statement) in 11-15> 13)
> 
> treesit--indent-1()
> treesit-indent()
> indent-according-to-mode()
> electric-indent-post-self-insert-function()
> newline(nil 1)
> funcall-interactively(newline nil 1)
> command-execute(newline)
> 
> 
> --
> Eason Huang
> 

The attached patch fixes it for me.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-c-ts-mode-indentation-Bug-59498.patch --]
[-- Type: text/x-patch; name=0001-Fix-c-ts-mode-indentation-Bug-59498.patch, Size: 882 bytes --]

From 94d7bd76b8ec48378b044ff691fb5ef2f9698c08 Mon Sep 17 00:00:00 2001
From: Randy Taylor <dev@rjt.dev>
Date: Thu, 24 Nov 2022 09:31:53 -0500
Subject: [PATCH] Fix c++-ts-mode indentation (Bug#59498)

* lisp/progmodes/c-ts-mode.el (c++-ts-mode): Set treesit-comment-start
and treesit-comment-end.
---
 lisp/progmodes/c-ts-mode.el | 2 ++
 1 file changed, 2 insertions(+)

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)
 
-- 
2.38.1


  reply	other threads:[~2022-11-24 14:39 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  2:24 bug#59498: 29.0.50; c++-ts-mode get wrong-type-argument error when enabled Eason Huang
2022-11-23  8:44 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 10:53   ` Eason Huang
2022-11-24 14:39     ` Randy Taylor [this message]
2022-11-25 12:56       ` Eason Huang
2022-11-26 11:18       ` Eli Zaretskii
2022-11-26 22:11         ` Yuan Fu
2022-11-27  6:24           ` Eli Zaretskii
2022-11-27  7:18             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-27  7:24               ` Eli Zaretskii
2022-11-27 22:21                 ` Yuan Fu
2022-11-28  0:24                   ` Stefan Kangas
2022-12-18  9:57                     ` Eli Zaretskii
2022-12-18 22:49                       ` Yuan Fu
2022-12-19 13:51                         ` Eli Zaretskii
2022-12-20  1:56                           ` Yuan Fu
2022-12-20 15:18                             ` Eli Zaretskii
2022-12-21  0:37                               ` Yuan Fu
2022-11-28 13:59                   ` Eason Huang
2022-11-27 22:00               ` Yuan Fu
     [not found] <m24juq9zn6.fsf@foxmail.com>
2022-11-30 21:33 ` Yuan Fu

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='6_5zC6qq_eQV2whwZ7epZMUlEN-yk5iOlJBLuVnNDLzl4RUGCPFnbIN12pG-DyNvCAYlRJTTopEe_RxX2_B7nSJQyBCJrzo915uBA51qW8A=@rjt.dev' \
    --to=dev@rjt.dev \
    --cc=59498@debbugs.gnu.org \
    --cc=aqua0210@foxmail.com \
    --cc=casouri@gmail.com \
    --cc=mardani29@yahoo.es \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.