1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-17 17:58:46 +00:00

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.
This commit is contained in:
Chong Yidong 2010-08-15 22:33:17 -04:00
parent 6d3e82d2d6
commit 7c23dd4468
7 changed files with 72 additions and 47 deletions

View File

@ -191,23 +191,26 @@ should use delete-char with a negative argument instead.
** 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 `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.
*** `select-active-regions' now defaults to t, so active regions set
the primary 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

View File

@ -1,3 +1,10 @@
2010-08-16 Chong Yidong <cyd@stupidchicken.com>
* 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 <cyd@stupidchicken.com>
* mouse.el (mouse--drag-set-mark-and-point): New function.

View File

@ -198,8 +198,8 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
(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)

View File

@ -3674,7 +3674,9 @@ Unless FORCE is non-nil, this function does nothing if Transient
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

View File

@ -1,3 +1,14 @@
2010-08-16 Chong Yidong <cyd@stupidchicken.com>
* 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 <jan.h.d@swipnet.se>
* keyboard.c (parse_tool_bar_item): Put in a bad label if :label

View File

@ -74,7 +74,7 @@ Lisp_Object combine_after_change_buffer;
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 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end,
#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));

View File

@ -368,7 +368,7 @@ Lisp_Object Vselect_active_regions;
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 @@ command_loop_1 (void)
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 @@ syms_of_keyboard (void)
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 @@ and tool-bar buttons. */);
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 `only', only temporarily active regions (usually made
by mouse-dragging or shift-selection) set the window selection.
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;
This takes effect only when Transient Mark mode is enabled. */);
Vselect_active_regions = Qt;
DEFVAR_LISP ("saved-region-selection",
&Vsaved_region_selection,