Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.


  • 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