summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2010-08-15 22:33:17 -0400
committerChong Yidong <cyd@stupidchicken.com>2010-08-15 22:33:17 -0400
commit7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e (patch)
treefc6daa2c1cf95788332e4216b8293dc5616ee73b
parent6d3e82d2d656d7ed27b374f62c320c7d58348248 (diff)
downloademacs-7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e.tar.gz
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.
-rw-r--r--etc/NEWS21
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/cus-start.el4
-rw-r--r--lisp/simple.el4
-rw-r--r--src/ChangeLog11
-rw-r--r--src/insdel.c12
-rw-r--r--src/keyboard.c60
7 files changed, 72 insertions, 47 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 8e2594d8ace..d489e2d32c7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dfe19e994ce..aad818634b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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.
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 10214d39a0d..ec05eb7c9b0 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -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)
diff --git a/lisp/simple.el b/lisp/simple.el
index 0ac199ea2f6..5a2c9e70ad6 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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
diff --git a/src/ChangeLog b/src/ChangeLog
index e7a6d1c3132..e5bb506931d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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
diff --git a/src/insdel.c b/src/insdel.c
index 00025808e37..2ccc0b8eaac 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -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));
diff --git a/src/keyboard.c b/src/keyboard.c
index 570bf360eb5..2fd13c4ae24 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -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 `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.
+If the value is `only', only temporarily active regions (usually made
+by mouse-dragging or shift-selection) set the window selection.
-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,