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

From: Stefan Monnier <[email-masked]>
Date: Wed, 26 Jun 2024 16:25:08 -0400

>>> I need to test if a parenthesis in LaTeX (latex-mode) starts
>>> a balanced expression.
>> You mentioned `forward-sexp` which should do the trick, so what made you
>> try `sexp-at-point`?
> Because `forward-sexp` does not return nil if the parenthesis does not start
> a balanced expression.

There is no function that does just what you want; you need to make them
do what you want.  E.g.

    (save-excursion
      (condition-case nil
          (progn (forward-sexp 1) t)
        (scan-error nil)))

Note that "test if a parenthesis in LaTeX (latex-mode) starts a balanced
expression" is a kind of weird request, because it will only return nil
if there's a missing close-paren but not if there are too many
close-parens, i.e. it only detects one half of the imbalances.

        Stefan