unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David De La Harpe Golden <david@harpegolden.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Chong Yidong <cyd@stupidchicken.com>, 8996@debbugs.gnu.org
Subject: bug#8996: Set PRIMARY from last selection, not last selected window
Date: Mon, 11 Jul 2011 03:57:13 +0100	[thread overview]
Message-ID: <4E1A6689.1040203@harpegolden.net> (raw)
In-Reply-To: <4E169B83.4050706@harpegolden.net>

[-- Attachment #1: Type: text/plain, Size: 978 bytes --]

On 08/07/11 06:54, David De La Harpe Golden wrote:
> On 05/07/11 04:26, Stefan Monnier wrote:
>
>
>> The window manager is ctwm rather than Metacity, in case it matters.
>>
>
> I can replicate this (not just with ctwm)
>
> The issue I was thinking of is still present too, and is likely
> closely related / really the same thing.

Hmm. bug #6872 was addressed by trunk r101176, which suppresses the 
primary update on handle_switch_frame, but, well, that only covers that 
immediate frame switch case.  Kinda need to address switching between 
individual windows too (or actually instead since handle_switch_frame 
will always wind up calling select_window itself, I think).  However, 
select-window itself is not a command afaiui, and enumerating all 
potential window-switching commands is probably not viable.  I can't say 
I like the attached solution (modelled on the deactivate-mark variable) 
very much, though nor did I have any especially better ideas.

















[-- Attachment #2: select-active-regions_noupdate_on_select_window_r1.diff --]
[-- Type: text/x-patch, Size: 2965 bytes --]

=== modified file 'lisp/simple.el'
--- lisp/simple.el	2011-07-06 19:44:09 +0000
+++ lisp/simple.el	2011-07-11 02:44:14 +0000
@@ -3701,6 +3701,7 @@
     (when (and (if (eq select-active-regions 'only)
 		   (eq (car-safe transient-mark-mode) 'only)
 		 select-active-regions)
+	       (not skip-active-region-selection)
 	       (region-active-p)
 	       (display-selections-p))
       ;; The var `saved-region-selection', if non-nil, is the text in

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2011-07-02 23:40:04 +0000
+++ src/keyboard.c	2011-07-11 02:43:15 +0000
@@ -1337,6 +1337,7 @@
   KVAR (current_kboard, Vprefix_arg) = Qnil;
   KVAR (current_kboard, Vlast_prefix_arg) = Qnil;
   Vdeactivate_mark = Qnil;
+  Vskip_active_region_selection = Qnil;
   waiting_for_input = 0;
   cancel_echoing ();
 
@@ -1388,6 +1389,7 @@
 	display_malloc_warning ();
 
       Vdeactivate_mark = Qnil;
+      Vskip_active_region_selection = Qnil;
 
       /* If minibuffer on and echo area in use,
 	 wait a short time and redraw minibuffer.  */
@@ -1512,6 +1514,7 @@
       /* Process filters and timers may have messed with deactivate-mark.
 	 reset it before we execute the command. */
       Vdeactivate_mark = Qnil;
+      Vskip_active_region_selection = Qnil;
 
       /* Remap command through active keymaps */
       Vthis_original_command = cmd;
@@ -1648,7 +1651,7 @@
 		      ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
 		      : (!NILP (Vselect_active_regions)
 			 && !NILP (Vtransient_mark_mode)))
-		  && !EQ (Vthis_command, Qhandle_switch_frame))
+                  && NILP (Vskip_active_region_selection))
 		{
 		  EMACS_INT beg =
 		    XINT (Fmarker_position (BVAR (current_buffer, mark)));
@@ -12212,6 +12215,16 @@
 `deactivate-mark' call uses this to set the window selection.  */);
   Vsaved_region_selection = Qnil;
 
+  DEFVAR_LISP ("skip-active-region-selection", Vskip_active_region_selection,
+	       doc: /* If an editing command sets this to t, don't update the primary selection.
+The command loop sets this to nil before each command,
+and tests the value when the command returns. Certain atypical commands
+(e.g. window and frame switching) may change the current active region,
+yet it is incorrect to update the system selection from that active
+region at that time, as would normally be done if select-active-regions
+is non-nil */);
+  Vskip_active_region_selection = Qnil;
+
   DEFVAR_LISP ("debug-on-event",
                Vdebug_on_event,
                doc: /* Enter debugger on this event.  When Emacs

=== modified file 'src/window.c'
--- src/window.c	2011-07-02 10:36:48 +0000
+++ src/window.c	2011-07-11 02:23:31 +0000
@@ -339,6 +339,9 @@
   if (EQ (window, selected_window) && !inhibit_point_swap)
     return window;
 
+  /* frame/window switches are not grounds to update the primary selection */
+  Vskip_active_region_selection = Qt;
+
   sf = SELECTED_FRAME ();
   if (XFRAME (WINDOW_FRAME (w)) != sf)
     {


  reply	other threads:[~2011-07-11  2:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04 17:19 bug#8996: Set PRIMARY from last selection, not last selected window Stefan Monnier
2011-07-04 19:11 ` David De La Harpe Golden
2011-07-04 20:27   ` Chong Yidong
2011-07-05  3:26     ` Stefan Monnier
2011-07-05 10:11       ` David De La Harpe Golden
2011-07-08  5:54       ` David De La Harpe Golden
2011-07-11  2:57         ` David De La Harpe Golden [this message]
2012-03-13 13:23           ` Stefan Monnier
2012-03-18 19:18             ` David De La Harpe Golden
2012-03-24 11:10             ` Chong Yidong
2012-03-25  3:32               ` David De La Harpe Golden
2012-03-25  3:42                 ` Chong Yidong
2012-03-25 13:42                   ` David De La Harpe Golden
2012-03-25 14:20                 ` David De La Harpe Golden
2012-03-26  4:06                   ` Chong Yidong
2012-03-27  0:16                     ` David De La Harpe Golden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E1A6689.1040203@harpegolden.net \
    --to=david@harpegolden.net \
    --cc=8996@debbugs.gnu.org \
    --cc=cyd@stupidchicken.com \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).