[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yanking wrong text

From: Stefan Monnier
Subject: Re: Yanking wrong text
Date: Sat, 23 Jun 2007 15:00:05 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

>       That's because the selected region happens to be the same as the
>     first region added to the top of the kill ring, and due to optimization
>     C-y inserts the second element of the kill ring.

>     You may ask why do I want to replace a region with exactly same text.
>     Usually text is very large, so I don't see that these regions have
>     no differences.  My goal is to copy the region to another place regardless
>     of the fact that it happens to be the same as the selected region to be
>     replaced in another place.

I think he's right.

> This heuristic avoids annoying results in a common case.

IIUC the current code tries to handle the following situation:
- select text "toto" with the mouse to "cut" or "copy" it.
- select text "titi" with the mouse.
- hit C-y to replace "titi" with "toto".
What really happens instead is that "titi" gets replaced with "titi" because
the selection of "titi" with the mouse did an implicit M-w.

But in Juri's case he did not select with the mouse, so "titi" wasn't added
to the kill-ring.  Instead in his case "titi" and "toto" are actually the
same string.

> I wonder if we can tune it to detect that common case
> while not triggering in your case.

I think the key is to check not just whether the two strings are equal, but
also whether the head of the kill-ring really comes from the currently
active region.  E.g. check that last-command is one that uses


reply via email to

[Prev in Thread] Current Thread [Next in Thread]