0

I have not been able to find a solution to this frustrating problem. Here is the situation and my questions are at the end:

Given code that looks similar to this:

$this->hello()->wootFluent()->patterns();

I want to wrap the whole chain in parens, this could be just parens or maybe another function call. So I start with my cursor, |, at the front:

|$this->hello()->wootFluent()->patterns();

I insert-parentheses with M-(

()|$this->hello()->wootFluent()->patterns();

Then I sp-slurp-hybrid-sexp with C-S-right after moving the cursor within the parens:

($this)->hello()->wootFluent()->patterns();

One more time:

($thishello())->->wootFluent()->patterns();

And now my chain is illegal; fubar.

Is there a way to configure smartparens to include the -> in its slurping? Am I using the right smartparens command for slurping? I would like to make successive slurp commands so that I will end up with a structure like this:

($this->hello()->wootFluent()->patterns());
3
  • Welcome! Would encircling the region you want (set-mark-command) and press "(" work for you? Commented Aug 20, 2019 at 11:01
  • There are workarounds but slurping and barfing allow a more interactive way of structuring. For example what if my desired form is otherFunction($this->hello()->wootFluent())->patterns(); Then I can slurp with C-<right> until I'm happy. Commented Aug 21, 2019 at 16:04
  • Hi! Did you try adding a post-handler? Commented Oct 1, 2021 at 14:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.