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

`:wrap` does not respect `:when`-condition #1131

Open Perangelot opened 2 years ago

Perangelot commented 2 years ago

Expected behavior

After defining two sp-pairs with the same :wrap and trigger but different parens-pairs and disjunct :when condititions, the :wrap keybinding inserts that pair whose :when condition returns t.

Actual behavior

The :wrap keybinding always inserts that parens-pair which was defined last.

Steps to reproduce the problem

To your config, add

    (sp-pair        "\\textit\{" "\}"
                    :when '(sp-in-string-p)
                    :trigger "ital "
                    :wrap "C-S-k")

    (sp-pair        "\\mathit\{" "\}"
                    :when '(sp-in-math-p)
                    :trigger "ital "
                    :wrap "C-S-k")
  1. Open an org-file.
  2. Select some text wrapped in dollars signs and press C-S-k.
  3. Select some plain text and press C-S-k.
  4. Observe that in both cases, the pair "\mathit{" "}" is inserted.

This problem is OS- and version-indepdendent.