cursorless
cursorless copied to clipboard
Clearer / more verbose grammar for `"head <M>"` / `"tail <M>"`
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
- [ ] Change the grammar of
"head"/"tail"to require"of"when applied to a modifier other than line, eg"head of paint air". The new capture would be:
Note that this new grammar removes the ambiguity that exists in today's grammar, as"[of (" "<user.cursorless_interior_modifier> |" "[<user.cursorless_interior_modifier>] <user.cursorless_head_tail_swallowed_modifier>" ")]""head"will never try to "swallow" subsequent modifiers if you don't use the word"of". Thus, for example,"head paint air"will take from the sequence of non-whitespace characters containingairpast the start of the line - [ ] Pop up a notification to alert existing users that behaviour of
"head <M>"is changing (in VSCode? in Talon? Need to store something to avoid duplicate notifications) - [ ] Add a tag that activates today's
"head <M>"behaviour, as it is preferred by power users - [ ] Update cheatsheet to look at the new tag and use the correct grammar
- [ ] Update docs to use the new grammar