aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2010-08-15 22:33:17 -0400
committerChong Yidong2010-08-15 22:33:17 -0400
commit7c23dd4468eb42dbe7e3f40339c6fda9f9905d0e (patch)
treefc6daa2c1cf95788332e4216b8293dc5616ee73b /src
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/insdel.c12
-rw-r--r--src/keyboard.c60
3 files changed, 48 insertions, 35 deletions
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,