I think I finally understood what they do, but I can’t think of a usecase that wouldn’t be better served by “set operation” inspired operations (intersect, union, hull and difference).

I use `<a-z>u`

when I know from which part I want a selection to start, but I don’t have a structural way to get/know the end, so I save the start with Z and then create a selectio till my position with `<a-z>u`

.

That’s the smallest interval containing all of your selections. The hull, mathematically speaking. If you had a primitive available, say `<a-%>`

, that replaces all selections with an interval containing all of them (their hull), this would become a search for interesting locations, which you save by `<a-Z>a`

, then selecting them with `z`

, then selecting the range in which they occur with `<a-%>`

. This much more clearly expresses the intent.

I want to understand why mawww has chosen to have `<a-z>u`

and `<a-z>i`

behave like they do, instead of having them be a “set-like” union or intersection.

oh, I see, I remember some time ago reading this: Selections combinations · mawww/kakoune Wiki · GitHub, don’t know if it helps but I remember it was interesting for me at that moment.

I think at the time i went with what would help with the actual issue i was trying to fix (some pretty involved indentation ligic IIRC) and a straightforward implementation. I think this was a mistake and would like to change those to proper mathematical operations.

@mawww

One issue I see with implementing such set operation like combinations is that there only seem to be “smart” ways of dealing with character ranges that are covered by multiple selections.

Instead, maybe use the marks register as a way to store interesting selections (via “adding”), then bring them up with `z`

and do the set operation afterwards. A union would then more or less come down to `<a-+>`

. An intersection is less obvious, maybe a new `<a-->`

could figure out groups of overlapping selections and then drop each group for its intersection, while leaving selections without any overlapping other untouched. I feel this could be the most commonly wanted case.

What do you think about the previosly mentioned `<a-%>`

?

I like this idea, I believe this might be a common use case.

Currently I use something like `,Z<a-u>),<a-z>u`

.

We should clean up the terminology, hull makes so much sense.

here’s an implementation of the `<a-%>`

hull. I’ll try this for a while.

```
define-command -override hull %{
evaluate-commands -save-regs ^ %{
evaluate-commands -save-regs ab %{
execute-keys %exp{%reg{hash}()}
execute-keys '"aZ'
execute-keys ,"bZ"az(,"b<a-z>u
execute-keys -save-regs '' Z
}
execute-keys z
}
}
map global normal <a-percent> %{:hull<ret>}
```

There’s also https://github.com/occivink/kakoune-set-operations/blob/master/set-operations.kak