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

Using sp-splice-sexp on ruby parentheses should replace parens with spaces #263

Open dgtized opened 10 years ago

dgtized commented 10 years ago

Currently if you hit M-s in the middle of the code below it transforms from

test(foo,bar) => testfoo,bar

Given that parentheses are optional in ruby I would expect the default transformation to leave a space where at least the beginning parentheses is to avoid joining words together. I would expect the behavior to be

test(foo,bar) => test foo,bar

I don't know if this should also apply to single quotes or strings or other braces.

Jell commented 10 years ago

Right, better handling of parenthesis is on my todo list. Right now it's still relying on smartparens default behaviour for them, which is not correct (slurping and barfing only work in trivial cases).

This might take a while before I look into it though, with the holiday season and so on...

Fuco1 commented 10 years ago

Should be simple enough to repurpose sp--unwrap-sexp to take optional opening/closing replacement---right now it only deletes the regions occupied by the delimiters.

I'm thinking what would be a good way to specify the replacements though. I suppose it'll need a customize variable. Or maybe a pair property if the replacement with spaces isn't always correct.

So that's the question on you: is it always valid to replace the parens with spaces? Can't there be a construct where it would not make sense in ruby?

Though I think that having it as pair property would be more flexible for the future anyway.

Jell commented 10 years ago

I'd say that would be a very useful feature that would simplify the rest of the ruby config (which is already way too much complex :p)

If you can make it so that the parenthesis is replaced by "just one space", that would be super perfect and work everywhere. Bonus if it can be smart about end of line (i.e. no extra space at the end of the line).

Fuco1 commented 10 years ago

What about other types of parens as @dgtized mentioned? I think I'll make it a pair property where you can specify a cons of beg/end replacements... with some special form with tests if the replacement should occur or not.