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

Commands to change pairs #591

Open cute-jumper opened 8 years ago

cute-jumper commented 8 years ago

Do you plan to add commands to change pairs? Evil-surround has a similar change function inherited from surround.vim. Smartparens are good at inserting/manipulating pairs, would it be better if pair changing commands are also supported?

Fuco1 commented 8 years ago

sp-rewrap-sexp :)

Do you plan to add commands to change pairs? Evil-surround has a similar change function inherited from surround.vim. Smartparens are good at inserting/manipulating pairs, would it be better if pair changing commands are also supported?


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/Fuco1/smartparens/issues/591

Best regards, Matúš Goljer

cute-jumper commented 8 years ago

Thanks. I'm not aware of this before. But it is not possible to choose what to be replaced. For example, if the cursor is in the middle of foo, it is impossible to use sp-rewrap-sexp to achieve:

("foo") => ["foo"]

Maybe it be better to have a more general sp-rewrap-sexp?

Fuco1 commented 8 years ago

Could be. How would you imagine it should work? I don't know vim nor surround.

cute-jumper commented 8 years ago

Just prompt the user for two inputs, one for the old surrounding pair, and the other for the new surrounding pair, and then find the nearest old surrounding pair and replace it with the new pair.

M-x our-rewrap-command, then ( and [, we could achieve(| is the cursor location)

(("fo|o" bar) baz) => (["fo|o" bar] baz)

Maybe you can look at evil-surround.

EDIT: Fix missing link.

derikson commented 7 years ago

Perhaps while the prompt is active, the pair being changed could be highlighted, and the keybindings C-f and C-b could move between them.

cute-jumper commented 7 years ago

FWIW, I implemented embrace (and evil-embrace) myself based on expand-region to achieve something similar.