Selection combining operator "u: union" is little bit misleading

Hello! This is my first post on discuss. (And excuse me that first post is about “Complaints”…:bowing_man:)

Well, as the title says, when I first used <a-z>/<a-Z>, I was a little bit confused because I thought there’s no difference between “a: append lists” and “u: union.”

Wikipedia says:

the union of a collection of sets is the set of all elements in the collection.

Yes, this definition is correct. And selection seems a kind of set contains characters as its elements. So I expected both <a-z>a and <a-z>u to “add” registered selections to current ones. However, you know, this exactly is what <a-z>a is doing, not <a-z>u is.

What “u: union” is doing is… for my poor English, I can’t find proper words… a sort of “connect each selections.” Hmm… in my intuition, “union” never add elements that are outside sets…

After that, I found these conventions came from vis’ pairwise combining operator. So now I don’t think we should rename these operators, but do think adding some more explanations to infobox helps newcomers.

How do you think?

1 Like

Hi

Here’s what currently happen with this union operator:

        case CombineOp::Union:
        sel.set(std::min(sel.min(), other.min()),
                std::max(sel.max(), other.max()));
        break;

Example: the 2nd line of a buffer is selected and saved into register with Z. Then you go on the 5th line, select it and decide to do a union with <a-z>u. The result is one big selection starting on line 2 and finishing line on 5. Whereas an append operation <a-z>a would result in only the line 2 and the line 5 selected.

image

So as you said the definition is maybe not strictly mathematically correct.
The behaviors I described above may be quite hard to describe succinctly in a small infobox.
(I proposed a little improvement this week: add unambiguous titles for infobox "enter combining operator" · Issue #3089 · mawww/kakoune · GitHub to a related matter)

Maybe we need to start a “combine operators” page on the wiki with visual example.

Also, earlier this year, @alexherbo2 created an issue about adding a difference operator: Add a difference 'd' operator to marks · Issue #2850 · mawww/kakoune · GitHub

2 Likes

In fact, your issue (#3089) recalled me a kind of awkwardness of “union” operator and led to create this topic :smile:
Well, as you said, the infobox is too small for clear explanation, so now I also think it’s better to improve the wiki. (But I’m too lazy to make visual example of these…)

Also, I welcome “difference” (or “subtract”) operator! To be honest, in almost all interactive use-case, I chose only “append lists” other than pairwise operators because they are too complicated.
However, I think these are essential for “text manipulation language.” And I guess difference operator may be useful when to split selections manually.

I’ve started this wiki page to describe the current situation: https://github.com/mawww/kakoune/wiki/Selections-combinations

2 Likes

looks cool! :sunglasses:

(And I didn’t know how “intersection” works when selections do not overlap…)

I think part of the confusion is that the operators are pairwise intersection, union, and so forth. I suspect just adding that word to the UI would have cleared things up.

1 Like

This commit resolves the ambiguity: Add unambiguous titles for infobox "enter combining operator" · mawww/kakoune@2148b84 · GitHub

The next step that would really help about these combinators is my proposal for the mark highlighter: Add mark highlighter by Delapouite · Pull Request #2461 · mawww/kakoune · GitHub

1 Like