cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Create new connectives to combine target lists

Open pokey opened this issue 2 years ago • 2 comments

We currently have connectives that zip lists of targets and form ranges between them. We also have "and", which is just a union at the set level. There are other ways we could combine two lists of targets

  • [ ] Set subtraction where we remove any targets in A that touch targets in B. This is the semantics used by the "give" action
  • [ ] Subtraction where we remove the chunks from targets B that intersect A. Eg to remove a word section from the middle of a token selection
  • [ ] Union where we merge targets that are touching
  • [ ] Intersection where targets must be identical
  • [ ] Intersection where we keep any targets that touch each other
  • [ ] Intersection where we modify the selections

To generalise, we have different set operations (union, intersection, subtraction, etc), and we can apply them in different ways (at character level, target level with equality being strict, target level with equality being touching)

Could think about other granularities (eg word-level / arbitrary scope level)

pokey avatar Jul 15 '23 09:07 pokey

@josharian your suggestion of intersecting function with visible made me think of this

pokey avatar Jul 15 '23 09:07 pokey

From a practical perspective, these use cases made me seek out this issue (may not be perfect, since I'm still learning):

  • I want to change a double-quoted string to a single-quoted string. Currently, you can, e.g., move the cursor somewhere inside the string and say "take first char string and last char string", then type the replacement quote character. With selection difference, you could also say "take string hat minus its inside string".
  • Removing surrounding parantheses: With selection difference, you could say "chuck round hat minus its inside round".

(Would be great, if "string" in "inside string" and "round" in "inside round" could even be omitted. Maybe "its" could refer to more than a mark, if the user omitted the modification object of a modifier like "inside".)

Enyium avatar Apr 17 '25 17:04 Enyium