aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-08-15 22:33:17 -0400
committerChong Yidong2010-08-15 22:33:17 -0400
commit7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e (patch)
treefc6daa2c1cf95788332e4216b8293dc5616ee73b
parent6d3e82d2d656d7ed27b374f62c320c7d58348248 (diff)
downloademacs-7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e.tar.gz
emacs-7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e.zip
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.
191 191
192** Selection changes. 192** Selection changes.
193 193
194The way Emacs interacts with the clipboard and primary selection, by 194The default handling of clipboard and primary selections has been
195default, is now similar to other X applications. In particular, kill 195changed to conform with other X applications.
196and yank use the clipboard, in addition to the primary selection.
197 196
198*** `select-active-regions' now defaults to `lazy'. 197*** `select-active-regions' now defaults to t, so active regions set
199This means that any active region made with shift-selection or mouse 198the primary selection.
200dragging, or acted on by Emacs (e.g. with M-w or C-w), is 199
201automatically added to the primary window selection. 200It also accepts a new value, `lazy', which means to only set the
201primary selection for temporarily active regions (usually made by
202mouse-dragging or shift-selection).
203
204*** `mouse-2' is now bound to `mouse-yank-primary'.
202 205
203*** `x-select-enable-clipboard' now defaults to t. 206*** `x-select-enable-clipboard' now defaults to t.
207Thus, killing and yanking now use the clipboard (in addition to the
208kill ring).
204 209
205*** `x-select-enable-primary' now defaults to nil. 210*** `x-select-enable-primary' now defaults to nil.
206 211
207*** `mouse-drag-copy-region' now defaults to nil. 212*** `mouse-drag-copy-region' now defaults to nil.
208 213
209*** `mouse-2' is now bound to `mouse-yank-primary'.
210
211 214
212* Changes in Specialized Modes and Packages in Emacs 24.1 215* Changes in Specialized Modes and Packages in Emacs 24.1
213 216
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dfe19e994ce..aad818634b9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12010-08-16 Chong Yidong <cyd@stupidchicken.com>
2
3 * simple.el (deactivate-mark): If select-active-regions is `only',
4 only set selection for temporarily active regions.
5
6 * cus-start.el: Change defcustom for select-active-regions.
7
12010-08-15 Chong Yidong <cyd@stupidchicken.com> 82010-08-15 Chong Yidong <cyd@stupidchicken.com>
2 9
3 * mouse.el (mouse--drag-set-mark-and-point): New function. 10 * 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
198 (help-event-list keyboard (repeat (sexp :format "%v"))) 198 (help-event-list keyboard (repeat (sexp :format "%v")))
199 (menu-prompting menu boolean) 199 (menu-prompting menu boolean)
200 (select-active-regions killing 200 (select-active-regions killing
201 (choice (const :tag "lazy" lazy) 201 (choice (const :tag "always" t)
202 (const :tag "always" t) 202 (const :tag "only shift-selection or mouse-drag" only)
203 (const :tag "off" nil)) 203 (const :tag "off" nil))
204 "24.1") 204 "24.1")
205 (suggest-key-bindings keyboard (choice (const :tag "off" nil) 205 (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
3674Mark mode is disabled. 3674Mark mode is disabled.
3675This function also runs `deactivate-mark-hook'." 3675This function also runs `deactivate-mark-hook'."
3676 (when (or transient-mark-mode force) 3676 (when (or transient-mark-mode force)
3677 (when (and select-active-regions 3677 (when (and (if (eq select-active-regions 'only)
3678 (eq (car-safe transient-mark-mode) 'only)
3679 select-active-regions)
3678 (region-active-p) 3680 (region-active-p)
3679 (display-selections-p)) 3681 (display-selections-p))
3680 ;; The var `saved-region-selection', if non-nil, is the text in 3682 ;; 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 @@
12010-08-16 Chong Yidong <cyd@stupidchicken.com>
2
3 * keyboard.c (command_loop_1): Avoid setting selection twice,
4 since it's done in deactivate-mark as well.
5 (Vselect_active_regions): Change default to t. Replace `lazy'
6 with non-default value `only', meaning only set PRIMARY for
7 temporarily active regions.
8
9 * insdel.c (prepare_to_modify_buffer): Handle `only' value of
10 select-active-regions.
11
12010-08-15 Jan Djärv <jan.h.d@swipnet.se> 122010-08-15 Jan Djärv <jan.h.d@swipnet.se>
2 13
3 * keyboard.c (parse_tool_bar_item): Put in a bad label if :label 14 * 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;
74 74
75Lisp_Object Qinhibit_modification_hooks; 75Lisp_Object Qinhibit_modification_hooks;
76 76
77extern Lisp_Object Vselect_active_regions, Vsaved_region_selection; 77extern Lisp_Object Vselect_active_regions, Vsaved_region_selection, Qonly;
78 78
79 79
80/* Check all markers in the current buffer, looking for something invalid. */ 80/* 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,
2050#endif /* not CLASH_DETECTION */ 2050#endif /* not CLASH_DETECTION */
2051 2051
2052 /* If `select-active-regions' is non-nil, save the region text. */ 2052 /* If `select-active-regions' is non-nil, save the region text. */
2053 if (!NILP (Vselect_active_regions) 2053 if (!NILP (current_buffer->mark_active)
2054 && !NILP (current_buffer->mark_active) 2054 && NILP (Vsaved_region_selection)
2055 && !NILP (Vtransient_mark_mode) 2055 && (EQ (Vselect_active_regions, Qonly)
2056 && NILP (Vsaved_region_selection)) 2056 ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
2057 : (!NILP (Vselect_active_regions)
2058 && !NILP (Vtransient_mark_mode))))
2057 { 2059 {
2058 int b = XINT (Fmarker_position (current_buffer->mark)); 2060 int b = XINT (Fmarker_position (current_buffer->mark));
2059 int e = XINT (make_number (PT)); 2061 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;
368 Used by the `select-active-regions' feature. */ 368 Used by the `select-active-regions' feature. */
369Lisp_Object Vsaved_region_selection; 369Lisp_Object Vsaved_region_selection;
370 370
371Lisp_Object Qx_set_selection, QPRIMARY, Qlazy; 371Lisp_Object Qx_set_selection, QPRIMARY;
372 372
373Lisp_Object Qself_insert_command; 373Lisp_Object Qself_insert_command;
374Lisp_Object Qforward_char; 374Lisp_Object Qforward_char;
@@ -1790,27 +1790,34 @@ command_loop_1 (void)
1790 Vtransient_mark_mode = Qnil; 1790 Vtransient_mark_mode = Qnil;
1791 else if (EQ (Vtransient_mark_mode, Qonly)) 1791 else if (EQ (Vtransient_mark_mode, Qonly))
1792 Vtransient_mark_mode = Qidentity; 1792 Vtransient_mark_mode = Qidentity;
1793 else if (EQ (Vselect_active_regions, Qlazy)
1794 ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
1795 : (!NILP (Vselect_active_regions)
1796 && !NILP (Vtransient_mark_mode)))
1797 {
1798 /* Set window selection. If `select-active-regions' is
1799 `lazy', only do it for temporarily active regions. */
1800 int beg = XINT (Fmarker_position (current_buffer->mark));
1801 int end = XINT (make_number (PT));
1802 if (beg < end)
1803 call2 (Qx_set_selection, QPRIMARY,
1804 make_buffer_string (beg, end, 0));
1805 else if (beg > end)
1806 call2 (Qx_set_selection, QPRIMARY,
1807 make_buffer_string (end, beg, 0));
1808 }
1809 1793
1810 if (!NILP (Vdeactivate_mark)) 1794 if (!NILP (Vdeactivate_mark))
1795 /* If `select-active-regions' is non-nil, this call to
1796 `deactivate-mark' also sets the PRIMARY selection. */
1811 call0 (Qdeactivate_mark); 1797 call0 (Qdeactivate_mark);
1812 else if (current_buffer != prev_buffer || MODIFF != prev_modiff) 1798 else
1813 call1 (Vrun_hooks, intern ("activate-mark-hook")); 1799 {
1800 /* Even if not deactivating the mark, set PRIMARY if
1801 `select-active-regions' is non-nil. */
1802 if (EQ (Vselect_active_regions, Qonly)
1803 ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
1804 : (!NILP (Vselect_active_regions)
1805 && !NILP (Vtransient_mark_mode)))
1806 {
1807 int beg = XINT (Fmarker_position (current_buffer->mark));
1808 int end = XINT (make_number (PT));
1809 if (beg < end)
1810 call2 (Qx_set_selection, QPRIMARY,
1811 make_buffer_string (beg, end, 0));
1812 else if (beg > end)
1813 call2 (Qx_set_selection, QPRIMARY,
1814 make_buffer_string (end, beg, 0));
1815 /* Don't set empty selections. */
1816 }
1817
1818 if (current_buffer != prev_buffer || MODIFF != prev_modiff)
1819 call1 (Vrun_hooks, intern ("activate-mark-hook"));
1820 }
1814 1821
1815 Vsaved_region_selection = Qnil; 1822 Vsaved_region_selection = Qnil;
1816 } 1823 }
@@ -11718,8 +11725,6 @@ syms_of_keyboard (void)
11718 staticpro (&Qx_set_selection); 11725 staticpro (&Qx_set_selection);
11719 QPRIMARY = intern_c_string ("PRIMARY"); 11726 QPRIMARY = intern_c_string ("PRIMARY");
11720 staticpro (&QPRIMARY); 11727 staticpro (&QPRIMARY);
11721 Qlazy = intern_c_string ("lazy");
11722 staticpro (&Qlazy);
11723 11728
11724 Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char"); 11729 Qinput_method_exit_on_first_char = intern_c_string ("input-method-exit-on-first-char");
11725 staticpro (&Qinput_method_exit_on_first_char); 11730 staticpro (&Qinput_method_exit_on_first_char);
@@ -12331,16 +12336,11 @@ and tool-bar buttons. */);
12331 DEFVAR_LISP ("select-active-regions", 12336 DEFVAR_LISP ("select-active-regions",
12332 &Vselect_active_regions, 12337 &Vselect_active_regions,
12333 doc: /* If non-nil, an active region automatically becomes the window selection. 12338 doc: /* If non-nil, an active region automatically becomes the window selection.
12334This takes effect only when Transient Mark mode is enabled. 12339If the value is `only', only temporarily active regions (usually made
12335 12340by mouse-dragging or shift-selection) set the window selection.
12336If the value is `lazy', Emacs only sets the window selection during
12337`deactivate-mark'; unless the region is temporarily active
12338(e.g. mouse-drags or shift-selection), in which case it sets the
12339window selection after each command.
12340 12341
12341For other non-nil value, Emacs sets the window selection after every 12342This takes effect only when Transient Mark mode is enabled. */);
12342command. */); 12343 Vselect_active_regions = Qt;
12343 Vselect_active_regions = Qlazy;
12344 12344
12345 DEFVAR_LISP ("saved-region-selection", 12345 DEFVAR_LISP ("saved-region-selection",
12346 &Vsaved_region_selection, 12346 &Vsaved_region_selection,