Mercurial > emacs
comparison src/keyboard.c @ 90580:7f3f771c85fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 382-398)
- Update from CVS
- Update from erc--emacs--22
- Fix ERC bug introduced in last patch
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 123-125)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-101
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 16 Aug 2006 14:08:49 +0000 |
parents | 858cb33ae39d 949ddf473439 |
children | 6823a91487f2 |
comparison
equal
deleted
inserted
replaced
90579:c78f05b8f09e | 90580:7f3f771c85fa |
---|---|
97 int interrupt_input_pending; | 97 int interrupt_input_pending; |
98 | 98 |
99 | 99 |
100 /* File descriptor to use for input. */ | 100 /* File descriptor to use for input. */ |
101 extern int input_fd; | 101 extern int input_fd; |
102 | |
103 /* Nonzero if we are executing from the SIGIO signal handler. */ | |
104 int in_sighandler; | |
102 | 105 |
103 #ifdef HAVE_WINDOW_SYSTEM | 106 #ifdef HAVE_WINDOW_SYSTEM |
104 /* Make all keyboard buffers much bigger when using X windows. */ | 107 /* Make all keyboard buffers much bigger when using X windows. */ |
105 #ifdef MAC_OS8 | 108 #ifdef MAC_OS8 |
106 /* But not too big (local data > 32K error) if on Mac OS Classic. */ | 109 /* But not too big (local data > 32K error) if on Mac OS Classic. */ |
2401 Lisp_Object prev_event; | 2404 Lisp_Object prev_event; |
2402 int *used_mouse_menu; | 2405 int *used_mouse_menu; |
2403 EMACS_TIME *end_time; | 2406 EMACS_TIME *end_time; |
2404 { | 2407 { |
2405 volatile Lisp_Object c; | 2408 volatile Lisp_Object c; |
2406 int count; | 2409 int count, jmpcount; |
2407 jmp_buf local_getcjmp; | 2410 jmp_buf local_getcjmp; |
2408 jmp_buf save_jump; | 2411 jmp_buf save_jump; |
2409 volatile int key_already_recorded = 0; | 2412 volatile int key_already_recorded = 0; |
2410 Lisp_Object tem, save; | 2413 Lisp_Object tem, save; |
2411 volatile Lisp_Object previous_echo_area_message; | 2414 volatile Lisp_Object previous_echo_area_message; |
2627 We will do that below, temporarily for short sections of code, | 2630 We will do that below, temporarily for short sections of code, |
2628 when appropriate. local_getcjmp must be in effect | 2631 when appropriate. local_getcjmp must be in effect |
2629 around any call to sit_for or kbd_buffer_get_event; | 2632 around any call to sit_for or kbd_buffer_get_event; |
2630 it *must not* be in effect when we call redisplay. */ | 2633 it *must not* be in effect when we call redisplay. */ |
2631 | 2634 |
2635 jmpcount = SPECPDL_INDEX (); | |
2632 if (_setjmp (local_getcjmp)) | 2636 if (_setjmp (local_getcjmp)) |
2633 { | 2637 { |
2634 /* We must have saved the outer value of getcjmp here, | 2638 /* We must have saved the outer value of getcjmp here, |
2635 so restore it now. */ | 2639 so restore it now. */ |
2636 restore_getcjmp (save_jump); | 2640 restore_getcjmp (save_jump); |
2641 unbind_to (jmpcount, Qnil); | |
2637 XSETINT (c, quit_char); | 2642 XSETINT (c, quit_char); |
2638 internal_last_event_frame = selected_frame; | 2643 internal_last_event_frame = selected_frame; |
2639 Vlast_event_frame = internal_last_event_frame; | 2644 Vlast_event_frame = internal_last_event_frame; |
2640 /* If we report the quit char as an event, | 2645 /* If we report the quit char as an event, |
2641 don't do so more than once. */ | 2646 don't do so more than once. */ |
2672 } | 2677 } |
2673 #endif | 2678 #endif |
2674 goto non_reread; | 2679 goto non_reread; |
2675 } | 2680 } |
2676 | 2681 |
2677 timer_start_idle (); | 2682 /* Start idle timers if no time limit is supplied. We don't do it |
2683 if a time limit is supplied to avoid an infinite recursion in the | |
2684 situation where an idle timer calls `sit-for'. */ | |
2685 | |
2686 if (!end_time) | |
2687 timer_start_idle (); | |
2678 | 2688 |
2679 /* If in middle of key sequence and minibuffer not active, | 2689 /* If in middle of key sequence and minibuffer not active, |
2680 start echoing if enough time elapses. */ | 2690 start echoing if enough time elapses. */ |
2681 | 2691 |
2682 if (minibuf_level == 0 | 2692 if (minibuf_level == 0 |
2742 && unread_command_char < 0) | 2752 && unread_command_char < 0) |
2743 { | 2753 { |
2744 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); | 2754 c = read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu); |
2745 | 2755 |
2746 /* Now that we have read an event, Emacs is not idle. */ | 2756 /* Now that we have read an event, Emacs is not idle. */ |
2747 timer_stop_idle (); | 2757 if (!end_time) |
2758 timer_stop_idle (); | |
2748 | 2759 |
2749 goto exit; | 2760 goto exit; |
2750 } | 2761 } |
2751 | 2762 |
2752 /* Maybe autosave and/or garbage collect due to idleness. */ | 2763 /* Maybe autosave and/or garbage collect due to idleness. */ |
2872 } | 2883 } |
2873 | 2884 |
2874 /* Actually read a character, waiting if necessary. */ | 2885 /* Actually read a character, waiting if necessary. */ |
2875 save_getcjmp (save_jump); | 2886 save_getcjmp (save_jump); |
2876 restore_getcjmp (local_getcjmp); | 2887 restore_getcjmp (local_getcjmp); |
2877 timer_start_idle (); | 2888 if (!end_time) |
2889 timer_start_idle (); | |
2878 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); | 2890 c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time); |
2879 restore_getcjmp (save_jump); | 2891 restore_getcjmp (save_jump); |
2880 | 2892 |
2881 #ifdef MULTI_KBOARD | 2893 #ifdef MULTI_KBOARD |
2882 if (! NILP (c) && (kb != current_kboard)) | 2894 if (! NILP (c) && (kb != current_kboard)) |
2924 XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL)); | 2936 XSETINT (c, XINT (c) | (extra_keyboard_modifiers & ~0xff7f & ~CHAR_CTL)); |
2925 } | 2937 } |
2926 | 2938 |
2927 non_reread: | 2939 non_reread: |
2928 | 2940 |
2929 timer_stop_idle (); | 2941 if (!end_time) |
2942 timer_stop_idle (); | |
2930 RESUME_POLLING; | 2943 RESUME_POLLING; |
2931 | 2944 |
2932 if (NILP (c)) | 2945 if (NILP (c)) |
2933 { | 2946 { |
2934 if (commandflag >= 0 | 2947 if (commandflag >= 0 |
2958 int was_locked = single_kboard; | 2971 int was_locked = single_kboard; |
2959 | 2972 |
2960 last_input_char = c; | 2973 last_input_char = c; |
2961 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); | 2974 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); |
2962 | 2975 |
2963 if (CONSP (c) && EQ (XCAR (c), Qselect_window)) | 2976 if (CONSP (c) && EQ (XCAR (c), Qselect_window) && !end_time) |
2964 /* We stopped being idle for this event; undo that. This | 2977 /* We stopped being idle for this event; undo that. This |
2965 prevents automatic window selection (under | 2978 prevents automatic window selection (under |
2966 mouse_autoselect_window from acting as a real input event, for | 2979 mouse_autoselect_window from acting as a real input event, for |
2967 example banishing the mouse under mouse-avoidance-mode. */ | 2980 example banishing the mouse under mouse-avoidance-mode. */ |
2968 timer_resume_idle (); | 2981 timer_resume_idle (); |
3164 position = Fcar (tem); | 3177 position = Fcar (tem); |
3165 | 3178 |
3166 show_help_echo (help, window, object, position, 0); | 3179 show_help_echo (help, window, object, position, 0); |
3167 | 3180 |
3168 /* We stopped being idle for this event; undo that. */ | 3181 /* We stopped being idle for this event; undo that. */ |
3169 timer_resume_idle (); | 3182 if (!end_time) |
3183 timer_resume_idle (); | |
3170 goto retry; | 3184 goto retry; |
3171 } | 3185 } |
3172 | 3186 |
3173 if (! reread || this_command_key_count == 0 | 3187 if (! reread || this_command_key_count == 0 |
3174 || this_command_key_count_reset) | 3188 || this_command_key_count_reset) |
3950 #endif | 3964 #endif |
3951 if (end_time) | 3965 if (end_time) |
3952 { | 3966 { |
3953 EMACS_TIME duration; | 3967 EMACS_TIME duration; |
3954 EMACS_GET_TIME (duration); | 3968 EMACS_GET_TIME (duration); |
3955 EMACS_SUB_TIME (duration, *end_time, duration); | 3969 if (EMACS_TIME_GE (duration, *end_time)) |
3956 if (EMACS_TIME_NEG_P (duration)) | 3970 return Qnil; /* finished waiting */ |
3957 return Qnil; | |
3958 else | 3971 else |
3959 wait_reading_process_output (EMACS_SECS (duration), | 3972 { |
3960 EMACS_USECS (duration), | 3973 EMACS_SUB_TIME (duration, *end_time, duration); |
3961 -1, 1, Qnil, NULL, 0); | 3974 wait_reading_process_output (EMACS_SECS (duration), |
3975 EMACS_USECS (duration), | |
3976 -1, 1, Qnil, NULL, 0); | |
3977 } | |
3962 } | 3978 } |
3963 else | 3979 else |
3964 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); | 3980 wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); |
3965 | 3981 |
3966 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) | 3982 if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) |
6918 interrupt_input_pending = 1; | 6934 interrupt_input_pending = 1; |
6919 #else | 6935 #else |
6920 SIGNAL_THREAD_CHECK (signo); | 6936 SIGNAL_THREAD_CHECK (signo); |
6921 #endif | 6937 #endif |
6922 | 6938 |
6939 in_sighandler = 1; | |
6940 | |
6923 if (input_available_clear_time) | 6941 if (input_available_clear_time) |
6924 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | 6942 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
6925 | 6943 |
6926 #ifndef SYNC_INPUT | 6944 #ifndef SYNC_INPUT |
6927 handle_async_input (); | 6945 handle_async_input (); |
6929 | 6947 |
6930 #ifdef BSD4_1 | 6948 #ifdef BSD4_1 |
6931 sigfree (); | 6949 sigfree (); |
6932 #endif | 6950 #endif |
6933 errno = old_errno; | 6951 errno = old_errno; |
6952 in_sighandler = 0; | |
6934 } | 6953 } |
6935 #endif /* SIGIO */ | 6954 #endif /* SIGIO */ |
6936 | 6955 |
6937 /* Send ourselves a SIGIO. | 6956 /* Send ourselves a SIGIO. |
6938 | 6957 |
8379 | 8398 |
8380 /* Structure used to keep track of partial application of key remapping | 8399 /* Structure used to keep track of partial application of key remapping |
8381 such as Vfunction_key_map and Vkey_translation_map. */ | 8400 such as Vfunction_key_map and Vkey_translation_map. */ |
8382 typedef struct keyremap | 8401 typedef struct keyremap |
8383 { | 8402 { |
8384 Lisp_Object map, parent; | 8403 /* This is the map originally specified for this use. */ |
8404 Lisp_Object parent; | |
8405 /* This is a submap reached by looking up, in PARENT, | |
8406 the events from START to END. */ | |
8407 Lisp_Object map; | |
8408 /* Positions [START, END) in the key sequence buffer | |
8409 are the key that we have scanned so far. | |
8410 Those events are the ones that we will replace | |
8411 if PAREHT maps them into a key sequence. */ | |
8385 int start, end; | 8412 int start, end; |
8386 } keyremap; | 8413 } keyremap; |
8387 | 8414 |
8388 /* Lookup KEY in MAP. | 8415 /* Lookup KEY in MAP. |
8389 MAP is a keymap mapping keys to key vectors or functions. | 8416 MAP is a keymap mapping keys to key vectors or functions. |
8452 int input, doit, *diff, bufsize; | 8479 int input, doit, *diff, bufsize; |
8453 { | 8480 { |
8454 Lisp_Object next, key; | 8481 Lisp_Object next, key; |
8455 | 8482 |
8456 key = keybuf[fkey->end++]; | 8483 key = keybuf[fkey->end++]; |
8457 next = access_keymap_keyremap (fkey->map, key, prompt, doit); | 8484 |
8485 if (KEYMAPP (fkey->parent)) | |
8486 next = access_keymap_keyremap (fkey->map, key, prompt, doit); | |
8487 else | |
8488 next = Qnil; | |
8458 | 8489 |
8459 /* If keybuf[fkey->start..fkey->end] is bound in the | 8490 /* If keybuf[fkey->start..fkey->end] is bound in the |
8460 map and we're in a position to do the key remapping, replace it with | 8491 map and we're in a position to do the key remapping, replace it with |
8461 the binding and restart with fkey->start at the end. */ | 8492 the binding and restart with fkey->start at the end. */ |
8462 if ((VECTORP (next) || STRINGP (next)) && doit) | 8493 if ((VECTORP (next) || STRINGP (next)) && doit) |
8650 last_nonmenu_event = Qnil; | 8681 last_nonmenu_event = Qnil; |
8651 | 8682 |
8652 delayed_switch_frame = Qnil; | 8683 delayed_switch_frame = Qnil; |
8653 fkey.map = fkey.parent = Vfunction_key_map; | 8684 fkey.map = fkey.parent = Vfunction_key_map; |
8654 keytran.map = keytran.parent = Vkey_translation_map; | 8685 keytran.map = keytran.parent = Vkey_translation_map; |
8655 /* If there is no translation-map, turn off scanning. */ | 8686 fkey.start = fkey.end = 0; |
8656 fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; | 8687 keytran.start = keytran.end = 0; |
8657 keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; | |
8658 | 8688 |
8659 if (INTERACTIVE) | 8689 if (INTERACTIVE) |
8660 { | 8690 { |
8661 if (!NILP (prompt)) | 8691 if (!NILP (prompt)) |
8662 echo_prompt (prompt); | 8692 echo_prompt (prompt); |
9479 new_key = apply_modifiers (modifiers, | 9509 new_key = apply_modifiers (modifiers, |
9480 XCAR (breakdown)); | 9510 XCAR (breakdown)); |
9481 | 9511 |
9482 keybuf[t - 1] = new_key; | 9512 keybuf[t - 1] = new_key; |
9483 mock_input = max (t, mock_input); | 9513 mock_input = max (t, mock_input); |
9484 fkey.start = fkey.end = KEYMAPP (fkey.map) ? 0 : bufsize + 1; | 9514 fkey.start = fkey.end = 0; |
9485 keytran.start = keytran.end = KEYMAPP (keytran.map) ? 0 : bufsize + 1; | 9515 keytran.start = keytran.end = 0; |
9486 | 9516 |
9487 goto replay_sequence; | 9517 goto replay_sequence; |
9488 } | 9518 } |
9489 } | 9519 } |
9490 } | 9520 } |
10784 kbd_store_ptr = kbd_buffer; | 10814 kbd_store_ptr = kbd_buffer; |
10785 #ifdef HAVE_MOUSE | 10815 #ifdef HAVE_MOUSE |
10786 do_mouse_tracking = Qnil; | 10816 do_mouse_tracking = Qnil; |
10787 #endif | 10817 #endif |
10788 input_pending = 0; | 10818 input_pending = 0; |
10819 in_sighandler = 0; | |
10789 | 10820 |
10790 /* This means that command_loop_1 won't try to select anything the first | 10821 /* This means that command_loop_1 won't try to select anything the first |
10791 time through. */ | 10822 time through. */ |
10792 internal_last_event_frame = Qnil; | 10823 internal_last_event_frame = Qnil; |
10793 Vlast_event_frame = internal_last_event_frame; | 10824 Vlast_event_frame = internal_last_event_frame; |