On Sun, Apr 13 2025, Ihor Radchenko <yanta...@posteo.net> wrote:

> Karthik Chikmagalur <karthikchikmaga...@gmail.com> writes:
>
>> If I delete the last line, so it looks like
>>
>> \begin{align}
>> x = 1
>>
>> And now place the cursor anywhere on the first line (with the \begin...)
>> and call (org-element-context), it parses it as a `latex-fragment'.
>>
>> This make sense too, since any text of the form 
>>
>> \NAME BRACKETS
>>
>> is a `latex-fragment' as per Org syntax.  Is there a way to temporarily
>> suppress this latter behavior while parsing?
>
> No, there is no such way. Because there is nothing to suppress. Org
> parser has no notion of "partial latex fragment" and simply cannot parse
> such constructs.
>
>> ... This is required for
>> handling an edge case with live-updating LaTeX previews where the end
>> delimiter of a latex-environment (\end{foo}) is modified.
>
> Basically, we need a specialized parser that will guess that a given
> paragraph of text is actually an incomplete or broken latex fragment.
> You may try writing one. For example, by additionally checking paragraph
> elements to be latex-like.

Alternatively, why not fix Karthik's stated problem with some analogue
to `org-insert-structure-template'? E.g. `org-insert-latex-environment'.

It would insert a latex environment, after prompting for the name, or
update the environment name if called with a region that started with
\begin{FOO} and ended with \end{FOO}.

FWIW,
Leo

Reply via email to