I've been trying to get smartparens to recognize Mathematica's comments, which have delimiters (*
and *)
, while keeping the default behavior for ordinary parens (
and )
. The following configuration isn't working.
(sp-with-modes '(wolfram-mode)
(sp-local-pair "(*" "*)"
:unless '(sp-in-string-p)
:actions '(insert wrap)))
As soon as I type an open paren, smartparens enters a close paren, as it should. I would like to have the active pair turn into Mathematica comments when I type *
, as follows,
(|) -> (* | *)
where |
is point. Unfortunately, I found this in the smartparens wiki,
Pairs have to be prefix-free, that means no opening pair should be a prefix of some other pair. This is reasonable and in fact necessary for correct function. For example, with auto insertion of pair "(" ")" and pair "(/" "/)" (which has as a prefix the one paren version), the program wouldn't know you might want to insert the longer version and simply inserts (|). This can technically be fixed with "look-ahead" and then backward alteration of input text, but it will be confusing and probably not very useful anyway. If such functionality will ever get implemented, it will be disabled by default.
I'd like to have this functionality, as it's the same behavior that the Mathematica parser itself exhibits. Can anyone tell me how to do this?