Subject: Re: bug#6872: 24.0.50; Mouse-2 pastes the wrong text.

From: Chong Yidong <[email-masked]>
Date: Sun, 22 Aug 2010 19:27:13 -0400

Jan Djärv <[email-masked]> writes:

> In the first frame, go to *scratch* if not alread there.
> C-x 5 2.  In the new frame C-x b tmp
> Select the text "This buffer is for notes".
> Move mouse to the other frame and press mouse-2.  The text is inserted
> as it should.
> Double click on "buffer" (in the line that was just inserted) to select
> it.
> Go back to the frame with *scratch* and press mouse-2.  The selected
> word "buffer" is not inserted, but the old selection "This buffer is for
> notes".

Could you help test this patch?

*** lisp/mouse.el	2010-08-21 04:46:23 +0000
--- lisp/mouse.el	2010-08-22 23:25:55 +0000
***************
*** 1271,1277 ****
    (when select-active-regions
      ;; Without this, confusing things happen upon e.g. inserting into
      ;; the middle of an active region.
!     (deactivate-mark))
    (or mouse-yank-at-point (mouse-set-point click))
    (let ((primary
  	 (cond
--- 1271,1278 ----
    (when select-active-regions
      ;; Without this, confusing things happen upon e.g. inserting into
      ;; the middle of an active region.
!     (let ((select-active-regions nil))
!       (deactivate-mark)))
    (or mouse-yank-at-point (mouse-set-point click))
    (let ((primary
  	 (cond

=== modified file 'src/keyboard.c'
*** src/keyboard.c	2010-08-22 15:14:37 +0000
--- src/keyboard.c	2010-08-22 23:22:34 +0000
***************
*** 368,374 ****
     Used by the `select-active-regions' feature.  */
  Lisp_Object Vsaved_region_selection;
  
! Lisp_Object Qx_set_selection, QPRIMARY;
  
  Lisp_Object Qself_insert_command;
  Lisp_Object Qforward_char;
--- 368,374 ----
     Used by the `select-active-regions' feature.  */
  Lisp_Object Vsaved_region_selection;
  
! Lisp_Object Qx_set_selection, QPRIMARY, Qhandle_switch_frame;
  
  Lisp_Object Qself_insert_command;
  Lisp_Object Qforward_char;
***************
*** 1799,1808 ****
  	    {
  	      /* Even if not deactivating the mark, set PRIMARY if
  		 `select-active-regions' is non-nil.  */
! 	      if (EQ (Vselect_active_regions, Qonly)
! 		  ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
! 		  : (!NILP (Vselect_active_regions)
! 		     && !NILP (Vtransient_mark_mode)))
  		{
  		  int beg = XINT (Fmarker_position (current_buffer->mark));
  		  int end = XINT (make_number (PT));
--- 1799,1809 ----
  	    {
  	      /* Even if not deactivating the mark, set PRIMARY if
  		 `select-active-regions' is non-nil.  */
! 	      if ((EQ (Vselect_active_regions, Qonly)
! 		   ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
! 		   : (!NILP (Vselect_active_regions)
! 		      && !NILP (Vtransient_mark_mode)))
! 		  && !EQ (Vthis_command, Qhandle_switch_frame))
  		{
  		  int beg = XINT (Fmarker_position (current_buffer->mark));
  		  int end = XINT (make_number (PT));
***************
*** 11725,11730 ****
--- 11726,11733 ----
    staticpro (&Qx_set_selection);
    QPRIMARY = intern_c_string ("PRIMARY");
    staticpro (&QPRIMARY);
+   Qhandle_switch_frame = intern_c_string ("handle-switch-frame");
+   staticpro (&Qhandle_switch_frame);
  
    Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
    staticpro (&Qinput_method_exit_on_first_char);