bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#71777: 29.4; sexp-at-point in latex-mode when sexp contains ";"
Date: Wed, 26 Jun 2024 17:04:46 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> The `forward-sexp` function does not necessarily give an error if the
> parenthesis does not start a balanced expression. E.g.
>
> $( x + y ]$

Yup.  Most of the functions that are meant to be used to parse code
while it's being edited don't check validity.  Basically they try to
find "what is the meaning of this text" rather than "does this text have
meaning".  That's on purpose, because it makes them more usable even
when the text is not 100% valid.

`read` (which parses an ELisp s-exp and is used in `sexp-at-point` to
try and turn the string "( x + y ]" (found by `forward-sexp) into a Lisp
value) is one of the rare exceptions because that one is not meant to
parse text as you type it but rather to parse text in order to process
it (typically, to execute it).

But it obeys the ELisp syntax rather than the LaTeX syntax.

> here "(" does not start a balanced expression but `forward-sexp` does not
> return an error.

I don't think there's code in Emacs which does what you want, so if you
really need to check proper pairing you're going to have to write the code.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]