Mercurial > emacs
comparison src/keyboard.c @ 8076:3a35434b19d2
(safe_run_hooks): Take symbol as arg.
Use Fsymbol_value and Fset.
(command_loop_1): Pass symbol to safe_run_hooks.
Look in the value cell to check for trivial case (no hooks).
(read_key_sequence): Don't echo if echo_keystrokes is 0.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 28 Jun 1994 17:02:40 +0000 |
parents | 1aaf0461446d |
children | df2986993482 |
comparison
equal
deleted
inserted
replaced
8075:b546fa7e9911 | 8076:3a35434b19d2 |
---|---|
950 no_redisplay = 0; | 950 no_redisplay = 0; |
951 this_command_key_count = 0; | 951 this_command_key_count = 0; |
952 | 952 |
953 /* Make sure this hook runs after commands that get errors and | 953 /* Make sure this hook runs after commands that get errors and |
954 throw to top level. */ | 954 throw to top level. */ |
955 if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks)) | 955 /* Note that the value cell will never directly contain nil |
956 safe_run_hooks (&Vpost_command_hook); | 956 if the symbol is a local variable. */ |
957 if (!NILP (XSYMBOL (Qpost_command_hook)->value) && !NILP (Vrun_hooks)) | |
958 safe_run_hooks (Qpost_command_hook); | |
957 | 959 |
958 /* Do this after running Vpost_command_hook, for consistency. */ | 960 /* Do this after running Vpost_command_hook, for consistency. */ |
959 last_command = this_command; | 961 last_command = this_command; |
960 | 962 |
961 while (1) | 963 while (1) |
1072 XSET (last_point_position_buffer, Lisp_Buffer, prev_buffer); | 1074 XSET (last_point_position_buffer, Lisp_Buffer, prev_buffer); |
1073 | 1075 |
1074 /* Execute the command. */ | 1076 /* Execute the command. */ |
1075 | 1077 |
1076 this_command = cmd; | 1078 this_command = cmd; |
1077 if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks)) | 1079 /* Note that the value cell will never directly contain nil |
1078 safe_run_hooks (&Vpre_command_hook); | 1080 if the symbol is a local variable. */ |
1081 if (!NILP (XSYMBOL (Qpre_command_hook)->value) && !NILP (Vrun_hooks)) | |
1082 safe_run_hooks (Qpre_command_hook); | |
1079 | 1083 |
1080 if (NILP (this_command)) | 1084 if (NILP (this_command)) |
1081 { | 1085 { |
1082 /* nil means key is undefined. */ | 1086 /* nil means key is undefined. */ |
1083 bitch_at_user (); | 1087 bitch_at_user (); |
1209 Fcommand_execute (this_command, Qnil); | 1213 Fcommand_execute (this_command, Qnil); |
1210 | 1214 |
1211 } | 1215 } |
1212 directly_done: ; | 1216 directly_done: ; |
1213 | 1217 |
1214 if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks)) | 1218 /* Note that the value cell will never directly contain nil |
1215 safe_run_hooks (&Vpost_command_hook); | 1219 if the symbol is a local variable. */ |
1220 if (!NILP (XSYMBOL (Qpost_command_hook)->value) && !NILP (Vrun_hooks)) | |
1221 safe_run_hooks (Qpost_command_hook); | |
1216 | 1222 |
1217 /* If there is a prefix argument, | 1223 /* If there is a prefix argument, |
1218 1) We don't want last_command to be ``universal-argument'' | 1224 1) We don't want last_command to be ``universal-argument'' |
1219 (that would be dumb), so don't set last_command, | 1225 (that would be dumb), so don't set last_command, |
1220 2) we want to leave echoing on so that the prefix will be | 1226 2) we want to leave echoing on so that the prefix will be |
1246 /* If we get an error while running the hook, cause the hook variable | 1252 /* If we get an error while running the hook, cause the hook variable |
1247 to be nil. Also inhibit quits, so that C-g won't cause the hook | 1253 to be nil. Also inhibit quits, so that C-g won't cause the hook |
1248 to mysteriously evaporate. */ | 1254 to mysteriously evaporate. */ |
1249 static void | 1255 static void |
1250 safe_run_hooks (hook) | 1256 safe_run_hooks (hook) |
1251 Lisp_Object *hook; | 1257 Lisp_Object hook; |
1252 { | 1258 { |
1253 int count = specpdl_ptr - specpdl; | 1259 int count = specpdl_ptr - specpdl; |
1254 specbind (Qinhibit_quit, Qt); | 1260 specbind (Qinhibit_quit, Qt); |
1255 | 1261 |
1256 Vcommand_hook_internal = *hook; | 1262 /* We read and set the variable with functions, |
1257 *hook = Qnil; | 1263 in case it's buffer-local. */ |
1264 Vcommand_hook_internal = Fsymbol_value (hook); | |
1265 Fset (hook, Qnil); | |
1258 call1 (Vrun_hooks, Qcommand_hook_internal); | 1266 call1 (Vrun_hooks, Qcommand_hook_internal); |
1259 *hook = Vcommand_hook_internal; | 1267 Fset (hook, Vcommand_hook_internal); |
1260 | 1268 |
1261 unbind_to (count, Qnil); | 1269 unbind_to (count, Qnil); |
1262 } | 1270 } |
1263 | 1271 |
1264 /* Number of seconds between polling for input. */ | 1272 /* Number of seconds between polling for input. */ |
4404 | 4412 |
4405 if (INTERACTIVE) | 4413 if (INTERACTIVE) |
4406 { | 4414 { |
4407 if (!NILP (prompt)) | 4415 if (!NILP (prompt)) |
4408 echo_prompt (XSTRING (prompt)->data); | 4416 echo_prompt (XSTRING (prompt)->data); |
4409 else if (cursor_in_echo_area) | 4417 else if (cursor_in_echo_area && echo_keystrokes) |
4410 /* This doesn't put in a dash if the echo buffer is empty, so | 4418 /* This doesn't put in a dash if the echo buffer is empty, so |
4411 you don't always see a dash hanging out in the minibuffer. */ | 4419 you don't always see a dash hanging out in the minibuffer. */ |
4412 echo_dash (); | 4420 echo_dash (); |
4413 } | 4421 } |
4414 | 4422 |
4549 /* Does mock_input indicate that we are re-reading a key sequence? */ | 4557 /* Does mock_input indicate that we are re-reading a key sequence? */ |
4550 if (t < mock_input) | 4558 if (t < mock_input) |
4551 { | 4559 { |
4552 key = keybuf[t]; | 4560 key = keybuf[t]; |
4553 add_command_key (key); | 4561 add_command_key (key); |
4554 echo_char (key); | 4562 if (echo_keystrokes) |
4563 echo_char (key); | |
4555 } | 4564 } |
4556 | 4565 |
4557 /* If not, we should actually read a character. */ | 4566 /* If not, we should actually read a character. */ |
4558 else | 4567 else |
4559 { | 4568 { |
5085 read-key-sequence will always return a logical unit. | 5094 read-key-sequence will always return a logical unit. |
5086 | 5095 |
5087 Better ideas? */ | 5096 Better ideas? */ |
5088 for (; t < mock_input; t++) | 5097 for (; t < mock_input; t++) |
5089 { | 5098 { |
5090 echo_char (keybuf[t]); | 5099 if (echo_keystrokes) |
5100 echo_char (keybuf[t]); | |
5091 add_command_key (keybuf[t]); | 5101 add_command_key (keybuf[t]); |
5092 } | 5102 } |
5093 | 5103 |
5094 return t; | 5104 return t; |
5095 } | 5105 } |