Subject: Re: bug#59497: 29.0.50; Wrong type argument: number-or-marker-p, nil when enabling Tree Sitter in empty buffer

From: Daniel Martín <[email-masked]>
Date: Wed, 23 Nov 2022 01:51:52 +0100

Daniel Martín via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> Steps to reproduce:
>
> emacs -Q
> C-x b foo RET
> M-x python-ts-mode RET
>
> Wrong type argument: number-or-marker-p is thrown.
>
> The bug seems to be in treesit-ready-p, specifically at:
>
> (> (position-bytes (1- (point-max))) treesit-max-buffer-size)
>
> This check fails if the buffer is empty.

I think the correct check should be:

(> (1- (position-bytes (point-max))) treesit-max-buffer-size)