-
Notifications
You must be signed in to change notification settings - Fork 33
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
Capturing elements like emacs slurp #10
Comments
I'd also like this. It allows Another thing I noticed (separate issue I guess) is that some vim-sexp operations tend to modify the |
Hello, thanks for reporting!
This makes plenty of sense. It's easy to just use
This doesn't invalidate your point, but you can use
Does this mean that given the following (with cursor at (let [x█]) foo bar A first slurp-right produces the following: (let [x█] foo) bar A second slurp-right produces this: (let [x█ foo]) bar And a third slurp-right produces: (let [x█ foo] bar) This is also useful behavior if I've understood correctly. One more thing, what happens to the cursor position when slurping left and an opening bracket moves from current line to a line above? Does the cursor position stay at the same column, or does it shift left one to stay on the same character? I don't have much experience with Emacs, so I appreciate your input. @justinmk writes:
Ah, that's an oversight. Visual marks are intentionally overwritten for visual mode bindings, but they should not be mangled when called from normal mode. I'll fix this up as well. Thanks! |
Yes, that. If the cursor moves then I have to Thank you! |
That's exactly right.
emacs will actually automatically indent if you slurp something from the line above or below. I, personally, don't miss this as much and the rules are a bit harder to nail down, here's some examples: let
(█[x]) will become (let
█ [x]) If the cursor had been on the (let
[█x]) If you are inside an empty list, it will join the lines let
() Becomes (let█) Slurping below: (let [█x])
foo
bar becomes (let [█x]
foo)
bar (let [█x
foo])
bar (let [█x
foo]
bar) |
@guns if you want to take a different path forward on this, please feel free to reject my PRs. |
Hi, great plugin!
There are two features of slurping in emacs paredit mode that I really miss in vim-sexp. The cheat sheet here shows how it behaves and below is why it feels more natural for me to use than the vim equivalents.
http://emacswiki.org/emacs/PareditCheatsheet (See
Barfage & Slurpage
)Take the example of introducing a
let
for themap
result, after typing(something xs)
The first thing I miss, is that slurping an element does not move the cursor (or if at the end of a line it moves to the prev char). It makes it far easier to quickly drop out of insert, put forms in the right place and then back to insert without losing focus of where you were working. In the example, I can finish the vector and easily slurp in the
map
I was working on with...[xs])<ESC><slurp><slurp>
. With vim-sexp captures, it's painful to do this as I need to navigate to the previous form after each slurp.The second thing is that slurping will recursively slurp up the tree if there's nothing to slurp in the current form. In the example, my cursor can be on the
s
(the last non-closing char I need to type) and I can just slurp three times to get the map into the binding and the final form into the body.Would it be possible to change capture to behave in this way or introduce slurp and barf calls with this behavior?
I would have loved to do a PR but I've never written a vim plugin and I felt like I was way over my head when I dove into this.
The text was updated successfully, but these errors were encountered: