emacs-devel
[Top][All Lists]
Advanced

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

Re: Yanking wrong text


From: Juri Linkov
Subject: Re: Yanking wrong text
Date: Fri, 29 Jun 2007 19:34:01 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

>     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
>     copy-region-as-kill.
>
> It might work.  Would you like to try implementing that?

This patch should handle this:

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      29 Jun 2007 16:31:31 -0000
***************
*** 91,98 ****
                 ;; 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)
--- 91,105 ----
                 ;; make sure we don't yank the same region
                 ;; that we are going to delete.
                 ;; That would make yank a no-op.
!                (when (and (string= (buffer-substring-no-properties (point) 
(mark))
!                                    (car kill-ring))
!                           ;; Check also whether the head of the kill-ring
!                           ;; really comes from the currently active region,
!                           ;; i.e. check that last-command is one that uses
!                           ;; copy-region-as-kill or kill-new
!                           (memq last-command
!                                 '(mouse-set-region mouse-drag-region
!                                   mouse-save-then-kill 
mouse-secondary-save-then-kill)))
                   (current-kill 1))
                 (delete-active-region))
                ((eq type 'supersede)

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  29 Jun 2007 16:31:41 -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,915 ****
                (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
--- 905,922 ----
                (setq paste-lines (cua--delete-rectangle))
                (if (= paste-lines 1)
                    (setq paste-lines nil))) ;; paste all
!           ;; 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 (and (string= (filter-buffer-substring (point) (mark))
!                             (car kill-ring))
!                    ;; Check also whether the head of the kill-ring
!                    ;; really comes from the currently active region,
!                    ;; i.e. check that last-command is one that uses
!                    ;; copy-region-as-kill or kill-new
!                    (memq last-command
!                          '(mouse-set-region mouse-drag-region
!                            mouse-save-then-kill 
mouse-secondary-save-then-kill)))
                (current-kill 1))
            (cua-delete-region)))
        (cond

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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