diff options
| author | Richard M. Stallman | 1995-04-24 21:50:39 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-04-24 21:50:39 +0000 |
| commit | 0bc3db2b9dba8fe1b8f28ab3d3e2aaf754d01e54 (patch) | |
| tree | a7deddca634d758646de097180909c7bbd9aaef4 /src/keyboard.c | |
| parent | f8307c0cacae98a9072f48649c3fda886d213a05 (diff) | |
| download | emacs-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.
Diffstat (limited to 'src/keyboard.c')
| -rw-r--r-- | src/keyboard.c | 30 |
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 | |||
| 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 | } |