Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.82k stars 195 forks source link

Problem with insertion of double-quotes defined as trigger in smartparens-latex #772

Open TobiasZawada opened 7 years ago

TobiasZawada commented 7 years ago

Expected behavior

If I press " in the middle between Testing and quotes of the following LaTeX text

\documentclass{article}
\usepackage[ngerman]{babel}
\begin{document}
Testing  quotes
\end{document}

I expect to get

\documentclass{article}
\usepackage[ngerman]{babel}
\begin{document}
Testing ``'' quotes
\end{document}

with point placed between ` and '.

Actual behavior

I get the following strange auto-insertion:

\documentclass{article}
\usepackage[ngerman]{babel}
\begin{document}
Testing'' ` quotes
\end{document}

Steps to reproduce the problem

Run (require 'smartparens-latex) open the above text file, activate smartparens-mode and type " in the middle between Testing and quotes.

Environment & version information

nidrissi commented 6 years ago

Perhaps related: in the following document

\documentclass{article}
\begin{document}
Insert quotes here:
$f' = 0$
\end{document}

typing " before the math formula inserts opening quotes at the point (which is okay) but also "closes" the pair by inserting an apostrophe ' right after the one already in the file, which is not okay.

Fuco1 commented 6 years ago

@nidrissi Not sure if related but this bug is hilarious either way :D I think it would be better if you started a new issue, thanks!

The issue from OP actually seems to be already fixed on master, at least I can't reproduce it with the given setup.

@TobiasZawada could you please verify that this is fixed?

ofenerci commented 5 years ago

I am getting the same problem.

Janfel commented 4 years ago

I had the same problem, but after some experimenting, I managed to fix it. Note that this only applies to german quotes, not to french ones. It seems this issue is caused by Smartparens and AUCTeX disagreeing over the type of quotes to be inserted. I configured AUCTeX to automatically expand " into the correct opening quote, which, in turn, triggers Smartparens to insert the correct closing quote. Now everything seems to work as expected.

I first registered german quote syntax as a new pair. Note the lack of a :trigger. (I'm not entirely sure what the function of the post-handler does, so I left it in)

(sp-with-modes '(tex-mode
                   plain-tex-mode
                   latex-mode
                   LaTeX-mode)
    (sp-local-pair "\"`" "\"'"
                   :unless '(sp-latex-point-after-backslash sp-in-math-p)
                   :post-handlers '(sp-latex-skip-double-quote)))

Then I configured AUCTeX to automatically insert the german opening quote, when " is pressed. The corresponding entry in my custom-set-variables looks like this:

'(TeX-quote-language-alist (quote (("ngerman" "\"`" "\"'" nil))))