Mercurial > emacs
comparison src/keyboard.c @ 11540:b8b8a11a1aed
(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.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 24 Apr 1995 21:50:39 +0000 |
parents | 6b9693d102b0 |
children | 317e5825008b |
comparison
equal
deleted
inserted
replaced
11539:d8227796a997 | 11540:b8b8a11a1aed |
---|---|
1399 any_kboard_state (); | 1399 any_kboard_state (); |
1400 #endif | 1400 #endif |
1401 } | 1401 } |
1402 } | 1402 } |
1403 | 1403 |
1404 /* Subroutine for safe_run_hooks: run the hook HOOK. */ | |
1405 | |
1406 static Lisp_Object | |
1407 safe_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 | |
1415 static Lisp_Object | |
1416 safe_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 | |
1407 static void | 1426 static void |
1408 safe_run_hooks (hook) | 1427 safe_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 } |
1424 | 1438 |
1425 /* Number of seconds between polling for input. */ | 1439 /* Number of seconds between polling for input. */ |