diff options
| author | Richard M. Stallman | 1998-07-26 23:03:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-07-26 23:03:58 +0000 |
| commit | 7d18f9ae9903e59a2f5fab14efc978f8553b3486 (patch) | |
| tree | 9a2a8aa8b871316667401fe9101d59a1a22a795b /src | |
| parent | 79de6799c965595086a2c720aaf1c28057b9b762 (diff) | |
| download | emacs-7d18f9ae9903e59a2f5fab14efc978f8553b3486.tar.gz emacs-7d18f9ae9903e59a2f5fab14efc978f8553b3486.zip | |
(Qinput_method_function): New variable.
(syms_of_keyboard): Init and staticpro it.
(read_key_sequence): Bind input-method-function,
and set it to nil after reading the first event.
(raw_keybuf, raw_keybuf_count): New variables, to record
raw input events as they are read with read_char.
(GROW_RAW_KEYBUF): New macro.
(Fthis_single_command_raw_keys): New function.
(syms_of_keyboard): defsubr it.
(read_char): Call the input method if appropriate.
Change logic for distinguishing rereads from new events;
use local var `reread'. Take events from
Vunread_input_method_events and Vunread_post_input_method_events.
(Vunread_input_method_events, Vunread_post_input_method_events)
(Vinput_method_function): New variable.
(syms_of_keyboard): Set up Lisp vars.
(command_loop_1): Check Vunread_input_method_events and
Vunread_post_input_method_events along with Vunread_command_events.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 244 |
1 files changed, 200 insertions, 44 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 0df3f09cd86..e5d0a8946e7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -128,6 +128,22 @@ Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */ | |||
| 128 | Lisp_Object this_command_keys; | 128 | Lisp_Object this_command_keys; |
| 129 | int this_command_key_count; | 129 | int this_command_key_count; |
| 130 | 130 | ||
| 131 | /* This vector is used as a buffer to record the events that were actually read | ||
| 132 | by read_key_sequence. */ | ||
| 133 | Lisp_Object raw_keybuf; | ||
| 134 | int raw_keybuf_count; | ||
| 135 | |||
| 136 | #define GROW_RAW_KEYBUF \ | ||
| 137 | if (raw_keybuf_count == XVECTOR (raw_keybuf)->size) \ | ||
| 138 | { \ | ||
| 139 | int newsize = 2 * XVECTOR (raw_keybuf)->size; \ | ||
| 140 | Lisp_Object new; \ | ||
| 141 | new = Fmake_vector (make_number (newsize), Qnil); \ | ||
| 142 | bcopy (XVECTOR (raw_keybuf)->contents, XVECTOR (new)->contents, \ | ||
| 143 | raw_keybuf_count * sizeof (Lisp_Object)); \ | ||
| 144 | raw_keybuf = new; \ | ||
| 145 | } | ||
| 146 | |||
| 131 | /* Number of elements of this_command_keys | 147 | /* Number of elements of this_command_keys |
| 132 | that precede this key sequence. */ | 148 | that precede this key sequence. */ |
| 133 | int this_single_command_key_start; | 149 | int this_single_command_key_start; |
| @@ -249,6 +265,14 @@ Lisp_Object last_input_char; | |||
| 249 | /* If not Qnil, a list of objects to be read as subsequent command input. */ | 265 | /* If not Qnil, a list of objects to be read as subsequent command input. */ |
| 250 | Lisp_Object Vunread_command_events; | 266 | Lisp_Object Vunread_command_events; |
| 251 | 267 | ||
| 268 | /* If not Qnil, a list of objects to be read as subsequent command input | ||
| 269 | including input method processing. */ | ||
| 270 | Lisp_Object Vunread_input_method_events; | ||
| 271 | |||
| 272 | /* If not Qnil, a list of objects to be read as subsequent command input | ||
| 273 | but NOT including input method processing. */ | ||
| 274 | Lisp_Object Vunread_post_input_method_events; | ||
| 275 | |||
| 252 | /* If not -1, an event to be read as subsequent command input. */ | 276 | /* If not -1, an event to be read as subsequent command input. */ |
| 253 | int unread_command_char; | 277 | int unread_command_char; |
| 254 | 278 | ||
| @@ -340,6 +364,10 @@ extern Lisp_Object Vfunction_key_map; | |||
| 340 | This one takes precedence over ordinary definitions. */ | 364 | This one takes precedence over ordinary definitions. */ |
| 341 | extern Lisp_Object Vkey_translation_map; | 365 | extern Lisp_Object Vkey_translation_map; |
| 342 | 366 | ||
| 367 | /* If non-nil, this implements the current input method. */ | ||
| 368 | Lisp_Object Vinput_method_function; | ||
| 369 | Lisp_Object Qinput_method_function; | ||
| 370 | |||
| 343 | /* Non-nil means deactivate the mark at end of this command. */ | 371 | /* Non-nil means deactivate the mark at end of this command. */ |
| 344 | Lisp_Object Vdeactivate_mark; | 372 | Lisp_Object Vdeactivate_mark; |
| 345 | 373 | ||
| @@ -1149,6 +1177,8 @@ command_loop_1 () | |||
| 1149 | if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) | 1177 | if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) |
| 1150 | { | 1178 | { |
| 1151 | if (NILP (Vunread_command_events) | 1179 | if (NILP (Vunread_command_events) |
| 1180 | && NILP (Vunread_input_method_events) | ||
| 1181 | && NILP (Vunread_post_input_method_events) | ||
| 1152 | && NILP (Vexecuting_macro) | 1182 | && NILP (Vexecuting_macro) |
| 1153 | && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) | 1183 | && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) |
| 1154 | safe_run_hooks (Qpost_command_idle_hook); | 1184 | safe_run_hooks (Qpost_command_idle_hook); |
| @@ -1466,6 +1496,8 @@ command_loop_1 () | |||
| 1466 | if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) | 1496 | if (!NILP (Vpost_command_idle_hook) && !NILP (Vrun_hooks)) |
| 1467 | { | 1497 | { |
| 1468 | if (NILP (Vunread_command_events) | 1498 | if (NILP (Vunread_command_events) |
| 1499 | && NILP (Vunread_input_method_events) | ||
| 1500 | && NILP (Vunread_post_input_method_events) | ||
| 1469 | && NILP (Vexecuting_macro) | 1501 | && NILP (Vexecuting_macro) |
| 1470 | && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) | 1502 | && !NILP (sit_for (0, post_command_idle_delay, 0, 1, 1))) |
| 1471 | safe_run_hooks (Qpost_command_idle_hook); | 1503 | safe_run_hooks (Qpost_command_idle_hook); |
| @@ -1757,6 +1789,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1757 | int key_already_recorded = 0; | 1789 | int key_already_recorded = 0; |
| 1758 | Lisp_Object tem, save; | 1790 | Lisp_Object tem, save; |
| 1759 | Lisp_Object also_record; | 1791 | Lisp_Object also_record; |
| 1792 | int reread; | ||
| 1760 | struct gcpro gcpro1; | 1793 | struct gcpro gcpro1; |
| 1761 | 1794 | ||
| 1762 | also_record = Qnil; | 1795 | also_record = Qnil; |
| @@ -1769,10 +1802,12 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1769 | 1802 | ||
| 1770 | retry: | 1803 | retry: |
| 1771 | 1804 | ||
| 1772 | if (CONSP (Vunread_command_events)) | 1805 | reread = 0; |
| 1806 | if (CONSP (Vunread_post_input_method_events)) | ||
| 1773 | { | 1807 | { |
| 1774 | c = XCONS (Vunread_command_events)->car; | 1808 | c = XCONS (Vunread_post_input_method_events)->car; |
| 1775 | Vunread_command_events = XCONS (Vunread_command_events)->cdr; | 1809 | Vunread_post_input_method_events |
| 1810 | = XCONS (Vunread_post_input_method_events)->cdr; | ||
| 1776 | 1811 | ||
| 1777 | /* Undo what read_char_x_menu_prompt did when it unread | 1812 | /* Undo what read_char_x_menu_prompt did when it unread |
| 1778 | additional keys returned by Fx_popup_menu. */ | 1813 | additional keys returned by Fx_popup_menu. */ |
| @@ -1781,10 +1816,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1781 | && NILP (XCONS (c)->cdr)) | 1816 | && NILP (XCONS (c)->cdr)) |
| 1782 | c = XCONS (c)->car; | 1817 | c = XCONS (c)->car; |
| 1783 | 1818 | ||
| 1784 | if (this_command_key_count == 0) | 1819 | reread = 1; |
| 1785 | goto reread_first; | 1820 | goto reread_first; |
| 1786 | else | ||
| 1787 | goto reread; | ||
| 1788 | } | 1821 | } |
| 1789 | 1822 | ||
| 1790 | if (unread_command_char != -1) | 1823 | if (unread_command_char != -1) |
| @@ -1792,10 +1825,39 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1792 | XSETINT (c, unread_command_char); | 1825 | XSETINT (c, unread_command_char); |
| 1793 | unread_command_char = -1; | 1826 | unread_command_char = -1; |
| 1794 | 1827 | ||
| 1795 | if (this_command_key_count == 0) | 1828 | reread = 1; |
| 1796 | goto reread_first; | 1829 | goto reread_first; |
| 1797 | else | 1830 | } |
| 1798 | goto reread; | 1831 | |
| 1832 | if (CONSP (Vunread_command_events)) | ||
| 1833 | { | ||
| 1834 | c = XCONS (Vunread_command_events)->car; | ||
| 1835 | Vunread_command_events = XCONS (Vunread_command_events)->cdr; | ||
| 1836 | |||
| 1837 | /* Undo what read_char_x_menu_prompt did when it unread | ||
| 1838 | additional keys returned by Fx_popup_menu. */ | ||
| 1839 | if (CONSP (c) | ||
| 1840 | && (SYMBOLP (XCONS (c)->car) || INTEGERP (XCONS (c)->car)) | ||
| 1841 | && NILP (XCONS (c)->cdr)) | ||
| 1842 | c = XCONS (c)->car; | ||
| 1843 | |||
| 1844 | reread = 1; | ||
| 1845 | goto reread_for_input_method; | ||
| 1846 | } | ||
| 1847 | |||
| 1848 | if (CONSP (Vunread_input_method_events)) | ||
| 1849 | { | ||
| 1850 | c = XCONS (Vunread_input_method_events)->car; | ||
| 1851 | Vunread_input_method_events = XCONS (Vunread_input_method_events)->cdr; | ||
| 1852 | |||
| 1853 | /* Undo what read_char_x_menu_prompt did when it unread | ||
| 1854 | additional keys returned by Fx_popup_menu. */ | ||
| 1855 | if (CONSP (c) | ||
| 1856 | && (SYMBOLP (XCONS (c)->car) || INTEGERP (XCONS (c)->car)) | ||
| 1857 | && NILP (XCONS (c)->cdr)) | ||
| 1858 | c = XCONS (c)->car; | ||
| 1859 | reread = 1; | ||
| 1860 | goto reread_for_input_method; | ||
| 1799 | } | 1861 | } |
| 1800 | 1862 | ||
| 1801 | /* If there is no function key translated before | 1863 | /* If there is no function key translated before |
| @@ -1842,7 +1904,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 1842 | unread_switch_frame = Qnil; | 1904 | unread_switch_frame = Qnil; |
| 1843 | 1905 | ||
| 1844 | /* This event should make it into this_command_keys, and get echoed | 1906 | /* This event should make it into this_command_keys, and get echoed |
| 1845 | again, so we go to reread_first, rather than reread. */ | 1907 | again, so we do not set `reread'. */ |
| 1846 | goto reread_first; | 1908 | goto reread_first; |
| 1847 | } | 1909 | } |
| 1848 | 1910 | ||
| @@ -2263,36 +2325,61 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2263 | } | 2325 | } |
| 2264 | } | 2326 | } |
| 2265 | 2327 | ||
| 2328 | /* Store these characters into recent_keys, the dribble file if any, | ||
| 2329 | and the keyboard macro being defined, if any. */ | ||
| 2266 | record_char (c); | 2330 | record_char (c); |
| 2267 | if (! NILP (also_record)) | 2331 | if (! NILP (also_record)) |
| 2268 | record_char (also_record); | 2332 | record_char (also_record); |
| 2269 | 2333 | ||
| 2334 | reread_for_input_method: | ||
| 2270 | from_macro: | 2335 | from_macro: |
| 2271 | reread_first: | 2336 | /* Pass this to the input method, if appropriate. */ |
| 2337 | if (INTEGERP (c)) | ||
| 2338 | { | ||
| 2339 | /* If this is a printing character, run the input method. */ | ||
| 2340 | if (! NILP (Vinput_method_function) | ||
| 2341 | && (unsigned) XINT (c) >= ' ' | ||
| 2342 | && (unsigned) XINT (c) < 127) | ||
| 2343 | { | ||
| 2344 | int saved = current_kboard->immediate_echo; | ||
| 2345 | tem = call1 (Vinput_method_function, c); | ||
| 2346 | current_kboard->immediate_echo = saved; | ||
| 2347 | /* The input method can return no events. */ | ||
| 2348 | if (! CONSP (tem)) | ||
| 2349 | goto retry; | ||
| 2350 | /* It returned one event or more. */ | ||
| 2351 | c = XCONS (tem)->car; | ||
| 2352 | Vunread_post_input_method_events | ||
| 2353 | = nconc2 (XCONS (tem)->cdr, Vunread_post_input_method_events); | ||
| 2354 | } | ||
| 2355 | } | ||
| 2272 | 2356 | ||
| 2273 | before_command_key_count = this_command_key_count; | 2357 | reread_first: |
| 2274 | before_command_echo_length = echo_length (); | ||
| 2275 | 2358 | ||
| 2276 | /* Don't echo mouse motion events. */ | 2359 | if (this_command_key_count == 0 || ! reread) |
| 2277 | if (echo_keystrokes | ||
| 2278 | && ! (EVENT_HAS_PARAMETERS (c) | ||
| 2279 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | ||
| 2280 | { | 2360 | { |
| 2281 | echo_char (c); | 2361 | before_command_key_count = this_command_key_count; |
| 2362 | before_command_echo_length = echo_length (); | ||
| 2363 | |||
| 2364 | /* Don't echo mouse motion events. */ | ||
| 2365 | if (echo_keystrokes | ||
| 2366 | && ! (EVENT_HAS_PARAMETERS (c) | ||
| 2367 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement))) | ||
| 2368 | { | ||
| 2369 | echo_char (c); | ||
| 2370 | if (! NILP (also_record)) | ||
| 2371 | echo_char (also_record); | ||
| 2372 | /* Once we reread a character, echoing can happen | ||
| 2373 | the next time we pause to read a new one. */ | ||
| 2374 | ok_to_echo_at_next_pause = echo_area_glyphs; | ||
| 2375 | } | ||
| 2376 | |||
| 2377 | /* Record this character as part of the current key. */ | ||
| 2378 | add_command_key (c); | ||
| 2282 | if (! NILP (also_record)) | 2379 | if (! NILP (also_record)) |
| 2283 | echo_char (also_record); | 2380 | add_command_key (also_record); |
| 2284 | /* Once we reread a character, echoing can happen | ||
| 2285 | the next time we pause to read a new one. */ | ||
| 2286 | ok_to_echo_at_next_pause = echo_area_glyphs; | ||
| 2287 | } | 2381 | } |
| 2288 | 2382 | ||
| 2289 | /* Record this character as part of the current key. */ | ||
| 2290 | add_command_key (c); | ||
| 2291 | if (! NILP (also_record)) | ||
| 2292 | add_command_key (also_record); | ||
| 2293 | |||
| 2294 | /* Re-reading in the middle of a command */ | ||
| 2295 | reread: | ||
| 2296 | last_input_char = c; | 2383 | last_input_char = c; |
| 2297 | num_input_events++; | 2384 | num_input_events++; |
| 2298 | 2385 | ||
| @@ -6565,6 +6652,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6565 | 6652 | ||
| 6566 | int junk; | 6653 | int junk; |
| 6567 | 6654 | ||
| 6655 | raw_keybuf_count = 0; | ||
| 6656 | |||
| 6568 | last_nonmenu_event = Qnil; | 6657 | last_nonmenu_event = Qnil; |
| 6569 | 6658 | ||
| 6570 | delayed_switch_frame = Qnil; | 6659 | delayed_switch_frame = Qnil; |
| @@ -6609,6 +6698,10 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6609 | 6698 | ||
| 6610 | orig_local_map = get_local_map (PT, current_buffer); | 6699 | orig_local_map = get_local_map (PT, current_buffer); |
| 6611 | 6700 | ||
| 6701 | /* Bind input-method-function so that we can set it to nil | ||
| 6702 | temporarily after the first input event. */ | ||
| 6703 | specbind (Qinput_method_function, Vinput_method_function); | ||
| 6704 | |||
| 6612 | /* We jump here when the key sequence has been thoroughly changed, and | 6705 | /* We jump here when the key sequence has been thoroughly changed, and |
| 6613 | we need to rescan it starting from the beginning. When we jump here, | 6706 | we need to rescan it starting from the beginning. When we jump here, |
| 6614 | keybuf[0..mock_input] holds the sequence we should reread. */ | 6707 | keybuf[0..mock_input] holds the sequence we should reread. */ |
| @@ -6780,12 +6873,18 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6780 | #endif | 6873 | #endif |
| 6781 | key = read_char (NILP (prompt), nmaps, submaps, last_nonmenu_event, | 6874 | key = read_char (NILP (prompt), nmaps, submaps, last_nonmenu_event, |
| 6782 | &used_mouse_menu); | 6875 | &used_mouse_menu); |
| 6876 | |||
| 6877 | /* Turn off input methods after a prefix character. */ | ||
| 6878 | Vinput_method_function = Qnil; | ||
| 6783 | } | 6879 | } |
| 6784 | 6880 | ||
| 6785 | /* read_char returns t when it shows a menu and the user rejects it. | 6881 | /* read_char returns t when it shows a menu and the user rejects it. |
| 6786 | Just return -1. */ | 6882 | Just return -1. */ |
| 6787 | if (EQ (key, Qt)) | 6883 | if (EQ (key, Qt)) |
| 6788 | return -1; | 6884 | { |
| 6885 | unbind_to (count, Qnil); | ||
| 6886 | return -1; | ||
| 6887 | } | ||
| 6789 | 6888 | ||
| 6790 | /* read_char returns -1 at the end of a macro. | 6889 | /* read_char returns -1 at the end of a macro. |
| 6791 | Emacs 18 handles this by returning immediately with a | 6890 | Emacs 18 handles this by returning immediately with a |
| @@ -6821,6 +6920,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6821 | replay to get the right keymap. */ | 6920 | replay to get the right keymap. */ |
| 6822 | if (XINT (key) == quit_char && current_buffer != starting_buffer) | 6921 | if (XINT (key) == quit_char && current_buffer != starting_buffer) |
| 6823 | { | 6922 | { |
| 6923 | GROW_RAW_KEYBUF; | ||
| 6924 | XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; | ||
| 6824 | keybuf[t++] = key; | 6925 | keybuf[t++] = key; |
| 6825 | mock_input = t; | 6926 | mock_input = t; |
| 6826 | Vquit_flag = Qnil; | 6927 | Vquit_flag = Qnil; |
| @@ -6829,6 +6930,22 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6829 | } | 6930 | } |
| 6830 | 6931 | ||
| 6831 | Vquit_flag = Qnil; | 6932 | Vquit_flag = Qnil; |
| 6933 | |||
| 6934 | if (EVENT_HAS_PARAMETERS (key) | ||
| 6935 | && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)), Qswitch_frame)) | ||
| 6936 | { | ||
| 6937 | /* If we're at the beginning of a key sequence, and the caller | ||
| 6938 | says it's okay, go ahead and return this event. If we're | ||
| 6939 | in the midst of a key sequence, delay it until the end. */ | ||
| 6940 | if (t > 0 || !can_return_switch_frame) | ||
| 6941 | { | ||
| 6942 | delayed_switch_frame = key; | ||
| 6943 | goto replay_key; | ||
| 6944 | } | ||
| 6945 | } | ||
| 6946 | |||
| 6947 | GROW_RAW_KEYBUF; | ||
| 6948 | XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; | ||
| 6832 | } | 6949 | } |
| 6833 | 6950 | ||
| 6834 | /* Clicks in non-text areas get prefixed by the symbol | 6951 | /* Clicks in non-text areas get prefixed by the symbol |
| @@ -6874,6 +6991,7 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6874 | && BUFFERP (XWINDOW (window)->buffer) | 6991 | && BUFFERP (XWINDOW (window)->buffer) |
| 6875 | && XBUFFER (XWINDOW (window)->buffer) != current_buffer) | 6992 | && XBUFFER (XWINDOW (window)->buffer) != current_buffer) |
| 6876 | { | 6993 | { |
| 6994 | XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key; | ||
| 6877 | keybuf[t] = key; | 6995 | keybuf[t] = key; |
| 6878 | mock_input = t + 1; | 6996 | mock_input = t + 1; |
| 6879 | 6997 | ||
| @@ -6938,17 +7056,6 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 6938 | goto replay_key; | 7056 | goto replay_key; |
| 6939 | } | 7057 | } |
| 6940 | } | 7058 | } |
| 6941 | else if (EQ (kind, Qswitch_frame)) | ||
| 6942 | { | ||
| 6943 | /* If we're at the beginning of a key sequence, and the caller | ||
| 6944 | says it's okay, go ahead and return this event. If we're | ||
| 6945 | in the midst of a key sequence, delay it until the end. */ | ||
| 6946 | if (t > 0 || !can_return_switch_frame) | ||
| 6947 | { | ||
| 6948 | delayed_switch_frame = key; | ||
| 6949 | goto replay_key; | ||
| 6950 | } | ||
| 6951 | } | ||
| 6952 | else if (CONSP (XCONS (key)->cdr) | 7059 | else if (CONSP (XCONS (key)->cdr) |
| 6953 | && CONSP (EVENT_START (key)) | 7060 | && CONSP (EVENT_START (key)) |
| 6954 | && CONSP (XCONS (EVENT_START (key))->cdr)) | 7061 | && CONSP (XCONS (EVENT_START (key))->cdr)) |
| @@ -7456,6 +7563,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last, | |||
| 7456 | add_command_key (keybuf[t]); | 7563 | add_command_key (keybuf[t]); |
| 7457 | } | 7564 | } |
| 7458 | 7565 | ||
| 7566 | |||
| 7567 | |||
| 7459 | return t; | 7568 | return t; |
| 7460 | } | 7569 | } |
| 7461 | 7570 | ||
| @@ -7972,6 +8081,18 @@ The value is always a vector.") | |||
| 7972 | + this_single_command_key_start)); | 8081 | + this_single_command_key_start)); |
| 7973 | } | 8082 | } |
| 7974 | 8083 | ||
| 8084 | DEFUN ("this-single-command-raw-keys", Fthis_single_command_raw_keys, | ||
| 8085 | Sthis_single_command_raw_keys, 0, 0, 0, | ||
| 8086 | "Return the raw events that were read for this command.\n\ | ||
| 8087 | Unlike `this-single-command-keys', this function's value\n\ | ||
| 8088 | shows the events before all translations (except for input methods).\n\ | ||
| 8089 | The value is always a vector.") | ||
| 8090 | () | ||
| 8091 | { | ||
| 8092 | return Fvector (raw_keybuf_count, | ||
| 8093 | (XVECTOR (raw_keybuf)->contents)); | ||
| 8094 | } | ||
| 8095 | |||
| 7975 | DEFUN ("reset-this-command-lengths", Freset_this_command_lengths, | 8096 | DEFUN ("reset-this-command-lengths", Freset_this_command_lengths, |
| 7976 | Sreset_this_command_lengths, 0, 0, 0, | 8097 | Sreset_this_command_lengths, 0, 0, 0, |
| 7977 | "Used for complicated reasons in `universal-argument-other-key'.\n\ | 8098 | "Used for complicated reasons in `universal-argument-other-key'.\n\ |
| @@ -8711,6 +8832,9 @@ syms_of_keyboard () | |||
| 8711 | Qpolling_period = intern ("polling-period"); | 8832 | Qpolling_period = intern ("polling-period"); |
| 8712 | staticpro (&Qpolling_period); | 8833 | staticpro (&Qpolling_period); |
| 8713 | 8834 | ||
| 8835 | Qinput_method_function = intern ("input-method-function"); | ||
| 8836 | staticpro (&Qinput_method_function); | ||
| 8837 | |||
| 8714 | { | 8838 | { |
| 8715 | struct event_head *p; | 8839 | struct event_head *p; |
| 8716 | 8840 | ||
| @@ -8745,6 +8869,9 @@ syms_of_keyboard () | |||
| 8745 | this_command_keys = Fmake_vector (make_number (40), Qnil); | 8869 | this_command_keys = Fmake_vector (make_number (40), Qnil); |
| 8746 | staticpro (&this_command_keys); | 8870 | staticpro (&this_command_keys); |
| 8747 | 8871 | ||
| 8872 | raw_keybuf = Fmake_vector (make_number (30), Qnil); | ||
| 8873 | staticpro (&raw_keybuf); | ||
| 8874 | |||
| 8748 | Qextended_command_history = intern ("extended-command-history"); | 8875 | Qextended_command_history = intern ("extended-command-history"); |
| 8749 | Fset (Qextended_command_history, Qnil); | 8876 | Fset (Qextended_command_history, Qnil); |
| 8750 | staticpro (&Qextended_command_history); | 8877 | staticpro (&Qextended_command_history); |
| @@ -8792,6 +8919,7 @@ syms_of_keyboard () | |||
| 8792 | defsubr (&Sthis_command_keys); | 8919 | defsubr (&Sthis_command_keys); |
| 8793 | defsubr (&Sthis_command_keys_vector); | 8920 | defsubr (&Sthis_command_keys_vector); |
| 8794 | defsubr (&Sthis_single_command_keys); | 8921 | defsubr (&Sthis_single_command_keys); |
| 8922 | defsubr (&Sthis_single_command_raw_keys); | ||
| 8795 | defsubr (&Sreset_this_command_lengths); | 8923 | defsubr (&Sreset_this_command_lengths); |
| 8796 | defsubr (&Ssuspend_emacs); | 8924 | defsubr (&Ssuspend_emacs); |
| 8797 | defsubr (&Sabort_recursive_edit); | 8925 | defsubr (&Sabort_recursive_edit); |
| @@ -8823,11 +8951,25 @@ so that you can determine whether the command was run by mouse or not."); | |||
| 8823 | "Last input event."); | 8951 | "Last input event."); |
| 8824 | 8952 | ||
| 8825 | DEFVAR_LISP ("unread-command-events", &Vunread_command_events, | 8953 | DEFVAR_LISP ("unread-command-events", &Vunread_command_events, |
| 8826 | "List of objects to be read as next command input events."); | 8954 | "List of events to be read as the command input.\n\ |
| 8955 | These events are processed first, before actual keyboard input."); | ||
| 8956 | Vunread_command_events = Qnil; | ||
| 8827 | 8957 | ||
| 8828 | DEFVAR_INT ("unread-command-char", &unread_command_char, | 8958 | DEFVAR_INT ("unread-command-char", &unread_command_char, |
| 8829 | "If not -1, an object to be read as next command input event."); | 8959 | "If not -1, an object to be read as next command input event."); |
| 8830 | 8960 | ||
| 8961 | DEFVAR_LISP ("unread-post-input-method-events", &Vunread_post_input_method_events, | ||
| 8962 | "List of events to be processed as input by input methods.\n\ | ||
| 8963 | These events are processed after `unread-command-events', but\n\ | ||
| 8964 | before actual keyboard input."); | ||
| 8965 | Vunread_post_input_method_events = Qnil; | ||
| 8966 | |||
| 8967 | DEFVAR_LISP ("unread-input-method-events", &Vunread_input_method_events, | ||
| 8968 | "List of events to be processed as input by input methods.\n\ | ||
| 8969 | These events are processed after `unread-command-events', but\n\ | ||
| 8970 | before actual keyboard input."); | ||
| 8971 | Vunread_input_method_events = Qnil; | ||
| 8972 | |||
| 8831 | DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, | 8973 | DEFVAR_LISP ("meta-prefix-char", &meta_prefix_char, |
| 8832 | "Meta-prefix character code. Meta-foo as command input\n\ | 8974 | "Meta-prefix character code. Meta-foo as command input\n\ |
| 8833 | turns into this character followed by foo."); | 8975 | turns into this character followed by foo."); |
| @@ -9084,6 +9226,20 @@ If the value is non-nil and not a number, we wait 2 seconds."); | |||
| 9084 | DEFVAR_LISP ("timer-idle-list", &Vtimer_idle_list, | 9226 | DEFVAR_LISP ("timer-idle-list", &Vtimer_idle_list, |
| 9085 | "List of active idle-time timers in order of increasing time"); | 9227 | "List of active idle-time timers in order of increasing time"); |
| 9086 | Vtimer_idle_list = Qnil; | 9228 | Vtimer_idle_list = Qnil; |
| 9229 | |||
| 9230 | DEFVAR_LISP ("input-method-function", &Vinput_method_function, | ||
| 9231 | "If non-nil, the function that implements the current input method.\n\ | ||
| 9232 | It's called with one argument, a printing character that was just read.\n\ | ||
| 9233 | \(That means a character with code 040...0176.)\n\ | ||
| 9234 | Typically this function uses `read-event' to read additional events.\n\ | ||
| 9235 | When it does so, it should first bind `input-method-function' to nil\n\ | ||
| 9236 | so it will not be called recursively.\n\ | ||
| 9237 | \n\ | ||
| 9238 | The function should return a list of zero or more events\n\ | ||
| 9239 | to be used as input. If it wants to put back some events\n\ | ||
| 9240 | to be reconsidered, separately, by the input method,\n\ | ||
| 9241 | it can add them to the beginning of `unread-command-events'."); | ||
| 9242 | Vinput_method_function = Qnil; | ||
| 9087 | } | 9243 | } |
| 9088 | 9244 | ||
| 9089 | void | 9245 | void |