emacs-devel
[Top][All Lists]
Advanced

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

Yanking wrong text


From: Juri Linkov
Subject: Yanking wrong text
Date: Fri, 22 Jun 2007 23:59:14 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

I propose removing annoying behavior of yanking text.

Steps to reproduce: with delete-selection-mode or cua-selection-mode
I copy some region into the kill ring (`M-w').  After that I select
another region, and type `C-y' to replace the selected region,
but instead of inserting the copied region from the kill ring,
it inserts some completely unrelated text.  Then I need to undo this
action and start looking why does it insert wrong text.  When I start
trying to copy this region again, I realize that the reason of this
behavior is an "evil" optimization: if the text to replace is the same
as the text on the top of the kill ring, then it inserts the text from the
second element of the kill ring.

The comment in the implementation says that this was done because
otherwise yank would be a no-op.  So what?  I still need to insert
the last copied region even if it happens to be the same as the selected
region, and not insert some arbitrary text from the rest of the kill ring.

Index: lisp/delsel.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/delsel.el,v
retrieving revision 1.38
diff -c -r1.38 delsel.el
*** lisp/delsel.el      21 Jan 2007 03:53:12 -0000      1.38
--- lisp/delsel.el      22 Jun 2007 20:59:00 -0000
***************
*** 87,99 ****
          (cond ((eq type 'kill)
                 (delete-active-region t))
                ((eq type 'yank)
-                ;; Before a yank command,
-                ;; make sure we don't yank the same region
-                ;; that we are going to delete.
-                ;; That would make yank a no-op.
-                (when (string= (buffer-substring-no-properties (point) (mark))
-                               (car kill-ring))
-                  (current-kill 1))
                 (delete-active-region))
                ((eq type 'supersede)
                 (let ((empty-region (= (point) (mark))))
--- 87,92 ----

Index: lisp/emulation/cua-base.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emulation/cua-base.el,v
retrieving revision 1.78
diff -c -r1.78 cua-base.el
*** lisp/emulation/cua-base.el  24 Feb 2007 21:52:43 -0000      1.78
--- lisp/emulation/cua-base.el  22 Jun 2007 20:59:10 -0000
***************
*** 898,906 ****
       (t
        ;; Must save register here, since delete may override reg 0.
        (if mark-active
-         ;; Before a yank command, make sure we don't yank
-         ;; the same region that we are going to delete.
-         ;; That would make yank a no-op.
          (if cua--rectangle
              (progn
                (goto-char (min (mark) (point)))
--- 898,903 ----
***************
*** 908,916 ****
                (setq paste-lines (cua--delete-rectangle))
                (if (= paste-lines 1)
                    (setq paste-lines nil))) ;; paste all
-           (if (string= (filter-buffer-substring (point) (mark))
-                        (car kill-ring))
-               (current-kill 1))
            (cua-delete-region)))
        (cond
         (regtxt
--- 905,910 ----




reply via email to

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