all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Yanking wrong text
@ 2007-06-22 20:59 Juri Linkov
  2007-06-23  4:28 ` Stefan Monnier
  0 siblings, 1 reply; 16+ messages in thread
From: Juri Linkov @ 2007-06-22 20:59 UTC (permalink / raw)
  To: emacs-devel

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 ----

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-08-21 20:05 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-22 20:59 Yanking wrong text Juri Linkov
2007-06-23  4:28 ` Stefan Monnier
2007-06-23  6:19   ` David Kastrup
2007-06-23  9:45   ` Juri Linkov
2007-06-23 18:26     ` Richard Stallman
2007-06-23 19:00       ` Stefan Monnier
2007-06-23 20:04         ` Juri Linkov
2007-08-21  1:26           ` Chris Moore
2007-08-21 20:05             ` Juri Linkov
2007-06-24 14:40         ` Richard Stallman
2007-06-29 16:34           ` Juri Linkov
2007-06-30 15:09             ` Richard Stallman
2007-07-15 16:50             ` Richard Stallman
2007-07-15 20:00               ` Juri Linkov
2007-07-23 18:06             ` Richard Stallman
2007-07-23 21:31               ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.