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());
  • Welcome! Would encircling the region you want (set-mark-command) and press "(" work for you? – aadcg Aug 20 '19 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. – charlie mac Aug 21 '19 at 16:04

Your Answer

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

Browse other questions tagged or ask your own question.