Skip to content

Instantly share code, notes, and snippets.

@oakmac
Last active February 21, 2021 15:17
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save oakmac/e2aef73f121ab84d437390ec852561ab to your computer and use it in GitHub Desktop.
Parinfer Smart Mode Thoughts

Parinfer Smart Mode Thoughts

21 Feb 2021 - I woke up this morning with these thoughts about Parinfer and wanted to document them.

Smart Mode is a nice enhancement on top of Indent Mode, but many editor APIs do not support the "buffer change" information needed to make Smart Mode work correctly.

What if instead of passing in any buffer change to Smart Mode, we only run Smart Mode on the following keystrokes:

  • space bar
  • backspace
  • tab
  • shift-tab

The idea is that those "commands" (ie: normal key modifications to any buffer in just about any program) can be handled by Parinfer's Smart mode with a known change set.

For any other change to the buffer (ie: copy/paste) we can apply Indent Mode like normal.

Almost all editor APIs support overriding default key behavior, so it should not be a problem to hook into those four events / keys.

Considerations

  • What about find/replace buffer changes?
  • Would this have any implications for multi-cursor editing?
  • What about when the user has multiple lines selected?
  • We could also introduce ctrl + Tab and ctrl + Shift + Tab for "only do Indent Mode for this tab operation"
    • ie: this operation should only effect the line that the cursor is directly on (not "child" lines)
    • there are times when you want to indent or de-dent a line, but not move the forms "underneath it"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment