GNU bug report logs - #29323
kill-do-not-save-duplicate, FR

Previous Next

Package: emacs;

Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>

Date: Thu, 16 Nov 2017 19:35:02 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29323 in the body.
You can then email your comments to 29323 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Thu, 16 Nov 2017 19:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andreas Röhler <andreas.roehler <at> easy-emacs.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 16 Nov 2017 19:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: bug-gnu-emacs <at> gnu.org
Subject: kill-do-not-save-duplicate, FR
Date: Thu, 16 Nov 2017 20:51:54 +0100
[Message part 1 (text/plain, inline)]
Feature request:

Currently variable kill-do-not-save-duplicates checks only the (car 
kill-ring) as docu explains:

Do not add a new string to ‘kill-ring’ if it duplicates the last one.
The comparison is done using ‘equal-including-properties’.

AFAIU it would be trivial replace this check by a call of "member", thus 
checking the whole kill-ring.

Thanks,

Andreas


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Thu, 16 Nov 2017 22:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 29323 <at> debbugs.gnu.org
Subject: RE: bug#29323: kill-do-not-save-duplicate, FR
Date: Thu, 16 Nov 2017 14:34:56 -0800 (PST)
> Currently variable kill-do-not-save-duplicates checks only the (car kill-ring) as docu explains: 
>
> Do not add a new string to ‘kill-ring’ if it duplicates the last one.
> The comparison is done using ‘equal-including-properties’.
> AFAIU it would be trivial replace this check by a call of "member",
> thus checking > the whole kill-ring.

Why do that?  Why not just prevent duplicates in the first place,
which is what the option currently does?

If you for some reason get duplicate entries somehow, in spite of
using the option to prevent them, you can always remove them.

I don't understand how that would be something that would happen
normally.  What is the problem that this would try to solve/prevent?

---

BTW - it's a pain to remove all of the formatting of your mails
to such lists.  Please consider using plain text, or at a minimum
not using a colored (i.e. non-white) background.  Just a request
or suggestion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Sat, 18 Nov 2017 18:50:01 GMT) Full text and rfc822 format available.

Message #11 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: Drew Adams <drew.adams <at> oracle.com>, 29323 <at> debbugs.gnu.org
Subject: Re: bug#29323: kill-do-not-save-duplicate, FR
Date: Sat, 18 Nov 2017 20:06:54 +0100

On 16.11.2017 23:34, Drew Adams wrote:
>> Currently variable kill-do-not-save-duplicates checks only the (car 
>> kill-ring) as docu explains: Do not add a new string to ‘kill-ring’ 
>> if it duplicates the last one. The comparison is done using 
>> ‘equal-including-properties’. AFAIU it would be trivial replace this 
>> check by a call of "member", thus checking > the whole kill-ring. 
> Why do that? Why not just prevent duplicates in the first place, which 
> is what the option currently does? If you for some reason get 
> duplicate entries somehow, in spite of using the option to prevent 
> them, you can always remove them. I don't understand how that would be 
> something that would happen normally. What is the problem that this 
> would try to solve/prevent? ---


Currently not a check for duplicates is implemented, but for a repeat.

When having alternating strings to copy, they go into the kill-ring one 
after one. That way it ended up having just two strings in the 
kill-ring, and previous content lost.

BTW implementing it would be a way more complicated as thought because 
of text properties.

> BTW - it's a pain to remove all of the formatting of your mails to 
> such lists. 


Hmm, don't you see a formatting when sending.

> Please consider using plain text, or at a minimum not using a colored 
> (i.e. non-white) background.

Switched on "Readers Default Colors", which should help.

> Just a request or suggestion.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Sat, 18 Nov 2017 19:49:01 GMT) Full text and rfc822 format available.

Message #14 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 29323 <at> debbugs.gnu.org
Subject: RE: bug#29323: kill-do-not-save-duplicate, FR
Date: Sat, 18 Nov 2017 11:48:07 -0800 (PST)
> >> Currently variable kill-do-not-save-duplicates checks only the (car
> >> kill-ring) as docu explains: Do not add a new string to ‘kill-ring’
> >> if it duplicates the last one. The comparison is done using
> >> ‘equal-including-properties’. AFAIU it would be trivial replace this
> >> check by a call of "member", thus checking > the whole kill-ring.
> >
> > Why do that? Why not just prevent duplicates in the first place, which
> > is what the option currently does? If you for some reason get
> > duplicate entries somehow, in spite of using the option to prevent
> > them, you can always remove them. I don't understand how that would be
> > something that would happen normally. What is the problem that this
> > would try to solve/prevent? ---
> 
> Currently not a check for duplicates is implemented, but for a repeat.
> 
> When having alternating strings to copy, they go into the kill-ring one
> after one. That way it ended up having just two strings in the
> kill-ring, and previous content lost.

Sorry; my bad.  I don't use that variable.  Clearly you
are right.  The option should perhaps have 3 values: one
to do nothing special, one to not push when the car is
the same, and one to not push when the same is on the
right somewhere.

> BTW implementing it would be a way more complicated as thought because
> of text properties.

Not a big deal, I think.  It just uses predicate
`equal-including-properties', which is coded in C.

But now that this has come up... Perhaps the predicate
to test equality should be the value of a variable, to
give users the ability to control the behavior better.

Or barring that (which I'd prefer), perhaps it could
at least let a user choose whether to distinguish
entries if they are the same other than their properties.

> > BTW - it's a pain to remove all of the formatting of your mails to
> > such lists.
> 
> Hmm, don't you see a formatting when sending.
> 
> > Please consider using plain text, or at a minimum not using a colored
> > (i.e. non-white) background.
> 
> Switched on "Readers Default Colors", which should help.

Whatever you're doing now works, for me at least.  Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Sun, 19 Nov 2017 18:25:01 GMT) Full text and rfc822 format available.

Message #17 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: 29323 <at> debbugs.gnu.org
Subject: Re: bug#29323: kill-do-not-save-duplicate, FR
Date: Sun, 19 Nov 2017 19:42:27 +0100
[Message part 1 (text/plain, inline)]

On 16.11.2017 20:51, Andreas Röhler wrote:
> Feature request:
>
> Currently variable kill-do-not-save-duplicates checks only the (car 
> kill-ring) as docu explains:
>
> Do not add a new string to ‘kill-ring’ if it duplicates the last one.
> The comparison is done using ‘equal-including-properties’.
>
> AFAIU it would be trivial replace this check by a call of "member", 
> thus checking the whole kill-ring.
>
> Thanks,
>
> Andreas
>
>

This variant of kill-new should do it. Diff basically at comment " ;; 
delete string from kill-ring"

(defun ar-kill-new (string &optional replace)
  "Make STRING the latest kill in the kill ring.
Set `kill-ring-yank-pointer' to point to it.
If `interprogram-cut-function' is non-nil, apply it to STRING.
Optional second argument REPLACE non-nil means that STRING will replace
the front of the kill ring, rather than being added to the list.

When `save-interprogram-paste-before-kill' and `interprogram-paste-function'
are non-nil, saves the interprogram paste string(s) into `kill-ring' before
STRING.

When the yank handler has a non-nil PARAM element, the original STRING
argument is not used by `insert-for-yank'.  However, since Lisp code
may access and use elements from the kill ring directly, the STRING
argument should still be a \"useful\" string for such uses."
  (let (newring)
    (unless (and kill-do-not-save-duplicates
                 ;; Due to text properties such as 'yank-handler that
                 ;; can alter the contents to yank, comparison using
                 ;; `equal' is unsafe.
                 (equal-including-properties string (car kill-ring)))
      (if (fboundp 'menu-bar-update-yank-menu)
          (menu-bar-update-yank-menu string (and replace (car 
kill-ring)))))
    (when save-interprogram-paste-before-kill
      (let ((interprogram-paste (and interprogram-paste-function
                                     (funcall 
interprogram-paste-function))))
        (when interprogram-paste
          (dolist (s (if (listp interprogram-paste)
                         (nreverse interprogram-paste)
                       (list interprogram-paste)))
            (unless (and kill-do-not-save-duplicates
                         (equal-including-properties s (car kill-ring)))
              (push s kill-ring))))))
    (if (and kill-do-not-save-duplicates
         (member string kill-ring))
    (progn
      ;; delete string from kill-ring
      (dolist (ele kill-ring)
        (unless (equal-including-properties string ele)
          (push ele newring)))
      ;; push the match at top
      (push string newring)
      (setq kill-ring newring))
      (if (and replace kill-ring)
          (setcar kill-ring string)
        (push string kill-ring)
        (if (> (length kill-ring) kill-ring-max)
            (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))))
    (setq kill-ring-yank-pointer kill-ring)
    (if interprogram-cut-function
        (funcall interprogram-cut-function string))))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Mon, 11 Nov 2019 02:15:01 GMT) Full text and rfc822 format available.

Message #20 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Cc: 29323 <at> debbugs.gnu.org
Subject: Re: bug#29323: kill-do-not-save-duplicate, FR
Date: Mon, 11 Nov 2019 03:14:38 +0100
Andreas Röhler <andreas.roehler <at> easy-emacs.de> writes:

> On 16.11.2017 20:51, Andreas Rvhler wrote:
>
>  Feature request:
>
>  Currently variable kill-do-not-save-duplicates checks only the (car kill-ring) as docu explains: 
>
>  Do not add a new string to kill-ring if it duplicates the last one.
>  The comparison is done using equal-including-properties.
>
>  AFAIU it would be trivial replace this check by a call of "member", thus checking the whole kill-ring.
>
>  Thanks,
>
>  Andreas
>
> This variant of kill-new should do it. Diff basically at comment " ;; delete string from kill-ring" 

I personally can't imagine when I would want the behaviour you ask
for, but I think it could make sense to have it as an optional
behaviour.

Drew suggested that this variable should have three possible values,
where 't' and 'nil' stays as they are, but we introduce a new symbol
which means to have the behaviour you want.  I think this is a better
proposal than changing the existing default.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29323; Package emacs. (Tue, 30 Nov 2021 14:49:01 GMT) Full text and rfc822 format available.

Message #23 received at 29323 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: Andreas Röhler <andreas.roehler <at> easy-emacs.de>,
 29323 <at> debbugs.gnu.org
Subject: Re: bug#29323: kill-do-not-save-duplicate, FR
Date: Tue, 30 Nov 2021 15:48:02 +0100
Stefan Kangas <stefan <at> marxist.se> writes:

> I personally can't imagine when I would want the behaviour you ask
> for, but I think it could make sense to have it as an optional
> behaviour.
>
> Drew suggested that this variable should have three possible values,
> where 't' and 'nil' stays as they are, but we introduce a new symbol
> which means to have the behaviour you want.  I think this is a better
> proposal than changing the existing default.

I don't really see this being generally useful even as an option -- it
makes kill/yank into a completely unpredictable pair of commands, and
that sounds really confusing.

So I think if somebody really wants this, they'll just have to advice
the kill command to remove duplicates (or something like that), but I
don't think we should add such a feature to Emacs, and I'm therefore
closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 30 Nov 2021 14:49:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 29323 <at> debbugs.gnu.org and Andreas Röhler <andreas.roehler <at> easy-emacs.de> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 30 Nov 2021 14:49:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Dec 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.