tecosaur / LaTeX-auto-activating-snippets

Mirror of https://git.tecosaur.net/tec/LaTeX-auto-activating-snippets
GNU General Public License v3.0
102 stars 24 forks source link

Ensure entire expression is within math before expansion #16

Closed mohkale closed 3 years ago

mohkale commented 3 years ago

I've run into this strange issue where if I write a formula in org with laas-mode enabled, and then end a sentance after the math fragment the snippet is still activated.

For example in an org-mode before enter: hello \( some-math \).. The entire latex math fragment is wrapped in resulting in \\dot{( nm = -3 \)}.

ymarco commented 3 years ago

Can reproduce. laas-mathp is misbehaving and returning t when the cursor is right after ).

@tecosaur what do you think? Does auctex's texmathp work in org mode? It seems to behave correctly is this situation.

ymarco commented 3 years ago

Workaround for ". ":

(aas-set-snippets 'laas-mode ". " nil)

You won't be able to use the \dot snippets, but at least you could end sentences.

ymarco commented 3 years ago

Waiting for @tecosaur (or anyone else who's experianced with org-mode math)

tecosaur commented 3 years ago

So the way that Org element works is that each "element" may extend a whitespace char beyond whe we'd consider them ending. E.g.

Hello *there* you.
      ^------^

So we'd probably want to tweak lass-org-mathp to see if we're at the end of the element, and if so assume that we're actually just past it.

luavreis commented 3 years ago

Can reproduce. laas-mathp is misbehaving and returning t when the cursor is right after ). @tecosaur what do you think? Does auctex's texmathp work in org mode? It seems to behave correctly is this situation.

In my own config I use texmathp with my org-mode snippets and it has been working very well. You don't need to load all of auctex since it is defined in a separate file.

ymarco commented 3 years ago

Yeah. I think the switch from texmathp to laas-mathp occured because texmathp misbehaved in org-mode $$, but nowadays the consensus is to only use () so we can bring it back.

lizhuohua commented 3 years ago

Hello, I think we can use org-inside-LaTeX-fragment-p which is defined in org-mode.