Skip to content
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

Choose the proper form to evaluate #32

Open
tomaskulich opened this issue Dec 13, 2016 · 6 comments
Open

Choose the proper form to evaluate #32

tomaskulich opened this issue Dec 13, 2016 · 6 comments

Comments

@tomaskulich
Copy link

searching opening '(' on the first line seems like a decent heuristics for the beginning of the form.

  let topline = search('^(', 'bn') - 1

The bottomline however is searched for badly. Searching for corresponding ')' may not work, because there may not yet be corresponding closing bracket:

  let bottomline = searchpair('(','',')', 'n') + 1

Good idea may be to look for the next opening bracket on the first line (i.e. beginning of the next 'main' form) (or the end of file if not existing). I'm not sure how to implement this in vimscript though.

@bhurlow
Copy link
Owner

bhurlow commented Dec 13, 2016

@tomaskulich yep, this is definitely the tricky part thanks for the bump. I think the topline search is adequate as this is what vim-sexp is doing. Maybe a fallback for searchpair() is the next step

@tomaskulich
Copy link
Author

Well, if I understand correctly what the plugin is trying to do, then the searchpair approach is IMO conceptually broken; you cannot ask for matching paren, if the paren is yet-to-be inserted - which is very often the case. The searchpair will work correctly only if there is nothing to do (with this kind of parens)

@bhurlow
Copy link
Owner

bhurlow commented Dec 13, 2016

@tomaskulich I'm thinking the best thing here might be like you proposed, to count parens until we hit the next opening (

@shaunlebron
Copy link

The proposed solution is what atom-parinfer does 👍

@bhurlow
Copy link
Owner

bhurlow commented Dec 13, 2016

@shaunlebron good to know thanks!

bhurlow added a commit that referenced this issue Dec 13, 2016
modify SelectFullForm to not rely on paren matching
partially solves #32
@bhurlow
Copy link
Owner

bhurlow commented Dec 13, 2016

ok, I did this: 8c5269b. Could be few edge cases still left, although this definitely works smoother

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants