GNU bug report logs - #77870
treesit-language-at-point-default signals error (as of 4c5c20d)

Previous Next

Package: emacs;

Reported by: Ship Mints <shipmints <at> gmail.com>

Date: Thu, 17 Apr 2025 15:53:01 UTC

Severity: normal

Done: Yuan Fu <casouri <at> gmail.com>

To reply to this bug, email your comments to 77870 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#77870; Package emacs. (Thu, 17 Apr 2025 15:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ship Mints <shipmints <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 17 Apr 2025 15:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ship Mints <shipmints <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: treesit-language-at-point-default signals error (as of 4c5c20d)
Date: Thu, 17 Apr 2025 11:51:52 -0400
[Message part 1 (text/plain, inline)]
When there are no parsers present in a buffer, the most recent
treesit-language-at-point-default signals:

Debugger entered--Lisp error: (wrong-type-argument treesit-parser-p nil)
  treesit-parser-language(nil)
  eval((treesit-parser-language (car (treesit-parsers-at (point)))) nil)
  pp-eval-expression((treesit-parser-language (car (treesit-parsers-at
(point)))))
  funcall-interactively(pp-eval-expression (treesit-parser-language (car
(treesit-parsers-at (point)))))

I guess either the below needs to guard nil or treesit-parser-language (in
the C code) needs to accept nil and return nil?

(defun treesit-language-at-point-default (position)
  (treesit-parser-language
   (car (treesit-parsers-at position))))

-Stephane
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77870; Package emacs. (Thu, 17 Apr 2025 17:32:01 GMT) Full text and rfc822 format available.

Message #8 received at 77870 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 77870 <at> debbugs.gnu.org, Yuan Fu <casouri <at> gmail.com>
Subject: Re: bug#77870: treesit-language-at-point-default signals error (as
 of 4c5c20d)
Date: Thu, 17 Apr 2025 20:30:57 +0300
Cc-ing Yuan to help to decide what to do in this case.

> When there are no parsers present in a buffer, the most recent
> treesit-language-at-point-default signals:
>
> Debugger entered--Lisp error: (wrong-type-argument treesit-parser-p nil)
>   treesit-parser-language(nil)
>   eval((treesit-parser-language (car (treesit-parsers-at (point)))) nil)
>   pp-eval-expression((treesit-parser-language (car (treesit-parsers-at
> (point)))))
>   funcall-interactively(pp-eval-expression (treesit-parser-language (car
> (treesit-parsers-at (point)))))
>
> I guess either the below needs to guard nil or treesit-parser-language (in
> the C code) needs to accept nil and return nil?
>
> (defun treesit-language-at-point-default (position)
>   (treesit-parser-language
>    (car (treesit-parsers-at position))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77870; Package emacs. (Thu, 17 Apr 2025 22:32:03 GMT) Full text and rfc822 format available.

Message #11 received at 77870 <at> debbugs.gnu.org (full text, mbox):

From: JD Smith <jdtsmith <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 77870 <at> debbugs.gnu.org, casouri <at> gmail.com, shipmints <at> gmail.com
Subject: Re: bug#77870: treesit-language-at-point-default signals error (as 
 of 4c5c20d)
Date: Thu, 17 Apr 2025 18:30:40 -0400
Just had a user report this same problem via `indent-bars' in `python-ts-mode'[1].  `inferior-python-mode` spawns a temp buffer, and puts it into python-mode, which calls all the mode hooks, including ones which are expecting treesitter to be availabile.  Normally not a problem, but now the new `treesit-language-at-point-default' throws:

  treesit-language-at: Wrong type argument: treesit-parser-p, nil

in such buffers, since it does not check for "no parsers".

[1] https://github.com/jdtsmith/indent-bars/issues/103




Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Thu, 17 Apr 2025 23:59:04 GMT) Full text and rfc822 format available.

Notification sent to Ship Mints <shipmints <at> gmail.com>:
bug acknowledged by developer. (Thu, 17 Apr 2025 23:59:04 GMT) Full text and rfc822 format available.

Message #16 received at 77870-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: JD Smith <jdtsmith <at> gmail.com>
Cc: 77870-done <at> debbugs.gnu.org, shipmints <at> gmail.com,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#77870: treesit-language-at-point-default signals error (as of
 4c5c20d)
Date: Thu, 17 Apr 2025 16:58:04 -0700

> On Apr 17, 2025, at 3:30 PM, JD Smith <jdtsmith <at> gmail.com> wrote:
> 
> Just had a user report this same problem via `indent-bars' in `python-ts-mode'[1].  `inferior-python-mode` spawns a temp buffer, and puts it into python-mode, which calls all the mode hooks, including ones which are expecting treesitter to be availabile.  Normally not a problem, but now the new `treesit-language-at-point-default' throws:
> 
>  treesit-language-at: Wrong type argument: treesit-parser-p, nil
> 
> in such buffers, since it does not check for "no parsers".
> 
> [1] https://github.com/jdtsmith/indent-bars/issues/103

Yep, it should return nil if there’s no parser. I’ve pushed a fix to master. Sorry for the trouble guys.

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77870; Package emacs. (Fri, 18 Apr 2025 00:32:03 GMT) Full text and rfc822 format available.

Message #19 received at 77870-done <at> debbugs.gnu.org (full text, mbox):

From: Ship Mints <shipmints <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 77870-done <at> debbugs.gnu.org, JD Smith <jdtsmith <at> gmail.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#77870: treesit-language-at-point-default signals error (as of
 4c5c20d)
Date: Thu, 17 Apr 2025 20:31:28 -0400
[Message part 1 (text/plain, inline)]
On Thu, Apr 17, 2025 at 19:58 Yuan Fu <casouri <at> gmail.com> wrote:

>
>
> > On Apr 17, 2025, at 3:30 PM, JD Smith <jdtsmith <at> gmail.com> wrote:
> >
> > Just had a user report this same problem via `indent-bars' in
> `python-ts-mode'[1].  `inferior-python-mode` spawns a temp buffer, and puts
> it into python-mode, which calls all the mode hooks, including ones which
> are expecting treesitter to be availabile.  Normally not a problem, but now
> the new `treesit-language-at-point-default' throws:
> >
> >  treesit-language-at: Wrong type argument: treesit-parser-p, nil
> >
> > in such buffers, since it does not check for "no parsers".
> >
> > [1] https://github.com/jdtsmith/indent-bars/issues/103
>
> Yep, it should return nil if there’s no parser. I’ve pushed a fix to
> master. Sorry for the trouble guys.


Thank you. All this great treesitter work is gonna pay off nicely. A few
minor hiccups are nothing.

>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77870; Package emacs. (Fri, 18 Apr 2025 23:45:04 GMT) Full text and rfc822 format available.

Message #22 received at 77870-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Ship Mints <shipmints <at> gmail.com>
Cc: 77870-done <at> debbugs.gnu.org, JD Smith <jdtsmith <at> gmail.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#77870: treesit-language-at-point-default signals error (as of
 4c5c20d)
Date: Fri, 18 Apr 2025 16:44:36 -0700

> On Apr 17, 2025, at 5:31 PM, Ship Mints <shipmints <at> gmail.com> wrote:
> 
> On Thu, Apr 17, 2025 at 19:58 Yuan Fu <casouri <at> gmail.com> wrote:
> 
> 
> > On Apr 17, 2025, at 3:30 PM, JD Smith <jdtsmith <at> gmail.com> wrote:
> > 
> > Just had a user report this same problem via `indent-bars' in `python-ts-mode'[1].  `inferior-python-mode` spawns a temp buffer, and puts it into python-mode, which calls all the mode hooks, including ones which are expecting treesitter to be availabile.  Normally not a problem, but now the new `treesit-language-at-point-default' throws:
> > 
> >  treesit-language-at: Wrong type argument: treesit-parser-p, nil
> > > in such buffers, since it does not check for "no parsers".
> > 
> > [1] https://github.com/jdtsmith/indent-bars/issues/103
> 
> Yep, it should return nil if there’s no parser. I’ve pushed a fix to master. Sorry for the trouble guys.
> 
> Thank you. All this great treesitter work is gonna pay off nicely. A few minor hiccups are nothing. 

Thanks for your encouragement! :-)

Yuan 



This bug report was last modified 5 days ago.

Previous Next


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