comparison src/keyboard.c @ 83449:ff74a86c2b16

Overhaul and simplify single_kboard API. Allow calls to `recursive-edit' in process filters. Small fixes. * lisp/server.el (server-process-filter): Protect `display-splash-screen' call in a condition-case. Explain why. * src/callint.c (Fcall_interactively): Update call to `temporarily_switch_to_single_kboard'. * src/fns.c (Fy_or_n_p): Ditto. * src/frame.c (Fdelete_frame): Remove unused variable `count'. * src/keyboard.c (wrong_kboard_jmpbuf): Remove global variable. * src/keyboard.c (read_char): Add wrong_kboard_jmpbuf parameter to allow for recursive calls. Update longjmp invocations. Remember the original current_kboard, and longjmp to `wrong_kboard_jmpbuf' when a filter, timer or sentinel changes it. Comment out unnecessary calls to `record_single_kboard_state' and `any_kboard_state'. Update recursive calls. * src/keyboard.c (read_key_sequence): Add `wrong_kboard_jmpbuf' local variable. Update setjmp and read_char calls. Abort if interrupted_kboard died in read_char. * src/keyboard.c (any_kboard_state, single_kboard_state) (record_single_kboard_state): Comment out obsolete functions. (push_frame_kboard): Remove function. (pop_kboard): Switch out of single_kboard mode if the kboard has been deleted. (temporarily_switch_to_single_kboard): Change first parameter to a frame pointer. Throw an error when caller wants to change kboards while in single_kboard mode. (restore_kboard_configuration): Abort if pop_kboard changed the kboard in single_kboard mode. (Frecursive_edit): Switch to single_kboard mode only in nested command loops. (cmd_error, command_loop, command_loop_1, timer_check): Comment out unnecessary call to `any_kboard_state' and `record_single_kboard_state'. * src/keyboard.c (delete_kboard): Exit single_kboard mode if we have just deleted that kboard. * src/keyboard.c (interrupt_signal): Use `Fkill_emacs' to exit Emacs, not `fatal_error_signal'. * src/keyboard.h (read_char, single_kboard_state) (record_single_kboard_state): Remove. (temporarily_switch_to_single_kboard): Update. * src/lread.c: Include setjmp.h. Update declaration of `read_char'. (read_filtered_event): Call `read_char' with a local `wrong_kboard_jmpbuf'. * src/minibuf.c (read_minibuf): Update call to `temporarily_switch_to_single_kboard'. * src/termchar.h (tty_display_info): Rename `previous_terminal_frame' member to `previous_frame'. * src/xdisp.c (redisplay_internal): Update references to `previous_terminal_frame'. (display_mode_line, Fformat_mode_line): Replace calls to `push_frame_kboard' with `push_kboard'. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-489
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 03 Jan 2006 01:50:46 +0000
parents 1b1b0cb2e2a8
children ce06f17e2bfe
comparison
equal deleted inserted replaced
83448:d2af586aefe4 83449:ff74a86c2b16
668 static void save_getcjmp P_ ((jmp_buf)); 668 static void save_getcjmp P_ ((jmp_buf));
669 static void save_getcjmp (); 669 static void save_getcjmp ();
670 static void restore_getcjmp P_ ((jmp_buf)); 670 static void restore_getcjmp P_ ((jmp_buf));
671 static Lisp_Object apply_modifiers P_ ((int, Lisp_Object)); 671 static Lisp_Object apply_modifiers P_ ((int, Lisp_Object));
672 static void clear_event P_ ((struct input_event *)); 672 static void clear_event P_ ((struct input_event *));
673 static void any_kboard_state P_ ((void));
674 static Lisp_Object restore_kboard_configuration P_ ((Lisp_Object)); 673 static Lisp_Object restore_kboard_configuration P_ ((Lisp_Object));
675 static SIGTYPE interrupt_signal P_ ((int signalnum)); 674 static SIGTYPE interrupt_signal P_ ((int signalnum));
676 static void handle_interrupt P_ ((void)); 675 static void handle_interrupt P_ ((void));
677 static void timer_start_idle P_ ((void)); 676 static void timer_start_idle P_ ((void));
678 static void timer_stop_idle P_ ((void)); 677 static void timer_stop_idle P_ ((void));
1032 1031
1033 /* If we leave recursive_edit_1 below with a `throw' for instance, 1032 /* If we leave recursive_edit_1 below with a `throw' for instance,
1034 like it is done in the splash screen display, we have to 1033 like it is done in the splash screen display, we have to
1035 make sure that we restore single_kboard as command_loop_1 1034 make sure that we restore single_kboard as command_loop_1
1036 would have done if it were left normally. */ 1035 would have done if it were left normally. */
1037 temporarily_switch_to_single_kboard (FRAME_KBOARD (SELECTED_FRAME ())); 1036 if (command_loop_level > 0)
1037 temporarily_switch_to_single_kboard (SELECTED_FRAME ());
1038 record_unwind_protect (recursive_edit_unwind, buffer); 1038 record_unwind_protect (recursive_edit_unwind, buffer);
1039 1039
1040 recursive_edit_1 (); 1040 recursive_edit_1 ();
1041 return unbind_to (count, Qnil); 1041 return unbind_to (count, Qnil);
1042 } 1042 }
1052 update_mode_lines = 1; 1052 update_mode_lines = 1;
1053 return Qnil; 1053 return Qnil;
1054 } 1054 }
1055 1055
1056 1056
1057 #if 0 /* These two functions are now replaced with
1058 temporarily_switch_to_single_kboard. */
1057 static void 1059 static void
1058 any_kboard_state () 1060 any_kboard_state ()
1059 { 1061 {
1060 #ifdef MULTI_KBOARD 1062 #ifdef MULTI_KBOARD
1061 #if 0 /* Theory: if there's anything in Vunread_command_events, 1063 #if 0 /* Theory: if there's anything in Vunread_command_events,
1082 { 1084 {
1083 #ifdef MULTI_KBOARD 1085 #ifdef MULTI_KBOARD
1084 single_kboard = 1; 1086 single_kboard = 1;
1085 #endif 1087 #endif
1086 } 1088 }
1089 #endif
1087 1090
1088 /* If we're in single_kboard state for kboard KBOARD, 1091 /* If we're in single_kboard state for kboard KBOARD,
1089 get out of it. */ 1092 get out of it. */
1090 1093
1091 void 1094 void
1122 p->kboard = current_kboard; 1125 p->kboard = current_kboard;
1123 kboard_stack = p; 1126 kboard_stack = p;
1124 1127
1125 current_kboard = k; 1128 current_kboard = k;
1126 #endif 1129 #endif
1127 }
1128
1129 void
1130 push_frame_kboard (f)
1131 FRAME_PTR f;
1132 {
1133 push_kboard (f->terminal->kboard);
1134 } 1130 }
1135 1131
1136 void 1132 void
1137 pop_kboard () 1133 pop_kboard ()
1138 { 1134 {
1151 } 1147 }
1152 if (!found) 1148 if (!found)
1153 { 1149 {
1154 /* The terminal we remembered has been deleted. */ 1150 /* The terminal we remembered has been deleted. */
1155 current_kboard = FRAME_KBOARD (SELECTED_FRAME ()); 1151 current_kboard = FRAME_KBOARD (SELECTED_FRAME ());
1152 single_kboard = 0;
1156 } 1153 }
1157 kboard_stack = p->next; 1154 kboard_stack = p->next;
1158 xfree (p); 1155 xfree (p);
1159 #endif 1156 #endif
1160 } 1157 }
1161 1158
1162 /* Switch to single_kboard mode. If K is non-nil, set it as the 1159 /* Switch to single_kboard mode, making current_kboard the only KBOARD
1163 current keyboard. Use record_unwind_protect to return to the 1160 from which further input is accepted. If F is non-nil, set its
1164 previous state later. */ 1161 KBOARD as the current keyboard.
1162
1163 This function uses record_unwind_protect to return to the previous
1164 state later.
1165
1166 If Emacs is already in single_kboard mode, and F's keyboard is
1167 locked, then this function will throw an errow. */
1165 1168
1166 void 1169 void
1167 temporarily_switch_to_single_kboard (k) 1170 temporarily_switch_to_single_kboard (f)
1168 struct kboard *k; 1171 struct frame *f;
1169 { 1172 {
1170 #ifdef MULTI_KBOARD 1173 #ifdef MULTI_KBOARD
1171 int was_locked = single_kboard; 1174 int was_locked = single_kboard;
1172 if (was_locked) 1175 if (was_locked)
1173 { 1176 {
1174 if (k != NULL) 1177 if (f != NULL && FRAME_KBOARD (f) != current_kboard)
1175 push_kboard (k); 1178 /* We can not switch keyboards while in single_kboard mode.
1179 This can legally happen when Lisp code calls
1180 `recursive-edit' (or `read-minibuffer' or `y-or-n-p') after
1181 it switched to a locked frame. This kind of situation is
1182 likely to happen when server.el connects to a new
1183 terminal. */
1184 error ("Terminal %d is locked, cannot read from it",
1185 FRAME_TERMINAL (f)->id);
1176 else 1186 else
1187 /* This call is unnecessary, but helps
1188 `restore_kboard_configuration' discover if somebody changed
1189 `current_kboard' behind our back. */
1177 push_kboard (current_kboard); 1190 push_kboard (current_kboard);
1178 } 1191 }
1179 else if (k != NULL) 1192 else if (f != NULL)
1180 current_kboard = k; 1193 current_kboard = FRAME_KBOARD (f);
1181 single_kboard_state (); 1194 single_kboard = 1;
1182 record_unwind_protect (restore_kboard_configuration, 1195 record_unwind_protect (restore_kboard_configuration,
1183 (was_locked ? Qt : Qnil)); 1196 (was_locked ? Qt : Qnil));
1184 #endif 1197 #endif
1185 } 1198 }
1186 1199
1200 #if 0 /* This function is not needed anymore. */
1187 void 1201 void
1188 record_single_kboard_state () 1202 record_single_kboard_state ()
1189 { 1203 {
1190 if (single_kboard) 1204 if (single_kboard)
1191 push_kboard (current_kboard); 1205 push_kboard (current_kboard);
1192 record_unwind_protect (restore_kboard_configuration, 1206 record_unwind_protect (restore_kboard_configuration,
1193 (single_kboard ? Qt : Qnil)); 1207 (single_kboard ? Qt : Qnil));
1194 } 1208 }
1209 #endif
1195 1210
1196 static Lisp_Object 1211 static Lisp_Object
1197 restore_kboard_configuration (was_locked) 1212 restore_kboard_configuration (was_locked)
1198 Lisp_Object was_locked; 1213 Lisp_Object was_locked;
1199 { 1214 {
1200 if (NILP (was_locked)) 1215 if (NILP (was_locked))
1201 any_kboard_state (); 1216 single_kboard = 0;
1202 else 1217 else
1203 { 1218 {
1204 single_kboard_state (); 1219 struct kboard *prev = current_kboard;
1220 single_kboard = 1;
1205 pop_kboard (); 1221 pop_kboard ();
1222 /* The pop should not change the kboard. */
1223 if (single_kboard && current_kboard != prev)
1224 abort ();
1206 } 1225 }
1207 return Qnil; 1226 return Qnil;
1208 } 1227 }
1209 1228
1210 /* Handle errors that are not handled at inner levels 1229 /* Handle errors that are not handled at inner levels
1251 Vprint_length = old_length; 1270 Vprint_length = old_length;
1252 1271
1253 Vquit_flag = Qnil; 1272 Vquit_flag = Qnil;
1254 1273
1255 Vinhibit_quit = Qnil; 1274 Vinhibit_quit = Qnil;
1275 #if 0 /* This shouldn't be necessary anymore. --lorentey */
1256 #ifdef MULTI_KBOARD 1276 #ifdef MULTI_KBOARD
1257 if (command_loop_level == 0 && minibuf_level == 0) 1277 if (command_loop_level == 0 && minibuf_level == 0)
1258 any_kboard_state (); 1278 any_kboard_state ();
1279 #endif
1259 #endif 1280 #endif
1260 1281
1261 return make_number (0); 1282 return make_number (0);
1262 } 1283 }
1263 1284
1338 } 1359 }
1339 else 1360 else
1340 while (1) 1361 while (1)
1341 { 1362 {
1342 internal_catch (Qtop_level, top_level_1, Qnil); 1363 internal_catch (Qtop_level, top_level_1, Qnil);
1364 #if 0 /* This shouldn't be necessary anymore. --lorentey */
1343 /* Reset single_kboard in case top-level set it while 1365 /* Reset single_kboard in case top-level set it while
1344 evaluating an -f option, or we are stuck there for some 1366 evaluating an -f option, or we are stuck there for some
1345 other reason. */ 1367 other reason. */
1346 any_kboard_state (); 1368 any_kboard_state ();
1369 #endif
1347 internal_catch (Qtop_level, command_loop_2, Qnil); 1370 internal_catch (Qtop_level, command_loop_2, Qnil);
1348 executing_kbd_macro = Qnil; 1371 executing_kbd_macro = Qnil;
1349 1372
1350 /* End of file in -batch run causes exit here. */ 1373 /* End of file in -batch run causes exit here. */
1351 if (noninteractive) 1374 if (noninteractive)
1458 Lisp_Object keybuf[30]; 1481 Lisp_Object keybuf[30];
1459 int i; 1482 int i;
1460 int no_direct; 1483 int no_direct;
1461 int prev_modiff = 0; 1484 int prev_modiff = 0;
1462 struct buffer *prev_buffer = NULL; 1485 struct buffer *prev_buffer = NULL;
1486 #if 0 /* This shouldn't be necessary anymore. --lorentey */
1463 #ifdef MULTI_KBOARD 1487 #ifdef MULTI_KBOARD
1464 int was_locked = single_kboard; 1488 int was_locked = single_kboard;
1465 #endif 1489 #endif
1490 #endif
1466 int already_adjusted = 0; 1491 int already_adjusted = 0;
1467 1492
1468 current_kboard->Vprefix_arg = Qnil; 1493 current_kboard->Vprefix_arg = Qnil;
1469 current_kboard->Vlast_prefix_arg = Qnil; 1494 current_kboard->Vlast_prefix_arg = Qnil;
1470 Vdeactivate_mark = Qnil; 1495 Vdeactivate_mark = Qnil;
1917 /* Install chars successfully executed in kbd macro. */ 1942 /* Install chars successfully executed in kbd macro. */
1918 1943
1919 if (!NILP (current_kboard->defining_kbd_macro) 1944 if (!NILP (current_kboard->defining_kbd_macro)
1920 && NILP (current_kboard->Vprefix_arg)) 1945 && NILP (current_kboard->Vprefix_arg))
1921 finalize_kbd_macro_chars (); 1946 finalize_kbd_macro_chars ();
1922 1947 #if 0 /* This shouldn't be necessary anymore. --lorentey */
1923 #ifdef MULTI_KBOARD 1948 #ifdef MULTI_KBOARD
1924 if (!was_locked) 1949 if (!was_locked)
1925 any_kboard_state (); 1950 any_kboard_state ();
1951 #endif
1926 #endif 1952 #endif
1927 } 1953 }
1928 } 1954 }
1929 1955
1930 extern Lisp_Object Qcomposition, Qdisplay; 1956 extern Lisp_Object Qcomposition, Qdisplay;
2403 2429
2404 Lisp_Object print_help (); 2430 Lisp_Object print_help ();
2405 static Lisp_Object kbd_buffer_get_event (); 2431 static Lisp_Object kbd_buffer_get_event ();
2406 static void record_char (); 2432 static void record_char ();
2407 2433
2408 #ifdef MULTI_KBOARD
2409 static jmp_buf wrong_kboard_jmpbuf;
2410 #endif
2411
2412 #define STOP_POLLING \ 2434 #define STOP_POLLING \
2413 do { if (! polling_stopped_here) stop_polling (); \ 2435 do { if (! polling_stopped_here) stop_polling (); \
2414 polling_stopped_here = 1; } while (0) 2436 polling_stopped_here = 1; } while (0)
2415 2437
2416 #define RESUME_POLLING \ 2438 #define RESUME_POLLING \
2433 2455
2434 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1 2456 If USED_MOUSE_MENU is non-null, then we set *USED_MOUSE_MENU to 1
2435 if we used a mouse menu to read the input, or zero otherwise. If 2457 if we used a mouse menu to read the input, or zero otherwise. If
2436 USED_MOUSE_MENU is null, we don't dereference it. 2458 USED_MOUSE_MENU is null, we don't dereference it.
2437 2459
2460 WRONG_KBOARD_JMPBUF should be a stack context to longjmp to in case
2461 we find input on another keyboard.
2462
2438 Value is t if we showed a menu and the user rejected it. */ 2463 Value is t if we showed a menu and the user rejected it. */
2439 2464
2440 Lisp_Object 2465 Lisp_Object
2441 read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu) 2466 read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu, wrong_kboard_jmpbuf)
2442 int commandflag; 2467 int commandflag;
2443 int nmaps; 2468 int nmaps;
2444 Lisp_Object *maps; 2469 Lisp_Object *maps;
2445 Lisp_Object prev_event; 2470 Lisp_Object prev_event;
2446 int *used_mouse_menu; 2471 int *used_mouse_menu;
2472 jmp_buf *wrong_kboard_jmpbuf;
2447 { 2473 {
2448 volatile Lisp_Object c; 2474 volatile Lisp_Object c;
2449 int count; 2475 int count;
2450 jmp_buf local_getcjmp; 2476 jmp_buf local_getcjmp;
2451 jmp_buf save_jump; 2477 jmp_buf save_jump;
2454 volatile Lisp_Object previous_echo_area_message; 2480 volatile Lisp_Object previous_echo_area_message;
2455 volatile Lisp_Object also_record; 2481 volatile Lisp_Object also_record;
2456 volatile int reread; 2482 volatile int reread;
2457 struct gcpro gcpro1, gcpro2; 2483 struct gcpro gcpro1, gcpro2;
2458 int polling_stopped_here = 0; 2484 int polling_stopped_here = 0;
2485 struct kboard *orig_kboard = current_kboard;
2459 2486
2460 also_record = Qnil; 2487 also_record = Qnil;
2461 2488
2462 #if 0 /* This was commented out as part of fixing echo for C-u left. */ 2489 #if 0 /* This was commented out as part of fixing echo for C-u left. */
2463 before_command_key_count = this_command_key_count; 2490 before_command_key_count = this_command_key_count;
2709 kb->kbd_queue_has_data = 1; 2736 kb->kbd_queue_has_data = 1;
2710 current_kboard = kb; 2737 current_kboard = kb;
2711 /* This is going to exit from read_char 2738 /* This is going to exit from read_char
2712 so we had better get rid of this frame's stuff. */ 2739 so we had better get rid of this frame's stuff. */
2713 UNGCPRO; 2740 UNGCPRO;
2714 longjmp (wrong_kboard_jmpbuf, 1); 2741 if (wrong_kboard_jmpbuf == NULL)
2742 abort ();
2743 longjmp (*wrong_kboard_jmpbuf, 1);
2715 } 2744 }
2716 } 2745 }
2717 #endif 2746 #endif
2718 goto non_reread; 2747 goto non_reread;
2719 } 2748 }
2843 redisplay (); 2872 redisplay ();
2844 } 2873 }
2845 } 2874 }
2846 } 2875 }
2847 2876
2877 /* Notify the caller if a timer or sentinel or filter in the sit_for
2878 calls above have changed the current kboard. This could happen
2879 if they start a recursive edit, like the fancy splash screen in
2880 server.el's filter. If this longjmp wasn't here,
2881 read_key_sequence would interpret the next key sequence using the
2882 wrong translation tables and function keymaps. */
2883 if (NILP (c) && current_kboard != orig_kboard)
2884 {
2885 UNGCPRO;
2886 if (wrong_kboard_jmpbuf == NULL)
2887 abort ();
2888 longjmp (*wrong_kboard_jmpbuf, 1);
2889 }
2890
2848 /* If this has become non-nil here, it has been set by a timer 2891 /* If this has become non-nil here, it has been set by a timer
2849 or sentinel or filter. */ 2892 or sentinel or filter. */
2850 if (CONSP (Vunread_command_events)) 2893 if (CONSP (Vunread_command_events))
2851 { 2894 {
2852 c = XCAR (Vunread_command_events); 2895 c = XCAR (Vunread_command_events);
2891 { 2934 {
2892 current_kboard = kb; 2935 current_kboard = kb;
2893 /* This is going to exit from read_char 2936 /* This is going to exit from read_char
2894 so we had better get rid of this frame's stuff. */ 2937 so we had better get rid of this frame's stuff. */
2895 UNGCPRO; 2938 UNGCPRO;
2896 longjmp (wrong_kboard_jmpbuf, 1); 2939 if (wrong_kboard_jmpbuf == NULL)
2940 abort ();
2941 longjmp (*wrong_kboard_jmpbuf, 1);
2897 } 2942 }
2898 } 2943 }
2899 #endif 2944 #endif
2900 2945
2901 wrong_kboard: 2946 wrong_kboard:
2938 goto wrong_kboard; 2983 goto wrong_kboard;
2939 current_kboard = kb; 2984 current_kboard = kb;
2940 /* This is going to exit from read_char 2985 /* This is going to exit from read_char
2941 so we had better get rid of this frame's stuff. */ 2986 so we had better get rid of this frame's stuff. */
2942 UNGCPRO; 2987 UNGCPRO;
2943 longjmp (wrong_kboard_jmpbuf, 1); 2988 if (wrong_kboard_jmpbuf == NULL)
2989 abort ();
2990 longjmp (*wrong_kboard_jmpbuf, 1);
2944 } 2991 }
2945 #endif 2992 #endif
2946 } 2993 }
2947 2994
2948 /* Terminate Emacs in batch mode if at eof. */ 2995 /* Terminate Emacs in batch mode if at eof. */
2992 tem = access_keymap (get_keymap (Vspecial_event_map, 0, 1), c, 0, 0, 1); 3039 tem = access_keymap (get_keymap (Vspecial_event_map, 0, 1), c, 0, 0, 1);
2993 Vquit_flag = save; 3040 Vquit_flag = save;
2994 3041
2995 if (!NILP (tem)) 3042 if (!NILP (tem))
2996 { 3043 {
3044 #if 0 /* This shouldn't be necessary anymore. --lorentey */
2997 int was_locked = single_kboard; 3045 int was_locked = single_kboard;
2998 3046 int count = SPECPDL_INDEX ();
3047 record_single_kboard_state ();
3048 #endif
3049
2999 last_input_char = c; 3050 last_input_char = c;
3000 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt); 3051 Fcommand_execute (tem, Qnil, Fvector (1, &last_input_char), Qt);
3001 3052
3002 if (CONSP (c) && EQ (XCAR (c), Qselect_window)) 3053 if (CONSP (c) && EQ (XCAR (c), Qselect_window))
3003 /* We stopped being idle for this event; undo that. This 3054 /* We stopped being idle for this event; undo that. This
3004 prevents automatic window selection (under 3055 prevents automatic window selection (under
3005 mouse_autoselect_window from acting as a real input event, for 3056 mouse_autoselect_window from acting as a real input event, for
3006 example banishing the mouse under mouse-avoidance-mode. */ 3057 example banishing the mouse under mouse-avoidance-mode. */
3007 timer_resume_idle (); 3058 timer_resume_idle ();
3008 3059
3060 #if 0 /* This shouldn't be necessary anymore. --lorentey */
3009 /* Resume allowing input from any kboard, if that was true before. */ 3061 /* Resume allowing input from any kboard, if that was true before. */
3010 if (!was_locked) 3062 if (!was_locked)
3011 any_kboard_state (); 3063 any_kboard_state ();
3064 unbind_to (count, Qnil);
3065 #endif
3012 3066
3013 goto retry; 3067 goto retry;
3014 } 3068 }
3015 3069
3016 /* Handle things that only apply to characters. */ 3070 /* Handle things that only apply to characters. */
3249 if (STRINGP (tem0)) 3303 if (STRINGP (tem0))
3250 internal_with_output_to_temp_buffer ("*Help*", print_help, tem0); 3304 internal_with_output_to_temp_buffer ("*Help*", print_help, tem0);
3251 3305
3252 cancel_echoing (); 3306 cancel_echoing ();
3253 do 3307 do
3254 c = read_char (0, 0, 0, Qnil, 0); 3308 c = read_char (0, 0, 0, Qnil, 0, &wrong_kboard_jmpbuf);
3255 while (BUFFERP (c)); 3309 while (BUFFERP (c));
3256 /* Remove the help from the frame */ 3310 /* Remove the help from the frame */
3257 unbind_to (count, Qnil); 3311 unbind_to (count, Qnil);
3258 3312
3259 redisplay (); 3313 redisplay ();
3260 if (EQ (c, make_number (040))) 3314 if (EQ (c, make_number (040)))
3261 { 3315 {
3262 cancel_echoing (); 3316 cancel_echoing ();
3263 do 3317 do
3264 c = read_char (0, 0, 0, Qnil, 0); 3318 c = read_char (0, 0, 0, Qnil, 0, &wrong_kboard_jmpbuf);
3265 while (BUFFERP (c)); 3319 while (BUFFERP (c));
3266 } 3320 }
3267 } 3321 }
3268 3322
3269 exit: 3323 exit:
4520 if (NILP (vector[0])) 4574 if (NILP (vector[0]))
4521 { 4575 {
4522 int count = SPECPDL_INDEX (); 4576 int count = SPECPDL_INDEX ();
4523 Lisp_Object old_deactivate_mark = Vdeactivate_mark; 4577 Lisp_Object old_deactivate_mark = Vdeactivate_mark;
4524 4578
4579 #if 0 /* This shouldn't be necessary anymore. --lorentey */
4525 /* On unbind_to, resume allowing input from any kboard, if that 4580 /* On unbind_to, resume allowing input from any kboard, if that
4526 was true before. */ 4581 was true before. */
4527 record_single_kboard_state (); 4582 record_single_kboard_state ();
4528 4583 #endif
4529 /* Mark the timer as triggered to prevent problems if the lisp 4584 /* Mark the timer as triggered to prevent problems if the lisp
4530 code fails to reschedule it right. */ 4585 code fails to reschedule it right. */
4531 vector[0] = Qt; 4586 vector[0] = Qt;
4532 4587
4533 specbind (Qinhibit_quit, Qt); 4588 specbind (Qinhibit_quit, Qt);
8737 8792
8738 #if defined (GOBBLE_FIRST_EVENT) 8793 #if defined (GOBBLE_FIRST_EVENT)
8739 int junk; 8794 int junk;
8740 #endif 8795 #endif
8741 8796
8797 jmp_buf *volatile wrong_kboard_jmpbuf = alloca (sizeof (jmp_buf));
8798
8742 struct gcpro gcpro1; 8799 struct gcpro gcpro1;
8743 8800
8744 GCPRO1 (fake_prefixed_keys); 8801 GCPRO1 (fake_prefixed_keys);
8745 raw_keybuf_count = 0; 8802 raw_keybuf_count = 0;
8746 8803
8773 this work right. */ 8830 this work right. */
8774 8831
8775 /* Read the first char of the sequence specially, before setting 8832 /* Read the first char of the sequence specially, before setting
8776 up any keymaps, in case a filter runs and switches buffers on us. */ 8833 up any keymaps, in case a filter runs and switches buffers on us. */
8777 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event, 8834 first_event = read_char (NILP (prompt), 0, submaps, last_nonmenu_event,
8778 &junk); 8835 &junk, NULL);
8779 #endif /* GOBBLE_FIRST_EVENT */ 8836 #endif /* GOBBLE_FIRST_EVENT */
8780 8837
8781 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map); 8838 orig_local_map = get_local_map (PT, current_buffer, Qlocal_map);
8782 orig_keymap = get_local_map (PT, current_buffer, Qkeymap); 8839 orig_keymap = get_local_map (PT, current_buffer, Qkeymap);
8783 from_string = Qnil; 8840 from_string = Qnil;
8949 { 9006 {
8950 { 9007 {
8951 #ifdef MULTI_KBOARD 9008 #ifdef MULTI_KBOARD
8952 KBOARD *interrupted_kboard = current_kboard; 9009 KBOARD *interrupted_kboard = current_kboard;
8953 struct frame *interrupted_frame = SELECTED_FRAME (); 9010 struct frame *interrupted_frame = SELECTED_FRAME ();
8954 if (setjmp (wrong_kboard_jmpbuf)) 9011 if (setjmp (*wrong_kboard_jmpbuf))
8955 { 9012 {
9013 int found = 0;
9014 struct kboard *k;
9015
9016 for (k = all_kboards; k; k = k->next_kboard)
9017 if (k == interrupted_kboard)
9018 found = 1;
9019 if (!found)
9020 abort ();
9021
8956 if (!NILP (delayed_switch_frame)) 9022 if (!NILP (delayed_switch_frame))
8957 { 9023 {
8958 interrupted_kboard->kbd_queue 9024 interrupted_kboard->kbd_queue
8959 = Fcons (delayed_switch_frame, 9025 = Fcons (delayed_switch_frame,
8960 interrupted_kboard->kbd_queue); 9026 interrupted_kboard->kbd_queue);
8984 goto replay_sequence; 9050 goto replay_sequence;
8985 } 9051 }
8986 #endif 9052 #endif
8987 key = read_char (NILP (prompt), nmaps, 9053 key = read_char (NILP (prompt), nmaps,
8988 (Lisp_Object *) submaps, last_nonmenu_event, 9054 (Lisp_Object *) submaps, last_nonmenu_event,
8989 &used_mouse_menu); 9055 &used_mouse_menu, wrong_kboard_jmpbuf);
8990 } 9056 }
8991 9057
8992 /* read_char returns t when it shows a menu and the user rejects it. 9058 /* read_char returns t when it shows a menu and the user rejects it.
8993 Just return -1. */ 9059 Just return -1. */
8994 if (EQ (key, Qt)) 9060 if (EQ (key, Qt))
10464 terminal = get_named_tty (NULL); 10530 terminal = get_named_tty (NULL);
10465 if (!terminal) 10531 if (!terminal)
10466 { 10532 {
10467 /* If there are no frames there, let's pretend that we are a 10533 /* If there are no frames there, let's pretend that we are a
10468 well-behaving UN*X program and quit. */ 10534 well-behaving UN*X program and quit. */
10469 fatal_error_signal (SIGTERM); 10535 Fkill_emacs (Qnil);
10470 } 10536 }
10471 else 10537 else
10472 { 10538 {
10473 /* Otherwise, the SIGINT was probably generated by C-g. */ 10539 /* Otherwise, the SIGINT was probably generated by C-g. */
10474 10540
11032 /* Prevent a dangling reference to KB. */ 11098 /* Prevent a dangling reference to KB. */
11033 if (kb == current_kboard 11099 if (kb == current_kboard
11034 && FRAMEP (selected_frame) 11100 && FRAMEP (selected_frame)
11035 && FRAME_LIVE_P (XFRAME (selected_frame))) 11101 && FRAME_LIVE_P (XFRAME (selected_frame)))
11036 { 11102 {
11037 current_kboard = XFRAME (selected_frame)->terminal->kboard; 11103 current_kboard = FRAME_KBOARD (XFRAME (selected_frame));
11104 single_kboard = 0;
11038 if (current_kboard == kb) 11105 if (current_kboard == kb)
11039 abort (); 11106 abort ();
11040 } 11107 }
11041 11108
11042 wipe_kboard (kb); 11109 wipe_kboard (kb);