aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-04-24 21:50:39 +0000
committerRichard M. Stallman1995-04-24 21:50:39 +0000
commit0bc3db2b9dba8fe1b8f28ab3d3e2aaf754d01e54 (patch)
treea7deddca634d758646de097180909c7bbd9aaef4
parentf8307c0cacae98a9072f48649c3fda886d213a05 (diff)
downloademacs-0bc3db2b9dba8fe1b8f28ab3d3e2aaf754d01e54.tar.gz
emacs-0bc3db2b9dba8fe1b8f28ab3d3e2aaf754d01e54.zip
(safe_run_hooks_1, safe_run_hooks_error): New subroutines.
(safe_run_hooks): Handle errors to clear the hook, instead of always clearing it temporarily.
-rw-r--r--src/keyboard.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 623ea4efd19..de23b958568 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1401,23 +1401,37 @@ command_loop_1 ()
1401 } 1401 }
1402} 1402}
1403 1403
1404/* Subroutine for safe_run_hooks: run the hook HOOK. */
1405
1406static Lisp_Object
1407safe_run_hooks_1 (hook)
1408 Lisp_Object hook;
1409{
1410 return call1 (Vrun_hooks, Vinhibit_quit);
1411}
1412
1413/* Subroutine for safe_run_hooks: handle an error by clearing out the hook. */
1414
1415static Lisp_Object
1416safe_run_hooks_error (data)
1417 Lisp_Object data;
1418{
1419 Fset (Vinhibit_quit, Qnil);
1420}
1421
1404/* If we get an error while running the hook, cause the hook variable 1422/* If we get an error while running the hook, cause the hook variable
1405 to be nil. Also inhibit quits, so that C-g won't cause the hook 1423 to be nil. Also inhibit quits, so that C-g won't cause the hook
1406 to mysteriously evaporate. */ 1424 to mysteriously evaporate. */
1425
1407static void 1426static void
1408safe_run_hooks (hook) 1427safe_run_hooks (hook)
1409 Lisp_Object hook; 1428 Lisp_Object hook;
1410{ 1429{
1411 Lisp_Object value; 1430 Lisp_Object value;
1412 int count = specpdl_ptr - specpdl; 1431 int count = specpdl_ptr - specpdl;
1413 specbind (Qinhibit_quit, Qt); 1432 specbind (Qinhibit_quit, hook);
1414 1433
1415 /* We read and set the variable with functions, 1434 internal_condition_case (safe_run_hooks_1, Qerror, safe_run_hooks_error);
1416 in case it's buffer-local. */
1417 value = Vcommand_hook_internal = Fsymbol_value (hook);
1418 Fset (hook, Qnil);
1419 call1 (Vrun_hooks, Qcommand_hook_internal);
1420 Fset (hook, value);
1421 1435
1422 unbind_to (count, Qnil); 1436 unbind_to (count, Qnil);
1423} 1437}