Subject: bug#77906: 31.0.50; php-js-mode and js-ts-mode: treesit-show-paren-data--categorize: peculiar error: ("Cannot find the definition of the predicate in `treesit-thing-settings'" list)

From: Juri Linkov <[email-masked]>
Date: Thu, 24 Apr 2025 09:47:08 +0300

>>  @@ -869,7 +869,7 @@ treesit-parsers-at
>>     (let ((res nil))
>>       ;; Refer to (ref:local-parser-overlay) for more explanation of local
>>       ;; parser overlays.
>>  -    (dolist (ov (overlays-at (or pos (point))))
>>  +    (dolist (ov (overlays-at (1- (or pos (point)))))
>>         (when-let* ((parser (overlay-get ov 'treesit-parser))
>>                     (host-parser (or (null with-host)
>>                                      (overlay-get ov 'treesit-host-parser)))
>> 
>> With this patch the following case works correctly in test.heex:
>> 
>>  <%= if true do %>
>>    <p>hello, tree-sitter!</p>
>>  <% end| %>
>> 
>> With point at "|" the command 'backward-sexp' (C-M-b)
>> correctly jumps to the beginning of "if".
>
> Right.  I think it can be done in backward-sexp since there we know
> we’re moving back.  I assume that’s what you mean.

The problem is that the last time when the arg is still -1
is in 'treesit-forward-sexp', and then it calls
'treesit-beginning-of-thing' with '(abs arg)'.

The complete call chain:

- treesit-forward-sexp
- treesit-beginning-of-thing
- treesit-navigate-thing
- treesit-thing-at
- treesit-node-at
- treesit-parsers-at
- overlays-at

So not clear how to propagate the flag for decrementing the offset.
Maybe by let-binding a new dynamically bound variable?