smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

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

Open TobiasZawada opened this issue 8 years ago • 4 comments

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

  • smartparens version: melpa, 20170708.1326
  • Active major-mode: latex-mode from AucTeX
  • Emacs version (M-x emacs-version): 25.1 on linux and GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10) of 2017-04-21
  • OS: independent (tested on Linux and cygwin)

TobiasZawada avatar Jul 10 '17 10:07 TobiasZawada

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.

nidrissi avatar Nov 22 '17 13:11 nidrissi

@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?

Fuco1 avatar Nov 22 '17 14:11 Fuco1

I am getting the same problem.

ofenerci avatar Jul 02 '19 15:07 ofenerci

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))))

Janfel avatar Oct 21 '19 20:10 Janfel