Remove duplicates from clipboard ring
Is your feature request related to a problem? Please describe. I like using our freshly updated clipboard ring—it expands the limits of what clipboards can do. However, I often end up with duplicate pieces of data if I do this editing sequence, for example:
- edit text
- copy "foo"
- edit-text
- copy "bar"
- edit text
- copy exact same "foo"
After it, clipboard ring looks like "foo", "bar", "foo". Having these duplicate entries clutters the view and makes clipboard ring much less useful.
Describe the solution you'd like
Remove duplicates from the ring. My first implementation itch is to migrate to plain lists and do pushnew on them, which would be simple, fast, and dependency-free. containers:ring-buffer seems to not de-duplicate the data and is otherwise not used to its full power, so I don't see much use in it here.
Describe alternatives you've considered
Obviously, my initial implementation itch may be wrong. @Ambrevar, are you maybe aware of de-duplicating data structures from e.g. containers, that we can use?
Just a minor observation: de-duplication should be optional otherwise it can be confusing.
You expect the last thing you copied to be at the beginning of the ring, but when that thing is a duplicate then this expectation is broken.
Yes, a good observation. Doesn't mean de-duplication should be optional, though. Emacs just shuffles the duplicate entry back at the top, and that's a pretty intuitive behavior.
@Ambrevar, are you maybe aware of de-duplicating data structures from e.g.
containers, that we can use?
Not that I know of.
Curiously I don't remember this problem. I feel like there must have been a trivial solution, but I can't remember now...
Note that if you want to switch to plain lists, it won't be equivalent to a ring, unless you constraint its length somehow.
@Ambrevar, are you maybe aware of de-duplicating data structures from e.g.
containers, that we can use?Not that I know of.
Curiously I don't remember this problem. I feel like there must have been a trivial solution, but I can't remember now...
Yeah, feels the same to me—someone must've done this already :(
Note that if you want to switch to plain lists, it won't be equivalent to a ring, unless you constraint its length somehow.
Yes, and that feels like a benefit, because we'd no longer have suggestions deleted from the clipboard ring! More options, more suggestions, more externalized memory!
But then you can't run the browser forever without hitting memory issues... :p
(Generally speaking, Nyxt needs to do better with memory management!)
But then you can't run the browser forever without hitting memory issues... :p
I second this. A ring is a more robust solution.
Important issue.
After reading through this thread again, I think that Andre's initial observation was correct. Doing deduplication on this data structure is confusing. There is no upside to doing deduplication. No matter what, the user will need to navigate to get to whatever entry they are interested in. Better to preserve the duplicates as is done with M-y in Emacs. It is not too arduous to just type whatever that you need.