diff options
| author | Richard M. Stallman | 2002-09-27 17:03:46 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-09-27 17:03:46 +0000 |
| commit | 184c3d811ac1d2df60b26c442c44eab2f3ff2d6e (patch) | |
| tree | 432fa2523f1bc439bb2108918bbd3714e8e08dc4 /src | |
| parent | 730576f3ece61a29a95b25df897ba0bdb73aa539 (diff) | |
| download | emacs-184c3d811ac1d2df60b26c442c44eab2f3ff2d6e.tar.gz emacs-184c3d811ac1d2df60b26c442c44eab2f3ff2d6e.zip | |
(STOP_POLLING, RESUME_POLLING): New macros.
(read_char): Use them. Do all exits thru the end of the function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index b409439a993..6c6eb0fe221 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2144,6 +2144,14 @@ static void record_char (); | |||
| 2144 | static jmp_buf wrong_kboard_jmpbuf; | 2144 | static jmp_buf wrong_kboard_jmpbuf; |
| 2145 | #endif | 2145 | #endif |
| 2146 | 2146 | ||
| 2147 | #define STOP_POLLING \ | ||
| 2148 | do { if (! polling_stopped_here) stop_polling (); \ | ||
| 2149 | polling_stopped_here = 1; } while (0) | ||
| 2150 | |||
| 2151 | #define RESUME_POLLING \ | ||
| 2152 | do { if (polling_stopped_here) start_polling (); \ | ||
| 2153 | polling_stopped_here = 0; } while (0) | ||
| 2154 | |||
| 2147 | /* read a character from the keyboard; call the redisplay if needed */ | 2155 | /* read a character from the keyboard; call the redisplay if needed */ |
| 2148 | /* commandflag 0 means do not do auto-saving, but do do redisplay. | 2156 | /* commandflag 0 means do not do auto-saving, but do do redisplay. |
| 2149 | -1 means do not do redisplay, but do do autosaving. | 2157 | -1 means do not do redisplay, but do do autosaving. |
| @@ -2183,6 +2191,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2183 | volatile int reread; | 2191 | volatile int reread; |
| 2184 | struct gcpro gcpro1, gcpro2; | 2192 | struct gcpro gcpro1, gcpro2; |
| 2185 | EMACS_TIME last_idle_start; | 2193 | EMACS_TIME last_idle_start; |
| 2194 | int polling_stopped_here = 0; | ||
| 2186 | 2195 | ||
| 2187 | also_record = Qnil; | 2196 | also_record = Qnil; |
| 2188 | 2197 | ||
| @@ -2284,7 +2293,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2284 | || executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) | 2293 | || executing_macro_index >= XFASTINT (Flength (Vexecuting_macro))) |
| 2285 | { | 2294 | { |
| 2286 | XSETINT (c, -1); | 2295 | XSETINT (c, -1); |
| 2287 | RETURN_UNGCPRO (c); | 2296 | goto exit; |
| 2288 | } | 2297 | } |
| 2289 | 2298 | ||
| 2290 | c = Faref (Vexecuting_macro, make_number (executing_macro_index)); | 2299 | c = Faref (Vexecuting_macro, make_number (executing_macro_index)); |
| @@ -2516,7 +2525,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2516 | /* Now that we have read an event, Emacs is not idle. */ | 2525 | /* Now that we have read an event, Emacs is not idle. */ |
| 2517 | timer_stop_idle (); | 2526 | timer_stop_idle (); |
| 2518 | 2527 | ||
| 2519 | RETURN_UNGCPRO (c); | 2528 | goto exit; |
| 2520 | } | 2529 | } |
| 2521 | 2530 | ||
| 2522 | /* Maybe autosave and/or garbage collect due to idleness. */ | 2531 | /* Maybe autosave and/or garbage collect due to idleness. */ |
| @@ -2623,7 +2632,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2623 | 2632 | ||
| 2624 | wrong_kboard: | 2633 | wrong_kboard: |
| 2625 | 2634 | ||
| 2626 | stop_polling (); | 2635 | STOP_POLLING; |
| 2627 | 2636 | ||
| 2628 | /* Finally, we read from the main queue, | 2637 | /* Finally, we read from the main queue, |
| 2629 | and if that gives us something we can't use yet, we put it on the | 2638 | and if that gives us something we can't use yet, we put it on the |
| @@ -2692,7 +2701,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2692 | should the next event read be a help-echo. */ | 2701 | should the next event read be a help-echo. */ |
| 2693 | last_idle_start = timer_idleness_start_time; | 2702 | last_idle_start = timer_idleness_start_time; |
| 2694 | timer_stop_idle (); | 2703 | timer_stop_idle (); |
| 2695 | start_polling (); | 2704 | RESUME_POLLING; |
| 2696 | 2705 | ||
| 2697 | if (NILP (c)) | 2706 | if (NILP (c)) |
| 2698 | { | 2707 | { |
| @@ -2709,7 +2718,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2709 | so don't show them to the user. | 2718 | so don't show them to the user. |
| 2710 | Also, don't record a key if we already did. */ | 2719 | Also, don't record a key if we already did. */ |
| 2711 | if (BUFFERP (c) || key_already_recorded) | 2720 | if (BUFFERP (c) || key_already_recorded) |
| 2712 | RETURN_UNGCPRO (c); | 2721 | goto exit; |
| 2713 | 2722 | ||
| 2714 | /* Process special events within read_char | 2723 | /* Process special events within read_char |
| 2715 | and loop around to read another event. */ | 2724 | and loop around to read another event. */ |
| @@ -2744,7 +2753,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2744 | { | 2753 | { |
| 2745 | /* If kbd_buffer_get_event gave us an EOF, return that. */ | 2754 | /* If kbd_buffer_get_event gave us an EOF, return that. */ |
| 2746 | if (XINT (c) == -1) | 2755 | if (XINT (c) == -1) |
| 2747 | RETURN_UNGCPRO (c); | 2756 | goto exit; |
| 2748 | 2757 | ||
| 2749 | if ((STRINGP (Vkeyboard_translate_table) | 2758 | if ((STRINGP (Vkeyboard_translate_table) |
| 2750 | && SCHARS (Vkeyboard_translate_table) > (unsigned) XFASTINT (c)) | 2759 | && SCHARS (Vkeyboard_translate_table) > (unsigned) XFASTINT (c)) |
| @@ -2986,6 +2995,8 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) | |||
| 2986 | } | 2995 | } |
| 2987 | } | 2996 | } |
| 2988 | 2997 | ||
| 2998 | exit: | ||
| 2999 | RESUME_POLLING; | ||
| 2989 | RETURN_UNGCPRO (c); | 3000 | RETURN_UNGCPRO (c); |
| 2990 | } | 3001 | } |
| 2991 | 3002 | ||