Skip to content
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

Support one-way aliases #155

Closed
mitchellwrosen opened this issue May 20, 2023 · 4 comments
Closed

Support one-way aliases #155

mitchellwrosen opened this issue May 20, 2023 · 4 comments
Labels

Comments

@mitchellwrosen
Copy link

Hi there, I'd like to propose a feature similar to equivalence_classes, but one-way.

As a motivating example, suppose I want to make the . character equivalent to any special character, because it's easier to type than most:

equivalence_classes = { ".`~!@#$%^&*()-_=+[{]}\\|;:'\",<>/?" }

This works okay, but it does prevent me from ever jumping to (say) the comma character in this sequence:

","

because it's equivalent to an overlapping sequence of three dots:

...

If I could ask leap to treat . as any operator character, but not the other way around, then I could jump to the middle comma in the above example with s,"<label>, as usual.

Thanks!

@ggandor
Copy link
Owner

ggandor commented May 20, 2023

I should probably create a FAQ entry, this is an obvious request, but - just like smartcase - impossible by design: #89 (comment), #28.

@mitchellwrosen
Copy link
Author

Thanks, I trust your assessment, but I'm not sure I understand.

Think about it: when targeting k+, after pressing k, the plugin cannot know whether you will type + or * (the wildcard character), so it cannot decide which label to show (the labels are different in the two cases, since the wildcard would match a lot more targets).

Why must the plugin know whether you will type + or * after k in this example? I should think that after a single k, we'll get a label after every k<c> pair, and pressing * would simply drop no labels (because all k<c> match).

Or, in my example, I don't exactly have a wildcard, but I would think that after (say) j., we could leave a label after every j!, j@, j#, etc. in the buffer.

@ggandor
Copy link
Owner

ggandor commented May 21, 2023

I should think that after a single k, we'll get a label after every k pair, and pressing * would simply drop no labels (because all k match).

The problem is that in phase 1 there are conflicting labels, you cannot just keep all of them. Each sublist of targets gets labeled by the same label list, e.g. kas get l1, l2, l3..., and kbs also get l1, l2, l3... The ambiguity is only resolved in phase 2, once you enter the second character, and only the chosen sublist remains.
Because of this (ahead-of-time labeling), any kind of aliasing/mapping can only work in a "symmetric" way in Leap. We could say that . will match everything, but then everything has to match everything (= equivalence classes); after pressing k, you either label a given ka match as part of the k. joker sublist, or the shorter ka sublist, we can't have the cake and eat it too.

@mitchellwrosen
Copy link
Author

Oh, of course. I hadn't ever noticed that labels conflict but that does make sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants