smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Cannot insert quotes when sp-escape-quotes-after-insert is nil

Open amosbird opened this issue 8 years ago • 10 comments

I just disabled sp-escape-quotes-after-insert, and now I cannot insert " inside a " " region anymore.

amosbird avatar Feb 07 '17 08:02 amosbird

Can you give some more information: what mode, what sp version, what emacs version.

Fuco1 avatar Feb 07 '17 10:02 Fuco1

scratch mode, smartparens 20170129.956 , emacs 26.0.50.1 .

I just tried Fish mode with string " safasdf(cursor point)asdf " . It still inputs escaped quote.

amosbird avatar Feb 07 '17 10:02 amosbird

I have the same problem, smartparens 20170209, emacs 26.0.50.2. sp-escape-quotes-after-insert and sp-escape-wrapped-region are both set to nil.

rsbowman avatar Feb 13 '17 19:02 rsbowman

This seems to be an emacs 26 issue. I guess they changed the syntax tables once again :/

I'll try to get some tests running on that and see what's going on. Personally, I still use 24.5 :/ (I have zero time to update my config, sigh)

Fuco1 avatar Feb 13 '17 22:02 Fuco1

Confirmed to be a problem on 25.1

Fuco1 avatar Jul 13 '17 18:07 Fuco1

Could it be a bug in sp-escape-open-delimiter? This function doesn't seem to check the values of sp-escape-quotes-after-insert and sp-escape-wrapped-region, and disabling it completely (with advice-add) fixes the problem for me.

sergei-grechanik avatar Jul 20 '17 09:07 sergei-grechanik

This is really stupid on my part. There are two escaping features both of which kind of do the same but not. It is really confusing.

The option you refer to enables or disables escaping of pairs inserted when autopair is enabled. So if we have a buffer " foo | bar" and you press " it inserts " foo \"|\" bar".

If we have autopair disabled inside strings we still want to escape quotes so that it doesn't break the string structure when we insert a single quote. This is however controlled by the escape action attribute on the pair itself (and this is handled by the function you've mentioned). So to disable that behaviour you would need to remove the escape action from the quote.

It seems that the issue here is misconfiguration. Admittedly it is really badly designed. Maybe the option could be renamed to better indicate that it only relates to inserted pairs and not any inserted quotes.

The relevant documentation is here http://smartparens.readthedocs.io/en/latest/automatic-escaping.html

Fuco1 avatar Jul 20 '17 09:07 Fuco1

Have tried everything, even (sp-local-pair "\"" nil :actions nil) and stills does that annoying thing 😩 , I just want to go from this: "something|" to this "something"| instead of "something\"|\"" on elisp, mabe it's indeed a bug as in #961.

zzantares avatar Jun 20 '19 03:06 zzantares

@ZzAntares that seems like a different issue because for me it does what you describe.

Try setting (setq sp-autoskip-closing-pair (quote always))

Fuco1 avatar Jun 21 '19 10:06 Fuco1

Thanks for the help, but sadly it still doesn't work, should I file an issue? This is what I'm using:

(use-package smartparens
  :defer 3
  :diminish smartparens-mode
  :commands smartparens-mode
  :hook (prog-mode . smartparens-mode)
  :config
  (setq sp-autoskip-closing-pair (quote always))
  (require 'smartparens-config)
  (sp-with-modes 'emacs-lisp-mode
    (sp-local-pair "'" nil :actions nil)
    (sp-local-pair "`" "'" :when '(sp-in-string-p sp-in-comment-p)))
  (sp-with-modes 'markdown-mode
    (sp-local-pair "_" "_")
    (sp-local-pair "**" "**")
    (sp-local-pair "~~" "~~"))
  ;; Indent a new line when pressing RET after pair insertion
  (sp-pair "{" nil :post-handlers '((zz-newline-and-enter-sexp "RET")))
  (sp-pair "(" nil :post-handlers '((zz-newline-and-enter-sexp "RET")))
  (sp-pair "[" nil :post-handlers '((zz-newline-and-enter-sexp "RET"))))

zzantares avatar Jun 23 '19 05:06 zzantares