-
-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hybrid line/sexp commands such as paredit-kill #95
Comments
As an architectural aside, the way I am doing this is by adding |
In those cases I just put in empty strings. As those are used in some calculations of lengths and such, they just add nothing. You can check the |
Also, could you start an issue for each of Speaking about python, I was toying with an idea of creating some "python -> sexp" conversion system (based on depth most likely) that would enable the SP commands for python. But since I'm not a python programmer myself, I know quite little about the language. |
I can make separate issues if you want, but let me explain what I mean here so the general idea doesn't get spread out over too many tickets. Maybe my explanation can be useful for the documentation. "Hybrid sexp/line" is a term I just invented to refer to the general idea embodied within The definition of a hybrid/sexp line is smallest balanced region containing the line
The importance of having hybrid line commands is that programmers tend to organize things in lines, but operating using rigid line commands often destroys any nested constructs. For example,
which is probably not what you wanted.
Now, you said you weren't clear on sorting and transposing hybrid lines. These aren't in paredit; these features would set smartparens apart from the competition. Given the framework developed above, it's easy to understand them. Consider working with the following Python code:
You say to yourself "oops, let me transpose those statements". Using
yeah, not very useful. Using a hybrid transpose, we identify the hybrid lines:
and swap them:
Now, let's use Clojure as an example to illustrate sorting. To avoid messing with my
You want to order your variables. Mark your variables, M-x
Just terrible. Lets mark the hybrid lines:
and sort them:
still not totally what you want due to whitespace. So let's add a user setting for performing the operation modulo indentation:
Now add a setting to run
It's worth noting that a hypothetical I hope that helps. EDIT: you can find an implementation in #94 |
I know a lot about Python, although I spend my time coding in Clojure these days. Let me know if I can be of help. Recognizing indentation depth + the line before indentation as a sexp would help Python. Recognizing pairs like "def" "end" would help Ruby. Unfortunately, outside Lisp languages, this sorta stuff gets complicated. I'm not sure what the right thing to do is with respect to such languages. |
@Fuco1 Any news on this issue? |
I've exchanged an email with @monsanto, he has it sort of working in his branch and is polishing it out. It will definitely get added, sometime closer to the end of this month. Right now I can't afford spending too much time on anything, and this seems like pretty big change to incorporate properly. |
I think an With slurp: if te|st
end
object.method(bla) do
yadiyada
end
someother.suff(cool)
if te|st
object
end.method(bla) do
yadiyada
end
someother.suff(cool) With slurp-line: if te|st
end
object.method(bla) do
yadiyada
end
someother.suff(cool)
if te|st
object.method(bla) do
yadiyada
end
end
someother.suff(cool) |
Quick update: due to work obligations and a cross-country move I haven't had the time to address this issue. I should have some more free time soon to handle this. Sorry for the wait, everyone! |
This has been implemented in #158. |
Hybrid line/sexp commands are very versatile, if hard to write.
paredit-kill
is probably my favorite feature of paredit, and it has no equivalent in smartparens. (In brief, it kills to the end of the line likekill-line
, except will stop if the enclosing sexp ends, and will kill any hanging sexps at the end of the line. See http://www.emacswiki.org/emacs/PareditCheatsheet)I have a clone
sp-hybrid-kill-line
written, but it needs #94 fixed before I can give you a pull request.It would also be useful to have commands such as
sp-hybrid-sort-lines
,sp-hybrid-transpose-lines
, etc. These are especially important when working in non-sexp-based languages such as Python, or languages like Clojure that don't always group related things in parens. For an example of the latter, it's very difficult to move variable definitions around when they are written likeThe text was updated successfully, but these errors were encountered: