1

I'm using smartparens-global-strict-modeand having issues quoting variables. How do I get something like 'varname? My current strategy, which seems ridiculous, is to do:

'|' (sp inserts both pairs)

'varname' (write the varname)

at this point, I do M-x smartparens-strict-mode, which toggles it off, delete the right ', then do M-x smartparens-strict-mode again to turn it back on. But there's got to be a better way, right? Am I missing something simple?

2

What major mode are you using? In emacs-lisp-mode, Smartparens does not automatically close single quotes.

To insert a single character, use C-q, quoted-insert, followed by the character. E.g. C-q ' to insert a single quote.

| improve this answer | |
  • Huh. This happens in all major modes, including emacs-lisp-mode. I guess something else in my init file is causing that, then... The C-q tip works. Thanks for that. – Alex Aug 23 '16 at 1:31
1

Specific answer: The default configuration for smartparens should cover this, but perhaps you aren't loading the default config. Make sure that

(require 'smartparens-config)

is in your .emacs.d instead of just (require 'smartparens).

More generally, to see the delimiters that smartparens is currently tracking, inspect variable sp-pair-list. You can use the functions sp-pair and sp-local-pair to configure it. For example to globally disable autoinsertion of closing single quotes you can write:

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

Or to disable for specific modes:

(sp-local-pair '(emacs-lisp-mode) "'" "'" :actions nil)
| improve this answer | |
0

Eval (sp-pair "'" "'" :actions :rem) to disable any cleverness with the apostrophe. This removes the entry for ' from sp-pairs. You can get the right arguments to pass into sp-pair by evaling (sp-get-pair "'").

| improve this answer | |
New contributor
nivekuil is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Can you elaborate, to explain how that sexp does what you say? That could make your answer more helpful. – Drew Aug 3 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.