* bug#52543: Add option to eliminate all duplications from the kill ring
@ 2021-12-16 9:49 ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-19 12:04 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-12-16 9:49 UTC (permalink / raw)
To: 52543
There is kill-do-not-save-duplicates, but it deletes
only subsequent duplicates.
There should be an other variable which prevents any duplicates
even if there are, say, 10 or 20 items between them.
I expected kill-do-not-save-duplicates to do that, that variable
seems misnamed. It should be kill-do-not-save-subsequent-duplicates
instead.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#52543: Add option to eliminate all duplications from the kill ring
2021-12-16 9:49 bug#52543: Add option to eliminate all duplications from the kill ring ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-12-19 12:04 ` Lars Ingebrigtsen
2021-12-19 17:03 ` Juri Linkov
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-19 12:04 UTC (permalink / raw)
To: ndame; +Cc: 52543
ndame <laszlomail@protonmail.com> writes:
> There is kill-do-not-save-duplicates, but it deletes
> only subsequent duplicates.
>
> There should be an other variable which prevents any duplicates
> even if there are, say, 10 or 20 items between them.
>
> I expected kill-do-not-save-duplicates to do that, that variable
> seems misnamed. It should be kill-do-not-save-subsequent-duplicates
> instead.
This has previously been discussed, and we decided to not alter how this
works, because it'd be too surprising. (And there are options to filter
the kill ring that users that want that can use.) So I'm closing this
bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#52543: Add option to eliminate all duplications from the kill ring
2021-12-19 12:04 ` Lars Ingebrigtsen
@ 2021-12-19 17:03 ` Juri Linkov
2021-12-19 18:05 ` Juri Linkov
2021-12-19 19:44 ` Juri Linkov
0 siblings, 2 replies; 6+ messages in thread
From: Juri Linkov @ 2021-12-19 17:03 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: ndame, 52543
>> There is kill-do-not-save-duplicates, but it deletes
>> only subsequent duplicates.
>>
>> There should be an other variable which prevents any duplicates
>> even if there are, say, 10 or 20 items between them.
>>
>> I expected kill-do-not-save-duplicates to do that, that variable
>> seems misnamed. It should be kill-do-not-save-subsequent-duplicates
>> instead.
>
> This has previously been discussed, and we decided to not alter how this
> works, because it'd be too surprising. (And there are options to filter
> the kill ring that users that want that can use.) So I'm closing this
> bug report.
Indeed:
(setq kill-transform-function (lambda (s) (unless (member s kill-ring) s)))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#52543: Add option to eliminate all duplications from the kill ring
2021-12-19 17:03 ` Juri Linkov
@ 2021-12-19 18:05 ` Juri Linkov
2021-12-19 19:44 ` Juri Linkov
1 sibling, 0 replies; 6+ messages in thread
From: Juri Linkov @ 2021-12-19 18:05 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: ndame, 52543
>>> There is kill-do-not-save-duplicates, but it deletes
>>> only subsequent duplicates.
>>>
>>> There should be an other variable which prevents any duplicates
>>> even if there are, say, 10 or 20 items between them.
>>>
>>> I expected kill-do-not-save-duplicates to do that, that variable
>>> seems misnamed. It should be kill-do-not-save-subsequent-duplicates
>>> instead.
>>
>> This has previously been discussed, and we decided to not alter how this
>> works, because it'd be too surprising. (And there are options to filter
>> the kill ring that users that want that can use.) So I'm closing this
>> bug report.
>
> Indeed:
>
> (setq kill-transform-function (lambda (s) (unless (member s kill-ring) s)))
Here is the same as a choice to make it easier for everyone
to satisfy this frequent need - like history-delete-duplicates
and comint-input-ignoredups in Emacs, and ignoredups in shell.
If this is ok, more documentation could be added:
diff --git a/lisp/simple.el b/lisp/simple.el
index 959e7ea94c..466bc9c12d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5118,6 +5118,8 @@ kill-transform-function
be put on the kill ring). It should return a string or nil. If
the latter, the string is not put on the kill ring."
:type '(choice (const :tag "No transform" nil)
+ (const :tag "Ignore duplicates"
+ (lambda (s) (unless (member s kill-ring) s)))
function)
:group 'killing
:version "28.1")
--
^ permalink raw reply related [flat|nested] 6+ messages in thread
* bug#52543: Add option to eliminate all duplications from the kill ring
2021-12-19 17:03 ` Juri Linkov
2021-12-19 18:05 ` Juri Linkov
@ 2021-12-19 19:44 ` Juri Linkov
2021-12-20 10:01 ` Lars Ingebrigtsen
1 sibling, 1 reply; 6+ messages in thread
From: Juri Linkov @ 2021-12-19 19:44 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: ndame, 52543
>>> There is kill-do-not-save-duplicates, but it deletes
>>> only subsequent duplicates.
>>>
>>> There should be an other variable which prevents any duplicates
>>> even if there are, say, 10 or 20 items between them.
>>>
>>> I expected kill-do-not-save-duplicates to do that, that variable
>>> seems misnamed. It should be kill-do-not-save-subsequent-duplicates
>>> instead.
>>
>> This has previously been discussed, and we decided to not alter how this
>> works, because it'd be too surprising. (And there are options to filter
>> the kill ring that users that want that can use.) So I'm closing this
>> bug report.
>
> Indeed:
>
> (setq kill-transform-function (lambda (s) (unless (member s kill-ring) s)))
Sorry, this was wrong. It should delete all previous strings,
and add a new to the top of the kill-ring:
(setq kill-transform-function (lambda (s) (setq kill-ring (delete s kill-ring)) s))
But it would be strange to modify kill-ring in the transform function.
So maybe kill-do-not-save-duplicates should support a special choice
'delete-duplicates' after all.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#52543: Add option to eliminate all duplications from the kill ring
2021-12-19 19:44 ` Juri Linkov
@ 2021-12-20 10:01 ` Lars Ingebrigtsen
0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-20 10:01 UTC (permalink / raw)
To: Juri Linkov; +Cc: ndame, 52543
Juri Linkov <juri@linkov.net> writes:
> But it would be strange to modify kill-ring in the transform function.
> So maybe kill-do-not-save-duplicates should support a special choice
> 'delete-duplicates' after all.
I think some people wouldn't want to remove the duplicates (and add to
the front), and some wouldn't want to add at all (I think that was the
request in the other bug report?), and some want to take text properties
into account, and some don't, so I think leaving this to the user and
the transform function is the right solution. But we don't have to make
any pre-made functions for this.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-12-20 10:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-16 9:49 bug#52543: Add option to eliminate all duplications from the kill ring ndame via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-12-19 12:04 ` Lars Ingebrigtsen
2021-12-19 17:03 ` Juri Linkov
2021-12-19 18:05 ` Juri Linkov
2021-12-19 19:44 ` Juri Linkov
2021-12-20 10:01 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).