cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.14k stars 79 forks source link

Clearer / more verbose grammar for `"head <M>"` / `"tail <M>"` #972

Open pokey opened 2 years ago

pokey commented 2 years ago

The problem

Today, the grammar for "head" and "tail" is quite terse, and leads to ambiguities that require some knowledge to resolve. The "head" modifier can select from a target past the start of any modifier applied to that target. The default modifier is "line". Thus, "head air" selects from the air token past the start of the line, but "head paint air" selects from air through the start of the sequence of non-whitespace characters containing air. If you wanted to select from the sequence of non-whitespace characters containing air past the start of the line, you need to know to say "head line paint air", so that "head" doesn't "swallow" the "paint" modifier.

In addition, the terse grammar can be unintuitive for new users; see eg #939

The solution

pokey commented 1 year ago

One thing we may want to do as well would be to make the default modifier of "tail" be the iteration scope of the input. Then:

Might be a bit too magical tho 🤔