Commit f045dbe6 authored by Dmitry Antipov's avatar Dmitry Antipov

* keyboard.c (safe_run_hook_funcall): Avoid consing around

Vinhibit_quit and prefer internal_condition_case_n to pass args.
(safe_run_hooks_error, safe_run_hooks_1): Adjust accordingly.
(safe_run_hooks): Remove comment which is not relevant any more.
parent 8d2f1984
2014-08-04 Dmitry Antipov <dmantipov@yandex.ru>
* keyboard.c (safe_run_hook_funcall): Avoid consing around
Vinhibit_quit and prefer internal_condition_case_n to pass args.
(safe_run_hooks_error, safe_run_hooks_1): Adjust accordingly.
(safe_run_hooks): Remove comment which is not relevant any more.
2014-08-03 Paul Eggert <eggert@cs.ucla.edu>
Don't let big frames overrun the stack.
......
......@@ -1852,30 +1852,32 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
}
}
/* Subroutine for safe_run_hooks: run the hook HOOK. */
/* Subroutine for safe_run_hooks: run the hook, which is ARGS[1]. */
static Lisp_Object
safe_run_hooks_1 (void)
safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args)
{
eassert (CONSP (Vinhibit_quit));
return call0 (XCDR (Vinhibit_quit));
eassert (nargs == 2);
return call0 (args[1]);
}
/* Subroutine for safe_run_hooks: handle an error by clearing out the function
from the hook. */
static Lisp_Object
safe_run_hooks_error (Lisp_Object error_data)
{
Lisp_Object hook
= CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit;
Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil;
Lisp_Object args[4];
args[0] = build_string ("Error in %s (%S): %S");
args[1] = hook;
args[2] = fun;
args[3] = error_data;
Fmessage (4, args);
safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object hook, fun, msgargs[4];
eassert (nargs == 2);
hook = args[0];
fun = args[1];
msgargs[0] = build_string ("Error in %s (%S): %S");
msgargs[1] = hook;
msgargs[2] = fun;
msgargs[3] = error;
Fmessage (4, msgargs);
if (SYMBOLP (hook))
{
Lisp_Object val;
......@@ -1907,14 +1909,19 @@ safe_run_hooks_error (Lisp_Object error_data)
static Lisp_Object
safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
{
Lisp_Object iargs[2];
struct gcpro gcpro1;
eassert (nargs == 1);
if (CONSP (Vinhibit_quit))
XSETCDR (Vinhibit_quit, args[0]);
else
Vinhibit_quit = Fcons (Vinhibit_quit, args[0]);
iargs[0] = Vinhibit_quit;
iargs[1] = args[0];
internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error);
return Qnil;
GCPRO1 (*iargs);
gcpro1.nvars = 2;
internal_condition_case_n (safe_run_hooks_1, 2, iargs,
Qt, safe_run_hooks_error);
RETURN_UNGCPRO (Qnil);
}
/* If we get an error while running the hook, cause the hook variable
......@@ -1924,14 +1931,10 @@ safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
void
safe_run_hooks (Lisp_Object hook)
{
/* FIXME: our `internal_condition_case' does not provide any way to pass data
to its body or to its handlers other than via globals such as
dynamically-bound variables ;-) */
ptrdiff_t count = SPECPDL_INDEX ();
specbind (Qinhibit_quit, hook);
specbind (Qinhibit_quit, hook);
run_hook_with_args (1, &hook, safe_run_hook_funcall);
unbind_to (count, Qnil);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment