Subject: Re: bug#68956: M-q → Invalid predicate, see‘treesit-thing-settings’ for valid forms for a predicate: nil

From: Eli Zaretskii <[email-masked]>
Date: Wed, 10 Apr 2024 13:51:33 +0300

> From: Yuan Fu <[email-masked]>
> Date: Tue, 9 Apr 2024 23:03:21 -0700
> Cc: [email-masked]
> 
> [Adding the bug tracker back, forgot to replay-all]

And it might be a good idea to add Dominique as well ;-)

> 
> > On Apr 8, 2024, at 8:42 PM, Yuan Fu <[email-masked]> wrote:
> > 
> > 
> > Eli Zaretskii <[email-masked]> writes:
> > 
> >>> Cc: [email-masked]
> >>> Date: Sat, 10 Feb 2024 10:44:01 +0200
> >>> From: Eli Zaretskii <[email-masked]>
> >>> 
> >>>> From: Dominique Quatravaux <[email-masked]>
> >>>> Date: Tue, 6 Feb 2024 18:32:27 +0100
> >>>> 
> >>>> When invoking `prog-fill-reindent-defun' from inside a bash-ts-mode buffer, an exception (regardless of where
> >>>> point is), an error is raised that reads
> >>>> 
> >>>> Invalid predicate, see ‘treesit-thing-settings’ for valid forms for a predicate: nil
> >>>> 
> >>>> Investigation reveals that `prog-fill-reindent-defun' calls `treesit-node-match-p' with 'text as the second
> >>>> argument, which can only succeed if `(assq 'text (assq 'bash treesit-thing-settings))' is non-nil; whereas the
> >>>> corresponding setting for `treesit-thing-settings' prepared by `bash-ts-mode', doesn't provide a value for 'text
> >>>> (only for 'sentence).
> >>>> 
> >>>> I had success applying the following workaround:
> >>>> 
> >>>> (advice-add 'bash-ts-mode
> >>>>            :after (lambda (&rest ignored)
> >>>>                     (when-let ((bash-things (assq 'bash treesit-thing-settings)))
> >>>>                       (setf (alist-get 'text (cdr bash-things)) '(sentence)))))
> >>>> 
> >>>> Now M-q does the right thing for me everywhere in bash-ts-mode.
> >>> 
> >>> Yuan, any comments or ideas?
> >>> 
> >>> Thanks.
> > 
> > Sorry for the delay. Dominique, what version are you using? I can see
> > that this is fixed on master[1], but not on emacs-29, perhaps due to
> > the size of the change.
> > 
> > [1] b392d05089014ac6d41e35a016d46f496964f879
> > 
> > Yuan
> 
>