[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117640: * keyboard.c (safe_run_hook_funcall): Avoid
From: |
Dmitry Antipov |
Subject: |
[Emacs-diffs] trunk r117640: * keyboard.c (safe_run_hook_funcall): Avoid consing around |
Date: |
Mon, 04 Aug 2014 04:03:42 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117640
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2014-08-04 08:03:31 +0400
message:
* 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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/keyboard.c keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-08-03 23:16:39 +0000
+++ b/src/ChangeLog 2014-08-04 04:03:31 +0000
@@ -1,3 +1,10 @@
+2014-08-04 Dmitry Antipov <address@hidden>
+
+ * 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 <address@hidden>
Don't let big frames overrun the stack.
=== modified file 'src/keyboard.c'
--- a/src/keyboard.c 2014-08-03 15:38:52 +0000
+++ b/src/keyboard.c 2014-08-04 04:03:31 +0000
@@ -1852,30 +1852,32 @@
}
}
-/* 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)
+safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args)
{
- 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);
+ 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 @@
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]);
-
- internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error);
- return Qnil;
+ iargs[0] = Vinhibit_quit;
+ iargs[1] = args[0];
+
+ 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 @@
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);
-
run_hook_with_args (1, &hook, safe_run_hook_funcall);
-
unbind_to (count, Qnil);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117640: * keyboard.c (safe_run_hook_funcall): Avoid consing around,
Dmitry Antipov <=