smartparens
smartparens copied to clipboard
[Feature Request] Add sp-swap-left and sp-swap-right functionality
Expected behavior
I want to be able to swap an s-expression with its adjacent neighbors at the whim of a keybinding
; sp-swap-right 1 |2 3 => 1 3 2
1 2| 3 => 1 3 2 (notice sexp closest to point is used)
1| 2 3 => 2 3 1 ; if 2 is given as arg
1 2 3| => 3 1 2 ; if 0 is given as arg
|1 2 3 4 5 => 2 3 4 5 1 ; if C-u (negative) is used as arg
sp-swap-left would be the same as sp-swap-right, except going to the left It is also imperative that there should be variants or that these only work in the same level, similar to sp-forward-parallel-sexp and sp-backward-parallel-sexp Maybe also add variants where arg 0 isn't mandatory and it automatically wrap swaps with the last (swap-left) or first sexp (swap right)
I am aware of sp-transpose-sexp, and I reckon these can be built using transpose and some point modification, however, I quickly realized the code to do such a thing would be too complex, hence why I'm requesting the feature.
I think sp-swap-right
is the same as sp-transpose-sexp
except not moving the point? If so, wrapping with save-excursion
should do the trick.
The examples don't show the point position after the command, so it's a bit difficult to exactly see what is the expected result.