Skip to content

Add support for “grand” scopes #124

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

Closed
pokey opened this issue Jul 18, 2021 · 7 comments · Fixed by #2130
Closed

Add support for “grand” scopes #124

pokey opened this issue Jul 18, 2021 · 7 comments · Fixed by #2130
Assignees
Labels
enhancement New feature or request

Comments

@pokey
Copy link
Member

pokey commented Jul 18, 2021

Eg "take grand funk" would take function containing function contains token. Could also add "great grand funk" etc.

@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Jul 18, 2021

Maybe use ordinals here?

take second funk
take third map

@pokey
Copy link
Member Author

pokey commented Jul 18, 2021

We're going to want those ordinals for the new grammar. "Take second funk" will take the second function in the class containing the cursor

@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Jul 18, 2021

Okay then use super maybe?
take super funk
take second super funk

Is just don't think that great grand is the best syntax for nested code. What if you have more levels nested? But it's ok if you don't use it like that of course. You could always find a mark closer to the scope you actually want.

@pokey
Copy link
Member Author

pokey commented Jul 18, 2021

Yeah "super" could work, tho I'm not sure it helps because "second super funk" would want to be the second "super funk" in the new grammar

But yeah I agree multiple levels of nesting will be awkward as it would be "great great grand funk". Tho not sure how common it will be to want to go up more than 2 levels ("grand funk"), so from my perspective it's more important for it to be possible than compact

Could do something like "two super"? Idk not sure that feels right

Also we can (and maybe should?) make it so "funk" applied to a function target will expand to next higher funk rather than being idempotent, so then you could do "funk funk", which also scales like the "grand" approach but might have benefits

@pokey pokey added the enhancement New feature or request label Aug 6, 2021
pokey added a commit that referenced this issue Oct 19, 2022
AndreasArvidsson added a commit that referenced this issue Oct 23, 2022
* Original scope handlers

* More stuff

* Use proper token stage in sub token stage

* Work around for identifier matcher

* Use new scope handler in relative scope stage

* Use new scope handlers in ordinal scope stage

* Update usage of containing indices

* Rename

* Refactored create target

* Clean up

* clean up

* Add some tests that should pass

* Add a bunch more tests

* Attempt at different approach to scope handlers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Initial implementation of new idea

* More work on this stuff

* Rename and add some todos

* More stuff

* Tweaks

* Renames and docstrings

* Restructuring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* More jsdocs

* Tweaks

* Test fixes

* Fix error messages

* Revert `OrdinalScopeStage`

* Tweak

* jsdocs; fix import

* Don't export legacy types

* Fix import

* Preparation for surrounding pairs

* Naming cleanup

* Unify `getLegacyScopeStage` functions

* Lots of cleanup

* Fix regex `lastIndex` issue

* More cleanup

* More cleanup

* More cleanup

* Add `ancestorIndex` in prepartion for #124

* Add more jsdocs

* More docs

* More docs

* docstrings

* Improve hierarchical error type

* Docs

* More minor dog tweaks

* More docs

* More docs

* Doc strings and a couple tests

* Remove `isPreferredOver`

* Support `ancestorIndex` on api surface

* Improved jsdocs

* Split and cleanup relative stages

* Make scope handler constructor args optional

* More legacy type fixes

* Add `"identifier"` scope

* Working new code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Docs + cheatsheet

* Update docs

* Add jsdoc

* jsdoc

* JSDocs

* doc tweaks

* reflow

* Tweaks

Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
cursorless-bot pushed a commit that referenced this issue Oct 23, 2022
* Original scope handlers

* More stuff

* Use proper token stage in sub token stage

* Work around for identifier matcher

* Use new scope handler in relative scope stage

* Use new scope handlers in ordinal scope stage

* Update usage of containing indices

* Rename

* Refactored create target

* Clean up

* clean up

* Add some tests that should pass

* Add a bunch more tests

* Attempt at different approach to scope handlers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Initial implementation of new idea

* More work on this stuff

* Rename and add some todos

* More stuff

* Tweaks

* Renames and docstrings

* Restructuring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* More jsdocs

* Tweaks

* Test fixes

* Fix error messages

* Revert `OrdinalScopeStage`

* Tweak

* jsdocs; fix import

* Don't export legacy types

* Fix import

* Preparation for surrounding pairs

* Naming cleanup

* Unify `getLegacyScopeStage` functions

* Lots of cleanup

* Fix regex `lastIndex` issue

* More cleanup

* More cleanup

* More cleanup

* Add `ancestorIndex` in prepartion for #124

* Add more jsdocs

* More docs

* More docs

* docstrings

* Improve hierarchical error type

* Docs

* More minor dog tweaks

* More docs

* More docs

* Doc strings and a couple tests

* Remove `isPreferredOver`

* Support `ancestorIndex` on api surface

* Improved jsdocs

* Split and cleanup relative stages

* Make scope handler constructor args optional

* More legacy type fixes

* Add `"identifier"` scope

* Working new code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Docs + cheatsheet

* Update docs

* Add jsdoc

* jsdoc

* JSDocs

* doc tweaks

* reflow

* Tweaks

Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@bra1nDump
Copy link
Collaborator

Came across this after discovering take state state is a totally valid command, but the second state is a noop. I would expect this to work like what is being proposed here take super [scope].

The idea reminds me of VSCode 'Expand selection' command.

@AndreasArvidsson
Copy link
Member

Making expanding to a scope non-idempotent is an idea I've already had. One could argue about the behavior between commands versus inside the same command, but the idea is very similar.
#1116

@AndreasArvidsson AndreasArvidsson linked a pull request Dec 14, 2023 that will close this issue
3 tasks
@AndreasArvidsson AndreasArvidsson self-assigned this Dec 14, 2023
@pokey
Copy link
Member Author

pokey commented Dec 14, 2023

We rely on idempotence in certain scenarios. For example, for "instance", we attempt to expand to token to determine if it's a token. I'd be hesitant to change these semantics, but I can see how it could be useful

thetomcraig-aya pushed a commit to thetomcraig/cursorless that referenced this issue Mar 27, 2024
* Original scope handlers

* More stuff

* Use proper token stage in sub token stage

* Work around for identifier matcher

* Use new scope handler in relative scope stage

* Use new scope handlers in ordinal scope stage

* Update usage of containing indices

* Rename

* Refactored create target

* Clean up

* clean up

* Add some tests that should pass

* Add a bunch more tests

* Attempt at different approach to scope handlers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Initial implementation of new idea

* More work on this stuff

* Rename and add some todos

* More stuff

* Tweaks

* Renames and docstrings

* Restructuring

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* More jsdocs

* Tweaks

* Test fixes

* Fix error messages

* Revert `OrdinalScopeStage`

* Tweak

* jsdocs; fix import

* Don't export legacy types

* Fix import

* Preparation for surrounding pairs

* Naming cleanup

* Unify `getLegacyScopeStage` functions

* Lots of cleanup

* Fix regex `lastIndex` issue

* More cleanup

* More cleanup

* More cleanup

* Add `ancestorIndex` in prepartion for cursorless-dev#124

* Add more jsdocs

* More docs

* More docs

* docstrings

* Improve hierarchical error type

* Docs

* More minor dog tweaks

* More docs

* More docs

* Doc strings and a couple tests

* Remove `isPreferredOver`

* Support `ancestorIndex` on api surface

* Improved jsdocs

* Split and cleanup relative stages

* Make scope handler constructor args optional

* More legacy type fixes

* Add `"identifier"` scope

* Working new code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Docs + cheatsheet

* Update docs

* Add jsdoc

* jsdoc

* JSDocs

* doc tweaks

* reflow

* Tweaks

Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants