smartparens
smartparens copied to clipboard
:wrap does not respect :when and :unless keywords
Expected behavior
A region is wrapped in a pair using the keybindings specified in the definition iff all functions in :when keyword return non-nil, or if all functions in :unless keyword return nil.
Actual behavior
The :wrap keyword is ignorant of the :when and :unless keywords.
An example
With the below code, when pressing C-S-k in org-mode and having foo as active region,
-
\mathit{foo}should result ifsp-in-math-preturnsnon-nil. -
/foo/should result ifsp-in-math-preturnsnil.
(with-eval-after-load 'org
(sp-with-modes 'org-mode
(sp-local-pair "\\mathit\{" "\}"
:when '(sp-in-math-p)
:post-handlers '(sp-latex-skip-double-quote)
:wrap "C-S-k")
(sp-local-pair "\/" "\/"
:unless '(sp-in-math-p)
:post-handlers '(sp-latex-skip-double-quote)
:wrap "C-S-k")))