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.83k stars 194 forks source link

sp-local-pair can't remove single quote #1043

Open jgarvin opened 4 years ago

jgarvin commented 4 years ago

Expected behavior

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

Should run but doesn't. This does work though:

(sp-pair "'" nil :actions :rem)

Actual behavior

Debugger entered--Lisp error: (wrong-type-argument consp nil)
  sp-local-pair(rust-mode "'" nil :actions :rem)
  (progn (sp-local-pair 'rust-mode "'" nil :actions :rem))
  eval((progn (sp-local-pair 'rust-mode "'" nil :actions :rem)) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

Steps to reproduce the problem

Just paste into *scratch* and eval

Environment & version information

In recent enough smartparens you can call M-x sp-describe-system to generate this report. Please fill manually what we could not detect automatically. Edit the output as you see fit to protect your privacy.


Fuco1 commented 4 years ago

This is a bit of a confusion and stupid API design. You need to do

(sp-local-pair 'rust-mode "'" nil :actions nil)  ;; nil not :rem

:rem removes the entire local definition, but you have no local definition, only the global one which is inherited. To keep the global one working everywhere except in rust mode, you set the actions for the rust mode to nothing thus effectively ignore the pair for inserting/wrapping/navigating etc.