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

Flow movements #23

Merged
merged 18 commits into from May 15, 2017
Merged

Flow movements #23

merged 18 commits into from May 15, 2017

Conversation

bpstahlman
Copy link
Collaborator

Synopsis
Adds commands for moving in and out of lists in a way that's not possible with vim-sexp's other movement commands. Something like Paredit's up/down list commands, but with a traversal paradigm inspired by the Emacs Lispy package's "flow" command.

Motivation
Although vim-sexp already provides commands for moving forward and backward within a list, sometimes you want to "escape" from the current list, or descend into a child list. The added commands are called "flow commands" because they permit you to flow freely in and out of lists. In fact, it is possible to use an unbroken sequence of flow commands to move all the way from one end of the buffer to the other. Flow commands fall into 2 basic categories:

  1. List
    Land only on brackets. There are 4 variants, differentiated by both the direction moved in the buffer, and the type of bracket landed on (open or close).

  2. Leaf
    Land only on leaf (non-list) elements (atoms, strings, comments)

See doc/vim-sexp.txt for details and examples...

considering incorporating the BRACKET jumps into the same function, so I
wanted to establish a rollback point.
non-list elements crossing list boundaries) are basically working.
Checking in work before beginning on documentation and cleanup.
Just realized there's a good use-case for visual mode versions of these
commands. Establishing a rollback point before implementing...
flow commands need cursor to remain on near side of element when visual
mode is re-activated, added an optional arg to select_current_marks(),
which allows desired cursor position (which obviously must correspond to
one of the visual marks) to be specified. Need to clean up and document.
Also need to add visual mode support for the element flow commands.
whether to modify logic to use end of visual selection in desired
direction as start of search. Currently, I use cursor position
unconditionally, but it occurs to me that if a single element is
selected, it's likely the user would want the jump to move to a
different element, not just a different side of the current one.
the documentation. Did a bit of cleanup and commenting in the source
file, but more is needed...
list flow commands to note the distinction between in/out flow. Began
(but didn't finish) updating the documentation. Also, changed "element"
to "nonlist" in what were previously known as "element flow" commands,
to reflect the fact that a list can't be a target of a non-list flow
command (though a list can be an element in normal vim-sexp parlance).
documentation to reflect the changes. A bit more cleanup needed, but
wanted to establish rollback point before picking one of the alternate
presentations of the list flow command documentation.
bit more rework to handle character literals and comments properly.
however, I'm thinking of going to a simpler fix, which is more robust,
albeit possibly a bit less efficient.
was added to handle some edge cases that aren't handled any where else
in vim-sexp.
Reworked handling of BOF/EOF for list_flow to make more consistent with
the philosophy of accepting whatever we find as target: e.g., I now
select the list corresponding to the final bracket of desired type, even
if cursor started on it. Also, fixed bug whereby only parens were
treated as brackets.
--leaf_flow--
Simplified logic significantly after deciding not to handle (admittedly
somewhat pathological) edge cases that the rest of vim-sexp doesn't
handle. Commented the rationale in the function header.
--Cleanup--
Final review and commenting of flow functions (both list and leaf).
Removed alternate (but now dead) implementations of leaf_flow.
@guns guns merged commit 72d3c58 into guns:master May 15, 2017
@guns
Copy link
Owner

guns commented May 15, 2017

Impressive changes. Now that this is implemented, I can see the ergonomic benefits.

@bpstahlman
Copy link
Collaborator Author

bpstahlman commented May 15, 2017 via email

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

Successfully merging this pull request may close these issues.

None yet

2 participants