3

In latex mode, using \( ... \) is preferred over $ ... $, so in my configuration I have the following

(sp-local-pair modes "$" nil :actions :rem)
(sp-local-pair modes "\\(" "\\)" :trigger "$")

This way, when I try to insert $ the pair \( \) are inserted instead. This works well, however, for some reason if I select some text and press $ the pair \( \) are inserted after the text instead of wrapping the text with them.

If I press \( instead the selected text is wrapped correctly.

Is there a way to fix this so that if I press $ with a selected text, the text is wrapped with \( ... \)?

Tohiko
  • 1,589
  • 1
  • 10
  • 22
  • Does it work if you add `:trigger-wrap "$"` after `:trigger "$"`? – jagrg May 09 '19 at 17:05
  • No, that did not work. – Tohiko May 13 '19 at 08:37
  • I see the issue now with emacs -Q. In addition to adding `:trigger-wrap "$"` I also had to require `smartparens-latex`. If that works for you we'll have to dig there to answer your question. – jagrg May 14 '19 at 14:30

1 Answers1

1

In addition to @jagrg suggestion (to add :trigger-wrap "$") I found everything works as expected if I don't remove the $ pair from my modes

I.e., I had to comment out this line

(sp-local-pair 'latex-mode "$" nil :actions :rem)

This line alone does the trick

(sp-local-pair 'latex-mode "\\(" "\\)" :trigger "$" :trigger-wrap "$")
Tohiko
  • 1,589
  • 1
  • 10
  • 22