# HG changeset patch # User Chong Yidong # Date 1281925997 14400 # Node ID acc05fd0631b98790eefddbac9a4d6b32cdc4b0d # Parent f4192807d8a605d2697541c54857fc204938bf21 Let all active regions set the primary selection. This includes both temporarily active regions (mouse drag and shift-select) and those made with C-SPC and cursor motion. * lisp/cus-start.el: Change defcustom for select-active-regions. * lisp/simple.el (deactivate-mark): If select-active-regions is `only', only set selection for temporarily active regions. * src/insdel.c (prepare_to_modify_buffer): Handle `only' value of select-active-regions. * src/keyboard.c (command_loop_1): Avoid setting selection twice, since it's done in deactivate-mark as well. (Vselect_active_regions): Replace `lazy' value with `only', meaning to only set PRIMARY for temporarily active regions. diff -r f4192807d8a6 -r acc05fd0631b etc/NEWS --- a/etc/NEWS Sun Aug 15 22:08:01 2010 -0400 +++ b/etc/NEWS Sun Aug 15 22:33:17 2010 -0400 @@ -191,23 +191,26 @@ ** Selection changes. -The way Emacs interacts with the clipboard and primary selection, by -default, is now similar to other X applications. In particular, kill -and yank use the clipboard, in addition to the primary selection. +The default handling of clipboard and primary selections has been +changed to conform with other X applications. + +*** `select-active-regions' now defaults to t, so active regions set +the primary selection. -*** `select-active-regions' now defaults to `lazy'. -This means that any active region made with shift-selection or mouse -dragging, or acted on by Emacs (e.g. with M-w or C-w), is -automatically added to the primary window selection. +It also accepts a new value, `lazy', which means to only set the +primary selection for temporarily active regions (usually made by +mouse-dragging or shift-selection). + +*** `mouse-2' is now bound to `mouse-yank-primary'. *** `x-select-enable-clipboard' now defaults to t. +Thus, killing and yanking now use the clipboard (in addition to the +kill ring). *** `x-select-enable-primary' now defaults to nil. *** `mouse-drag-copy-region' now defaults to nil. -*** `mouse-2' is now bound to `mouse-yank-primary'. - * Changes in Specialized Modes and Packages in Emacs 24.1 diff -r f4192807d8a6 -r acc05fd0631b lisp/ChangeLog --- a/lisp/ChangeLog Sun Aug 15 22:08:01 2010 -0400 +++ b/lisp/ChangeLog Sun Aug 15 22:33:17 2010 -0400 @@ -1,3 +1,10 @@ +2010-08-16 Chong Yidong + + * simple.el (deactivate-mark): If select-active-regions is `only', + only set selection for temporarily active regions. + + * cus-start.el: Change defcustom for select-active-regions. + 2010-08-15 Chong Yidong * mouse.el (mouse--drag-set-mark-and-point): New function. diff -r f4192807d8a6 -r acc05fd0631b lisp/cus-start.el --- a/lisp/cus-start.el Sun Aug 15 22:08:01 2010 -0400 +++ b/lisp/cus-start.el Sun Aug 15 22:33:17 2010 -0400 @@ -198,8 +198,8 @@ (help-event-list keyboard (repeat (sexp :format "%v"))) (menu-prompting menu boolean) (select-active-regions killing - (choice (const :tag "lazy" lazy) - (const :tag "always" t) + (choice (const :tag "always" t) + (const :tag "only shift-selection or mouse-drag" only) (const :tag "off" nil)) "24.1") (suggest-key-bindings keyboard (choice (const :tag "off" nil) diff -r f4192807d8a6 -r acc05fd0631b lisp/simple.el --- a/lisp/simple.el Sun Aug 15 22:08:01 2010 -0400 +++ b/lisp/simple.el Sun Aug 15 22:33:17 2010 -0400 @@ -3674,7 +3674,9 @@ Mark mode is disabled. This function also runs `deactivate-mark-hook'." (when (or transient-mark-mode force) - (when (and select-active-regions + (when (and (if (eq select-active-regions 'only) + (eq (car-safe transient-mark-mode) 'only) + select-active-regions) (region-active-p) (display-selections-p)) ;; The var `saved-region-selection', if non-nil, is the text in diff -r f4192807d8a6 -r acc05fd0631b src/ChangeLog --- a/src/ChangeLog Sun Aug 15 22:08:01 2010 -0400 +++ b/src/ChangeLog Sun Aug 15 22:33:17 2010 -0400 @@ -1,3 +1,14 @@ +2010-08-16 Chong Yidong + + * keyboard.c (command_loop_1): Avoid setting selection twice, + since it's done in deactivate-mark as well. + (Vselect_active_regions): Change default to t. Replace `lazy' + with non-default value `only', meaning only set PRIMARY for + temporarily active regions. + + * insdel.c (prepare_to_modify_buffer): Handle `only' value of + select-active-regions. + 2010-08-15 Jan Djärv * keyboard.c (parse_tool_bar_item): Put in a bad label if :label diff -r f4192807d8a6 -r acc05fd0631b src/insdel.c --- a/src/insdel.c Sun Aug 15 22:08:01 2010 -0400 +++ b/src/insdel.c Sun Aug 15 22:33:17 2010 -0400 @@ -74,7 +74,7 @@ Lisp_Object Qinhibit_modification_hooks; -extern Lisp_Object Vselect_active_regions, Vsaved_region_selection; +extern Lisp_Object Vselect_active_regions, Vsaved_region_selection, Qonly; /* Check all markers in the current buffer, looking for something invalid. */ @@ -2050,10 +2050,12 @@ #endif /* not CLASH_DETECTION */ /* If `select-active-regions' is non-nil, save the region text. */ - if (!NILP (Vselect_active_regions) - && !NILP (current_buffer->mark_active) - && !NILP (Vtransient_mark_mode) - && NILP (Vsaved_region_selection)) + if (!NILP (current_buffer->mark_active) + && NILP (Vsaved_region_selection) + && (EQ (Vselect_active_regions, Qonly) + ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) + : (!NILP (Vselect_active_regions) + && !NILP (Vtransient_mark_mode)))) { int b = XINT (Fmarker_position (current_buffer->mark)); int e = XINT (make_number (PT)); diff -r f4192807d8a6 -r acc05fd0631b src/keyboard.c --- a/src/keyboard.c Sun Aug 15 22:08:01 2010 -0400 +++ b/src/keyboard.c Sun Aug 15 22:33:17 2010 -0400 @@ -368,7 +368,7 @@ Used by the `select-active-regions' feature. */ Lisp_Object Vsaved_region_selection; -Lisp_Object Qx_set_selection, QPRIMARY, Qlazy; +Lisp_Object Qx_set_selection, QPRIMARY; Lisp_Object Qself_insert_command; Lisp_Object Qforward_char; @@ -1790,27 +1790,34 @@ Vtransient_mark_mode = Qnil; else if (EQ (Vtransient_mark_mode, Qonly)) Vtransient_mark_mode = Qidentity; - else if (EQ (Vselect_active_regions, Qlazy) - ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly) - : (!NILP (Vselect_active_regions) - && !NILP (Vtransient_mark_mode))) - { - /* Set window selection. If `select-active-regions' is - `lazy', only do it for temporarily active regions. */ - int beg = XINT (Fmarker_position (current_buffer->mark)); - int end = XINT (make_number (PT)); - if (beg < end) - call2 (Qx_set_selection, QPRIMARY, - make_buffer_string (beg, end, 0)); - else if (beg > end) - call2 (Qx_set_selection, QPRIMARY, - make_buffer_string (end, beg, 0)); - } if (!NILP (Vdeactivate_mark)) + /* If `select-active-regions' is non-nil, this call to + `deactivate-mark' also sets the PRIMARY selection. */ call0 (Qdeactivate_mark); - else if (current_buffer != prev_buffer || MODIFF != prev_modiff) - call1 (Vrun_hooks, intern ("activate-mark-hook")); + else + { + /* 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)); + if (beg < end) + call2 (Qx_set_selection, QPRIMARY, + make_buffer_string (beg, end, 0)); + else if (beg > end) + call2 (Qx_set_selection, QPRIMARY, + make_buffer_string (end, beg, 0)); + /* Don't set empty selections. */ + } + + if (current_buffer != prev_buffer || MODIFF != prev_modiff) + call1 (Vrun_hooks, intern ("activate-mark-hook")); + } Vsaved_region_selection = Qnil; } @@ -11718,8 +11725,6 @@ staticpro (&Qx_set_selection); QPRIMARY = intern_c_string ("PRIMARY"); staticpro (&QPRIMARY); - Qlazy = intern_c_string ("lazy"); - staticpro (&Qlazy); Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char"); staticpro (&Qinput_method_exit_on_first_char); @@ -12331,16 +12336,11 @@ DEFVAR_LISP ("select-active-regions", &Vselect_active_regions, doc: /* If non-nil, an active region automatically becomes the window selection. -This takes effect only when Transient Mark mode is enabled. - -If the value is `lazy', Emacs only sets the window selection during -`deactivate-mark'; unless the region is temporarily active -(e.g. mouse-drags or shift-selection), in which case it sets the -window selection after each command. - -For other non-nil value, Emacs sets the window selection after every -command. */); - Vselect_active_regions = Qlazy; +If the value is `only', only temporarily active regions (usually made +by mouse-dragging or shift-selection) set the window selection. + +This takes effect only when Transient Mark mode is enabled. */); + Vselect_active_regions = Qt; DEFVAR_LISP ("saved-region-selection", &Vsaved_region_selection,