Subject: Re: bug#71777: 29.4; sexp-at-point in latex-mode when sexp contains ";"

From: Gabriele Nicolardi <[email-masked]>
Date: Wed, 26 Jun 2024 17:52:41 +0200

Il 26/06/24 15:46, Stefan Monnier ha scritto:
>>> $K(U_1, V_1, x_1; t_2, x_2)$
>>>
>>> If the pointer is located on the opened "(" and I run "forward-sexp" it
>>> works and the
>>> pointer goes after the closed ")".
>>>
>>> But if, again, the pointer is located on the opened "(" and I evaluate
>>> "(sexp-at-point)" it returns nil.
>>>
>>> If I remove the ";" symbol from the expression it works and returns the
>>> sexp-at-point:
>>>
>>> $K(U_1, V_1, x_1 t_2, x_2)$
>>>
>>> Is it a bug?
>> I don't think it's a bug.  forward-sexp moves across balanced
>> expressions, so it is not specific to Lisp.  By contrast,
>> sexp-at-point is specific to Lisp and Lisp-like syntax, and so it uses
>> the buffer's syntax.  Which is why ';' affects the result.
>>
>> Adding Stefan in case he has comments for this.
> AFAICT, `sexp-at-point` correctly finds the parenthesized thingy, but it
> is asked to return the Lisp object it represents rather than a string,
> so it `read`s, which inevitably obeys the ELisp syntax.
>
> IOW, I suspect you want (thing-at-point 'sexp) rather than
> (sexp-at-point).
>
>
>          Stefan
I need to test if a parenthesis in LaTeX (latex-mode) starts a balanced 
expression.

sexp-at-point: Return the sexp at point, or nil if none is found.

This is not possible with (thing-at-point 'sexp) because it does no return nil in the case, e.g.:

$K(U_1, V_1, x_1 t_2, x_2$

Gabriele