comparison src/keyboard.c @ 10626:616345f74278

(cmd_error): Clear prefix arg here. (command_loop_1): Not here. (command_loop_1): Save original perdisplay in case we're already locked to a particular display. Move display-specific cleanup to end of main loop. Use perdisplay to access prefix arg. (Fcommand_execute, Fexecute_extended_command): Use perdisplay.
author Karl Heuer <kwzh@gnu.org>
date Wed, 01 Feb 1995 22:18:21 +0000
parents 05a3cfc7a5ba
children c807d6c947de
comparison
equal deleted inserted replaced
10625:4d93473e25b9 10626:616345f74278
703 Lisp_Object data; 703 Lisp_Object data;
704 { 704 {
705 Vstandard_output = Qt; 705 Vstandard_output = Qt;
706 Vstandard_input = Qt; 706 Vstandard_input = Qt;
707 Vexecuting_macro = Qnil; 707 Vexecuting_macro = Qnil;
708 if (!current_perdisplay)
709 abort ();
710 current_perdisplay->Vprefix_arg = Qnil;
708 cmd_error_internal (data, 0); 711 cmd_error_internal (data, 0);
709 712
710 Vquit_flag = Qnil; 713 Vquit_flag = Qnil;
711 714
712 Vinhibit_quit = Qnil; 715 Vinhibit_quit = Qnil;
716 #ifdef MULTI_PERDISPLAY
717 current_perdisplay = 0;
718 #endif
713 719
714 return make_number (0); 720 return make_number (0);
715 } 721 }
716 722
717 cmd_error_internal (data, context) 723 cmd_error_internal (data, context)
905 int i; 911 int i;
906 int no_redisplay; 912 int no_redisplay;
907 int no_direct; 913 int no_direct;
908 int prev_modiff; 914 int prev_modiff;
909 struct buffer *prev_buffer; 915 struct buffer *prev_buffer;
910 916 PERDISPLAY *global_perdisplay = current_perdisplay;
911 Vprefix_arg = Qnil; 917
912 Vdeactivate_mark = Qnil; 918 Vdeactivate_mark = Qnil;
913 waiting_for_input = 0; 919 waiting_for_input = 0;
914 cancel_echoing (); 920 cancel_echoing ();
915 921
916 nonundocount = 0; 922 nonundocount = 0;
930 /* Do this after running Vpost_command_hook, for consistency. */ 936 /* Do this after running Vpost_command_hook, for consistency. */
931 last_command = this_command; 937 last_command = this_command;
932 938
933 while (1) 939 while (1)
934 { 940 {
935 /* Install chars successfully executed in kbd macro. */
936
937 if (defining_kbd_macro && NILP (Vprefix_arg))
938 finalize_kbd_macro_chars ();
939
940 /* Make sure the current window's buffer is selected. */ 941 /* Make sure the current window's buffer is selected. */
941 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer) 942 if (XBUFFER (XWINDOW (selected_window)->buffer) != current_buffer)
942 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer)); 943 set_buffer_internal (XBUFFER (XWINDOW (selected_window)->buffer));
943 944
944 /* Display any malloc warning that just came out. Use while because 945 /* Display any malloc warning that just came out. Use while because
971 Vunread_command_events = Fcons (make_number (quit_char), Qnil); 972 Vunread_command_events = Fcons (make_number (quit_char), Qnil);
972 } 973 }
973 } 974 }
974 975
975 #ifdef C_ALLOCA 976 #ifdef C_ALLOCA
976 alloca (0); /* Cause a garbage collection now */ 977 alloca (0); /* Cause a garbage collection now */
977 /* Since we can free the most stuff here. */ 978 /* Since we can free the most stuff here. */
978 #endif /* C_ALLOCA */ 979 #endif /* C_ALLOCA */
979 980
980 #if 0 981 #if 0
981 #ifdef MULTI_FRAME 982 #ifdef MULTI_FRAME
993 if (! NILP (Vlucid_menu_bar_dirty_flag) 994 if (! NILP (Vlucid_menu_bar_dirty_flag)
994 && !NILP (Ffboundp (Qrecompute_lucid_menubar))) 995 && !NILP (Ffboundp (Qrecompute_lucid_menubar)))
995 call0 (Qrecompute_lucid_menubar); 996 call0 (Qrecompute_lucid_menubar);
996 997
997 /* Read next key sequence; i gets its length. */ 998 /* Read next key sequence; i gets its length. */
998 i = read_key_sequence (keybuf, (sizeof keybuf / sizeof (keybuf[0])), Qnil, 0); 999 i = read_key_sequence (keybuf, sizeof keybuf / sizeof keybuf[0], Qnil, 0);
999 1000
1000 ++num_input_keys; 1001 ++num_input_keys;
1001 1002
1002 /* Now we have read a key sequence of length I, 1003 /* Now we have read a key sequence of length I,
1003 or else I is 0 and we found end of file. */ 1004 or else I is 0 and we found end of file. */
1008 Just loop around and read another command. */ 1009 Just loop around and read another command. */
1009 if (i == -1) 1010 if (i == -1)
1010 { 1011 {
1011 cancel_echoing (); 1012 cancel_echoing ();
1012 this_command_key_count = 0; 1013 this_command_key_count = 0;
1013 continue; 1014 goto finalize;
1014 } 1015 }
1015 1016
1016 last_command_char = keybuf[i - 1]; 1017 last_command_char = keybuf[i - 1];
1017 1018
1018 /* If the previous command tried to force a specific window-start, 1019 /* If the previous command tried to force a specific window-start,
1055 { 1056 {
1056 /* nil means key is undefined. */ 1057 /* nil means key is undefined. */
1057 bitch_at_user (); 1058 bitch_at_user ();
1058 defining_kbd_macro = 0; 1059 defining_kbd_macro = 0;
1059 update_mode_lines = 1; 1060 update_mode_lines = 1;
1060 Vprefix_arg = Qnil; 1061 current_perdisplay->Vprefix_arg = Qnil;
1061 1062
1062 } 1063 }
1063 else 1064 else
1064 { 1065 {
1065 if (NILP (Vprefix_arg) && ! no_direct) 1066 if (NILP (current_perdisplay->Vprefix_arg) && ! no_direct)
1066 { 1067 {
1067 /* Recognize some common commands in common situations and 1068 /* Recognize some common commands in common situations and
1068 do them directly. */ 1069 do them directly. */
1069 if (EQ (this_command, Qforward_char) && PT < ZV) 1070 if (EQ (this_command, Qforward_char) && PT < ZV)
1070 { 1071 {
1183 } 1184 }
1184 1185
1185 /* Here for a command that isn't executed directly */ 1186 /* Here for a command that isn't executed directly */
1186 1187
1187 nonundocount = 0; 1188 nonundocount = 0;
1188 if (NILP (Vprefix_arg)) 1189 if (NILP (current_perdisplay->Vprefix_arg))
1189 Fundo_boundary (); 1190 Fundo_boundary ();
1190 Fcommand_execute (this_command, Qnil); 1191 Fcommand_execute (this_command, Qnil);
1191 1192
1192 } 1193 }
1193 directly_done: ; 1194 directly_done: ;
1207 echoed as part of this key sequence, so don't call 1208 echoed as part of this key sequence, so don't call
1208 cancel_echoing, and 1209 cancel_echoing, and
1209 3) we want to leave this_command_key_count non-zero, so that 1210 3) we want to leave this_command_key_count non-zero, so that
1210 read_char will realize that it is re-reading a character, and 1211 read_char will realize that it is re-reading a character, and
1211 not echo it a second time. */ 1212 not echo it a second time. */
1212 if (NILP (Vprefix_arg)) 1213 if (NILP (current_perdisplay->Vprefix_arg))
1213 { 1214 {
1214 last_command = this_command; 1215 last_command = this_command;
1215 cancel_echoing (); 1216 cancel_echoing ();
1216 this_command_key_count = 0; 1217 this_command_key_count = 0;
1217 } 1218 }
1224 call1 (Vrun_hooks, intern ("deactivate-mark-hook")); 1225 call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
1225 } 1226 }
1226 else if (current_buffer != prev_buffer || MODIFF != prev_modiff) 1227 else if (current_buffer != prev_buffer || MODIFF != prev_modiff)
1227 call1 (Vrun_hooks, intern ("activate-mark-hook")); 1228 call1 (Vrun_hooks, intern ("activate-mark-hook"));
1228 } 1229 }
1230
1231 finalize:
1232 /* Install chars successfully executed in kbd macro. */
1233
1234 if (defining_kbd_macro && NILP (current_perdisplay->Vprefix_arg))
1235 finalize_kbd_macro_chars ();
1236
1237 #ifdef MULTI_PERDISPLAY
1238 current_perdisplay = global_perdisplay;
1239 #endif
1229 } 1240 }
1230 } 1241 }
1231 1242
1232 /* If we get an error while running the hook, cause the hook variable 1243 /* If we get an error while running the hook, cause the hook variable
1233 to be nil. Also inhibit quits, so that C-g won't cause the hook 1244 to be nil. Also inhibit quits, so that C-g won't cause the hook
5412 register Lisp_Object tem; 5423 register Lisp_Object tem;
5413 Lisp_Object prefixarg; 5424 Lisp_Object prefixarg;
5414 struct backtrace backtrace; 5425 struct backtrace backtrace;
5415 extern int debug_on_next_call; 5426 extern int debug_on_next_call;
5416 5427
5417 prefixarg = Vprefix_arg, Vprefix_arg = Qnil; 5428 prefixarg = current_perdisplay->Vprefix_arg;
5418 Vcurrent_prefix_arg = prefixarg; 5429 current_perdisplay->Vprefix_arg = Qnil;
5430 current_perdisplay->Vcurrent_prefix_arg = prefixarg;
5419 debug_on_next_call = 0; 5431 debug_on_next_call = 0;
5420 5432
5421 if (SYMBOLP (cmd)) 5433 if (SYMBOLP (cmd))
5422 { 5434 {
5423 tem = Fget (cmd, Qdisabled); 5435 tem = Fget (cmd, Qdisabled);
5529 } 5541 }
5530 5542
5531 UNGCPRO; 5543 UNGCPRO;
5532 5544
5533 function = Fintern (function, Qnil); 5545 function = Fintern (function, Qnil);
5534 Vprefix_arg = prefixarg; 5546 current_perdisplay->Vprefix_arg = prefixarg;
5535 this_command = function; 5547 this_command = function;
5536 5548
5537 return Fcommand_execute (function, Qt); 5549 return Fcommand_execute (function, Qt);
5538 } 5550 }
5539 5551