summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1994-05-10 05:48:20 +0000
committerKarl Heuer <kwzh@gnu.org>1994-05-10 05:48:20 +0000
commit1c9784c9c2a9a7ac1b1746791b6fd9b72511c58e (patch)
tree9bbca27eb2a68de0bf2373782cde4fd7d76d146b /src
parent8001d352f6cc9029a414776df01f088eb6d21ea0 (diff)
downloademacs-1c9784c9c2a9a7ac1b1746791b6fd9b72511c58e.tar.gz
(safe_run_hooks): New function, extracted from command_loop_1. Bind
inhibit_quit.
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 0d9e86d1e53..2cfc6895977 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -900,6 +900,7 @@ DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 0,
Lisp_Object Fcommand_execute ();
static int read_key_sequence ();
+static void safe_run_hooks ();
Lisp_Object
command_loop_1 ()
@@ -926,16 +927,7 @@ command_loop_1 ()
/* Make sure this hook runs after commands that get errors and
throw to top level. */
if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
- {
- /* If we get an error during the post-command-hook,
- cause post-command-hook to be nil. */
- Vcommand_hook_internal = Vpost_command_hook;
- Vpost_command_hook = Qnil;
-
- call1 (Vrun_hooks, Qcommand_hook_internal);
-
- Vpost_command_hook = Vcommand_hook_internal;
- }
+ safe_run_hooks (&Vpost_command_hook);
/* Do this after running Vpost_command_hook, for consistency. */
last_command = this_command;
@@ -1057,16 +1049,7 @@ command_loop_1 ()
this_command = cmd;
if (!NILP (Vpre_command_hook) && !NILP (Vrun_hooks))
- {
- /* If we get an error during the pre-command-hook,
- cause pre-command-hook to be nil. */
- Vcommand_hook_internal = Vpre_command_hook;
- Vpre_command_hook = Qnil;
-
- call1 (Vrun_hooks, Qcommand_hook_internal);
-
- Vpre_command_hook = Vcommand_hook_internal;
- }
+ safe_run_hooks (&Vpre_command_hook);
if (NILP (this_command))
{
@@ -1194,16 +1177,7 @@ command_loop_1 ()
directly_done: ;
if (!NILP (Vpost_command_hook) && !NILP (Vrun_hooks))
- {
- /* If we get an error during the post-command-hook,
- cause post-command-hook to be nil. */
- Vcommand_hook_internal = Vpost_command_hook;
- Vpost_command_hook = Qnil;
-
- call1 (Vrun_hooks, Qcommand_hook_internal);
-
- Vpost_command_hook = Vcommand_hook_internal;
- }
+ safe_run_hooks (&Vpost_command_hook);
/* If there is a prefix argument,
1) We don't want last_command to be ``universal-argument''
@@ -1233,6 +1207,24 @@ command_loop_1 ()
}
}
}
+
+/* If we get an error while running the hook, cause the hook variable
+ to be nil. Also inhibit quits, so that C-g won't cause the hook
+ to mysteriously evaporate. */
+static void
+safe_run_hooks (hook)
+ Lisp_Object *hook;
+{
+ int count = specpdl_ptr - specpdl;
+ specbind (Qinhibit_quit, Qt);
+
+ Vcommand_hook_internal = *hook;
+ *hook = Qnil;
+ call1 (Vrun_hooks, Qcommand_hook_internal);
+ *hook = Vcommand_hook_internal;
+
+ unbind_to (count, Qnil);
+}
/* Number of seconds between polling for input. */
int polling_period;