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

Marks #3720

Closed
wants to merge 5 commits into from
Closed

Marks #3720

wants to merge 5 commits into from

Conversation

the-mikedavis
Copy link
Member

Marks are a way of recording selections/ranges in a way that can be used later. It's like the ability to store jumplist entry in a registers plus commands to combine selections to/from registers. This PR implements kakoune's marks commands and also adds a function that joins the ranges of a given selection together.

I would like to explore basing LSP snippets on marks so I'll keep this as a draft for now.

Questions:

  • The implementation (prior to this change) knows "multiple selections" as one helix_core::selection::Selection with many helix_core::selection::Ranges. Colloquially we call this multiple selections though. Should the marks commands say "selections" or "ranges"?
  • Where to put the marks commands? z/Z is taken and the normal mode keymap is pretty much full. I'm using ^ for now which is a bit hidden but it's nice that it matches the default marks register.

Closes #703

@the-mikedavis the-mikedavis added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Sep 5, 2022
@EpocSquadron
Copy link
Contributor

IMHO, Range should be renamed to Selection in code for confirmation with how is referred to colloquially. Correspondingly, Selection should be renamed simply to Selections, plural. But that's probably a separate PR. Regardless I think the user facing language should follow what people are saying.

@EpocSquadron
Copy link
Contributor

There's some really interesting discussion about how kakoune's marks could be improved or generalized in this post on the kakoune discourse that I think should be thought through before we commit to exactly the current kakoune implementation here. I'd like our version to be an improvement rather than just a copy.

@the-mikedavis
Copy link
Member Author

The top-level folding ideas look like marks ideas applied to the ranges of the current selection (rather than the current selection and the selection in the register). ^j in this PR implements <A-r>u. I'm not sure intersection makes sense since you can't have overlapping ranges in a single selection. It could be used as the space between all consecutive ranges in a selection I suppose.

Since only s/S are taken under ^ currently, we could rename ^j as ^u and implement the rest to act on the ranges in the current selection only.

I'm not sure I like the reduce idea with |, it seems too specific and I'm having a hard time imagining a useful use-case for it.

@EpocSquadron
Copy link
Contributor

EpocSquadron commented Sep 7, 2022

I'm still chewing on adding operations on the current selections. I agree intersection makes little sense there, and at least left and right most are achievable with a combination of (/) and ,. Longest and shortest could theoretically be useful after s with a regex giving variable length matches, but it's pretty niche.

I agree that the pipe thing as presented is too complicated and niche. There's something to being able to iterate and accumulate over contents of current selections, but that's best as a separate issue.

In the meantime I found the original issue where z/Z was chosen and apparently it started as ^ too. I kind of agree it's not super ergonomic. What about $? Looks like the s in selections, and we could use that as the default register instead of ^. Perhaps even less ergonomic though.

@EpocSquadron
Copy link
Contributor

EpocSquadron commented Sep 7, 2022

One operation missing that has a lot of discussion in kakoune is adding the difference operation.

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Sep 13, 2022
@kirawi kirawi added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Apr 2, 2024
@goyalyashpal
Copy link
Contributor

can this one be considered closed?

@VKondakoff
Copy link
Contributor

So, is the marks feature abandoned?

@the-mikedavis
Copy link
Member Author

I haven't looked at this or worked on it in a while. It's still a useful feature I'd like to see implemented eventually but I don't plan to work on it any time soon. So I'll close this out.

Anyone interested can pick up this PR but it needs some work: we need to map the saved ranges through changes to their documents.

@the-mikedavis the-mikedavis deleted the md-marks branch April 5, 2024 19:05
@archseer archseer mentioned this pull request Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marks
5 participants