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.81k stars 193 forks source link

Question: How do I enter curly quotes with smartparens? #854

Open debajit opened 6 years ago

debajit commented 6 years ago

I would like to use “curly quotes” and have smartparens auto close them.

What is the best way to do this?

(I tried adding a new sp-pair in my init.el, but that does not appear to help:

(use-package smartparens
  :ensure t
  :diminish smartparens-mode
  :config
  (require 'smartparens-config)
  (sp-pair "“" "”")
  (smartparens-global-mode 1))
debajit commented 6 years ago

I can use electric-quote-mode to get around this somewhat, which allows me to type in `` which gets transformed into the opening curly quote, but when I close it with two apostrophes, then smartparens comes in and enters an extra quote, which I need to delete.

Fuco1 commented 6 years ago

Smartparens will pair this only if you insert the curly quote as-is, there is no transformation. You can however add a keyword :trigger "``" this will make the two backticks act as a trigger to insert the pair. However in modes such as latex-mode where two backticks are valid syntax you might run into some trouble. But then you can disable the pair in those specific modes.

There's some documentation but the use-case you are describing is not in there, I will add it for the future: http://smartparens.readthedocs.io/en/latest/pair-management.html#pair-management

Fuco1 commented 6 years ago

Please do not close this issue until I update the docs :)