Mercurial > emacs
comparison src/keyboard.c @ 93543:ae83caf43667
(Vthis_command_keys_shift_translated): New var.
(command_loop_1): Avoid running the direct display versions of
forward-char and backward-char if shift-selection may occur.
Don't change the value of transient-mark-mode; this is now handled
by handle-shift-selection.
(read_key_sequence): Set Vthis_command_keys_shift_translated if
shift-translation takes place.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 02 Apr 2008 20:14:57 +0000 |
parents | ed10c3092847 |
children | b05c7196d0b6 |
comparison
equal
deleted
inserted
replaced
93542:5dd7fdf8c27e | 93543:ae83caf43667 |
---|---|
130 /* This vector is used as a buffer to record the events that were actually read | 130 /* This vector is used as a buffer to record the events that were actually read |
131 by read_key_sequence. */ | 131 by read_key_sequence. */ |
132 Lisp_Object raw_keybuf; | 132 Lisp_Object raw_keybuf; |
133 int raw_keybuf_count; | 133 int raw_keybuf_count; |
134 | 134 |
135 /* Non-nil if the present key sequence was obtained by shift translation. */ | |
136 Lisp_Object Vthis_command_keys_shift_translated; | |
137 | |
135 #define GROW_RAW_KEYBUF \ | 138 #define GROW_RAW_KEYBUF \ |
136 if (raw_keybuf_count == XVECTOR (raw_keybuf)->size) \ | 139 if (raw_keybuf_count == XVECTOR (raw_keybuf)->size) \ |
137 raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil) \ | 140 raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil) \ |
138 | 141 |
139 /* Number of elements of this_command_keys | 142 /* Number of elements of this_command_keys |
656 static int store_user_signal_events P_ ((void)); | 659 static int store_user_signal_events P_ ((void)); |
657 | 660 |
658 /* Nonzero means don't try to suspend even if the operating system seems | 661 /* Nonzero means don't try to suspend even if the operating system seems |
659 to support it. */ | 662 to support it. */ |
660 static int cannot_suspend; | 663 static int cannot_suspend; |
661 | |
662 extern Lisp_Object Qidentity, Qonly; | |
663 | 664 |
664 /* Install the string STR as the beginning of the string of echoing, | 665 /* Install the string STR as the beginning of the string of echoing, |
665 so that it serves as a prompt for the next character. | 666 so that it serves as a prompt for the next character. |
666 Also start echoing. */ | 667 Also start echoing. */ |
667 | 668 |
1646 before_command_echo_length = echo_length (); | 1647 before_command_echo_length = echo_length (); |
1647 | 1648 |
1648 Vthis_command = Qnil; | 1649 Vthis_command = Qnil; |
1649 real_this_command = Qnil; | 1650 real_this_command = Qnil; |
1650 Vthis_original_command = Qnil; | 1651 Vthis_original_command = Qnil; |
1652 Vthis_command_keys_shift_translated = Qnil; | |
1651 | 1653 |
1652 /* Read next key sequence; i gets its length. */ | 1654 /* Read next key sequence; i gets its length. */ |
1653 i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0], | 1655 i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0], |
1654 Qnil, 0, 1, 1); | 1656 Qnil, 0, 1, 1); |
1655 | 1657 |
1759 /* In case we jump to directly_done. */ | 1761 /* In case we jump to directly_done. */ |
1760 Vcurrent_prefix_arg = current_kboard->Vprefix_arg; | 1762 Vcurrent_prefix_arg = current_kboard->Vprefix_arg; |
1761 | 1763 |
1762 /* Recognize some common commands in common situations and | 1764 /* Recognize some common commands in common situations and |
1763 do them directly. */ | 1765 do them directly. */ |
1764 if (EQ (Vthis_command, Qforward_char) && PT < ZV) | 1766 if (EQ (Vthis_command, Qforward_char) && PT < ZV |
1767 && NILP (Vthis_command_keys_shift_translated) | |
1768 && !CONSP (Vtransient_mark_mode)) | |
1765 { | 1769 { |
1766 struct Lisp_Char_Table *dp | 1770 struct Lisp_Char_Table *dp |
1767 = window_display_table (XWINDOW (selected_window)); | 1771 = window_display_table (XWINDOW (selected_window)); |
1768 lose = FETCH_CHAR (PT_BYTE); | 1772 lose = FETCH_CHAR (PT_BYTE); |
1769 SET_PT (PT + 1); | 1773 SET_PT (PT + 1); |
1799 && NILP (XWINDOW (selected_window)->column_number_displayed) | 1803 && NILP (XWINDOW (selected_window)->column_number_displayed) |
1800 && NILP (Vexecuting_kbd_macro)) | 1804 && NILP (Vexecuting_kbd_macro)) |
1801 direct_output_forward_char (1); | 1805 direct_output_forward_char (1); |
1802 goto directly_done; | 1806 goto directly_done; |
1803 } | 1807 } |
1804 else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV) | 1808 else if (EQ (Vthis_command, Qbackward_char) && PT > BEGV |
1809 && NILP (Vthis_command_keys_shift_translated) | |
1810 && !CONSP (Vtransient_mark_mode)) | |
1805 { | 1811 { |
1806 struct Lisp_Char_Table *dp | 1812 struct Lisp_Char_Table *dp |
1807 = window_display_table (XWINDOW (selected_window)); | 1813 = window_display_table (XWINDOW (selected_window)); |
1808 SET_PT (PT - 1); | 1814 SET_PT (PT - 1); |
1809 lose = FETCH_CHAR (PT_BYTE); | 1815 lose = FETCH_CHAR (PT_BYTE); |
1959 this_single_command_key_start = 0; | 1965 this_single_command_key_start = 0; |
1960 } | 1966 } |
1961 | 1967 |
1962 if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks)) | 1968 if (!NILP (current_buffer->mark_active) && !NILP (Vrun_hooks)) |
1963 { | 1969 { |
1964 /* Setting transient-mark-mode to `only' is a way of | |
1965 turning it on for just one command. */ | |
1966 | |
1967 if (EQ (Vtransient_mark_mode, Qidentity)) | |
1968 Vtransient_mark_mode = Qnil; | |
1969 if (EQ (Vtransient_mark_mode, Qonly)) | |
1970 Vtransient_mark_mode = Qidentity; | |
1971 | |
1972 if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode)) | 1970 if (!NILP (Vdeactivate_mark) && !NILP (Vtransient_mark_mode)) |
1973 { | 1971 { |
1974 /* We could also call `deactivate'mark'. */ | 1972 /* We could also call `deactivate'mark'. */ |
1975 if (EQ (Vtransient_mark_mode, Qlambda)) | 1973 if (EQ (Vtransient_mark_mode, Qlambda)) |
1976 Vtransient_mark_mode = Qnil; | 1974 Vtransient_mark_mode = Qnil; |
9207 volatile keyremap fkey; | 9205 volatile keyremap fkey; |
9208 | 9206 |
9209 /* Likewise, for key_translation_map and input-decode-map. */ | 9207 /* Likewise, for key_translation_map and input-decode-map. */ |
9210 volatile keyremap keytran, indec; | 9208 volatile keyremap keytran, indec; |
9211 | 9209 |
9210 /* Non-zero if we are trying to map a key by changing an upper-case | |
9211 letter to lower case, or a shifted function key to an unshifted | |
9212 one. */ | |
9213 volatile int shift_translated = 0; | |
9214 | |
9212 /* If we receive a `switch-frame' or `select-window' event in the middle of | 9215 /* If we receive a `switch-frame' or `select-window' event in the middle of |
9213 a key sequence, we put it off for later. | 9216 a key sequence, we put it off for later. |
9214 While we're reading, we keep the event here. */ | 9217 While we're reading, we keep the event here. */ |
9215 volatile Lisp_Object delayed_switch_frame; | 9218 volatile Lisp_Object delayed_switch_frame; |
9216 | 9219 |
10125 /* We have to do this unconditionally, regardless of whether | 10128 /* We have to do this unconditionally, regardless of whether |
10126 the lower-case char is defined in the keymaps, because they | 10129 the lower-case char is defined in the keymaps, because they |
10127 might get translated through function-key-map. */ | 10130 might get translated through function-key-map. */ |
10128 keybuf[t - 1] = new_key; | 10131 keybuf[t - 1] = new_key; |
10129 mock_input = max (t, mock_input); | 10132 mock_input = max (t, mock_input); |
10133 shift_translated = 1; | |
10130 | 10134 |
10131 goto replay_sequence; | 10135 goto replay_sequence; |
10132 } | 10136 } |
10133 /* If KEY is not defined in any of the keymaps, | 10137 /* If KEY is not defined in any of the keymaps, |
10134 and cannot be part of a function key or translation, | 10138 and cannot be part of a function key or translation, |
10166 function-key-map on the result, so that S-backspace is | 10170 function-key-map on the result, so that S-backspace is |
10167 correctly mapped to DEL (via backspace). OTOH, | 10171 correctly mapped to DEL (via backspace). OTOH, |
10168 input-decode-map doesn't need to go through it again. */ | 10172 input-decode-map doesn't need to go through it again. */ |
10169 fkey.start = fkey.end = 0; | 10173 fkey.start = fkey.end = 0; |
10170 keytran.start = keytran.end = 0; | 10174 keytran.start = keytran.end = 0; |
10175 shift_translated = 1; | |
10171 | 10176 |
10172 goto replay_sequence; | 10177 goto replay_sequence; |
10173 } | 10178 } |
10174 } | 10179 } |
10175 } | 10180 } |
10184 /* Don't downcase the last character if the caller says don't. | 10189 /* Don't downcase the last character if the caller says don't. |
10185 Don't downcase it if the result is undefined, either. */ | 10190 Don't downcase it if the result is undefined, either. */ |
10186 if ((dont_downcase_last || first_binding >= nmaps) | 10191 if ((dont_downcase_last || first_binding >= nmaps) |
10187 && t > 0 | 10192 && t > 0 |
10188 && t - 1 == original_uppercase_position) | 10193 && t - 1 == original_uppercase_position) |
10189 keybuf[t - 1] = original_uppercase; | 10194 { |
10195 keybuf[t - 1] = original_uppercase; | |
10196 shift_translated = 0; | |
10197 } | |
10198 | |
10199 if (shift_translated) | |
10200 Vthis_command_keys_shift_translated = Qt; | |
10190 | 10201 |
10191 /* Occasionally we fabricate events, perhaps by expanding something | 10202 /* Occasionally we fabricate events, perhaps by expanding something |
10192 according to function-key-map, or by adding a prefix symbol to a | 10203 according to function-key-map, or by adding a prefix symbol to a |
10193 mouse click in the scroll bar or modeline. In this cases, return | 10204 mouse click in the scroll bar or modeline. In this cases, return |
10194 the entire generated key sequence, even if we hit an unbound | 10205 the entire generated key sequence, even if we hit an unbound |
10202 if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) | 10213 if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes)) |
10203 && NILP (Fzerop (Vecho_keystrokes))) | 10214 && NILP (Fzerop (Vecho_keystrokes))) |
10204 echo_char (keybuf[t]); | 10215 echo_char (keybuf[t]); |
10205 add_command_key (keybuf[t]); | 10216 add_command_key (keybuf[t]); |
10206 } | 10217 } |
10207 | |
10208 | |
10209 | 10218 |
10210 UNGCPRO; | 10219 UNGCPRO; |
10211 return t; | 10220 return t; |
10212 } | 10221 } |
10213 | 10222 |
12097 DEFVAR_LISP ("this-command", &Vthis_command, | 12106 DEFVAR_LISP ("this-command", &Vthis_command, |
12098 doc: /* The command now being executed. | 12107 doc: /* The command now being executed. |
12099 The command can set this variable; whatever is put here | 12108 The command can set this variable; whatever is put here |
12100 will be in `last-command' during the following command. */); | 12109 will be in `last-command' during the following command. */); |
12101 Vthis_command = Qnil; | 12110 Vthis_command = Qnil; |
12111 | |
12112 DEFVAR_LISP ("this-command-keys-shift-translated", | |
12113 &Vthis_command_keys_shift_translated, | |
12114 doc: /* Non-nil if the key sequence activating this command was shift-translated. | |
12115 Shift-translation occurs when there is no binding for the key sequence | |
12116 as entered, but a binding was found by changing an upper-case letter | |
12117 to lower-case, or a shifted function key to an unshifted one. */); | |
12118 Vthis_command_keys_shift_translated = Qnil; | |
12102 | 12119 |
12103 DEFVAR_LISP ("this-original-command", &Vthis_original_command, | 12120 DEFVAR_LISP ("this-original-command", &Vthis_original_command, |
12104 doc: /* The command bound to the current key sequence before remapping. | 12121 doc: /* The command bound to the current key sequence before remapping. |
12105 It equals `this-command' if the original command was not remapped through | 12122 It equals `this-command' if the original command was not remapped through |
12106 any of the active keymaps. Otherwise, the value of `this-command' is the | 12123 any of the active keymaps. Otherwise, the value of `this-command' is the |