aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-08-04 08:03:31 +0400
committerDmitry Antipov2014-08-04 08:03:31 +0400
commitf045dbe6a0e173eb60383199319b35835254f452 (patch)
treea612053d4da3239f5375fee38d144d9fc79291b5 /src
parent8d2f19849a194934c05486e19a968d585f516fd6 (diff)
downloademacs-f045dbe6a0e173eb60383199319b35835254f452.tar.gz
emacs-f045dbe6a0e173eb60383199319b35835254f452.zip
* 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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/keyboard.c55
2 files changed, 36 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 70f77f8f0cd..ab0ba1b6758 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12014-08-04 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * keyboard.c (safe_run_hook_funcall): Avoid consing around
4 Vinhibit_quit and prefer internal_condition_case_n to pass args.
5 (safe_run_hooks_error, safe_run_hooks_1): Adjust accordingly.
6 (safe_run_hooks): Remove comment which is not relevant any more.
7
12014-08-03 Paul Eggert <eggert@cs.ucla.edu> 82014-08-03 Paul Eggert <eggert@cs.ucla.edu>
2 9
3 Don't let big frames overrun the stack. 10 Don't let big frames overrun the stack.
diff --git a/src/keyboard.c b/src/keyboard.c
index 5c7ad95f5ac..dd7e084783d 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1852,30 +1852,32 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
1852 } 1852 }
1853} 1853}
1854 1854
1855/* Subroutine for safe_run_hooks: run the hook HOOK. */ 1855/* Subroutine for safe_run_hooks: run the hook, which is ARGS[1]. */
1856 1856
1857static Lisp_Object 1857static Lisp_Object
1858safe_run_hooks_1 (void) 1858safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args)
1859{ 1859{
1860 eassert (CONSP (Vinhibit_quit)); 1860 eassert (nargs == 2);
1861 return call0 (XCDR (Vinhibit_quit)); 1861 return call0 (args[1]);
1862} 1862}
1863 1863
1864/* Subroutine for safe_run_hooks: handle an error by clearing out the function 1864/* Subroutine for safe_run_hooks: handle an error by clearing out the function
1865 from the hook. */ 1865 from the hook. */
1866 1866
1867static Lisp_Object 1867static Lisp_Object
1868safe_run_hooks_error (Lisp_Object error_data) 1868safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args)
1869{ 1869{
1870 Lisp_Object hook 1870 Lisp_Object hook, fun, msgargs[4];
1871 = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit; 1871
1872 Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil; 1872 eassert (nargs == 2);
1873 Lisp_Object args[4]; 1873 hook = args[0];
1874 args[0] = build_string ("Error in %s (%S): %S"); 1874 fun = args[1];
1875 args[1] = hook; 1875 msgargs[0] = build_string ("Error in %s (%S): %S");
1876 args[2] = fun; 1876 msgargs[1] = hook;
1877 args[3] = error_data; 1877 msgargs[2] = fun;
1878 Fmessage (4, args); 1878 msgargs[3] = error;
1879 Fmessage (4, msgargs);
1880
1879 if (SYMBOLP (hook)) 1881 if (SYMBOLP (hook))
1880 { 1882 {
1881 Lisp_Object val; 1883 Lisp_Object val;
@@ -1907,14 +1909,19 @@ safe_run_hooks_error (Lisp_Object error_data)
1907static Lisp_Object 1909static Lisp_Object
1908safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args) 1910safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
1909{ 1911{
1912 Lisp_Object iargs[2];
1913 struct gcpro gcpro1;
1914
1910 eassert (nargs == 1); 1915 eassert (nargs == 1);
1911 if (CONSP (Vinhibit_quit)) 1916 iargs[0] = Vinhibit_quit;
1912 XSETCDR (Vinhibit_quit, args[0]); 1917 iargs[1] = args[0];
1913 else
1914 Vinhibit_quit = Fcons (Vinhibit_quit, args[0]);
1915 1918
1916 internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error); 1919 GCPRO1 (*iargs);
1917 return Qnil; 1920 gcpro1.nvars = 2;
1921
1922 internal_condition_case_n (safe_run_hooks_1, 2, iargs,
1923 Qt, safe_run_hooks_error);
1924 RETURN_UNGCPRO (Qnil);
1918} 1925}
1919 1926
1920/* If we get an error while running the hook, cause the hook variable 1927/* 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)
1924void 1931void
1925safe_run_hooks (Lisp_Object hook) 1932safe_run_hooks (Lisp_Object hook)
1926{ 1933{
1927 /* FIXME: our `internal_condition_case' does not provide any way to pass data
1928 to its body or to its handlers other than via globals such as
1929 dynamically-bound variables ;-) */
1930 ptrdiff_t count = SPECPDL_INDEX (); 1934 ptrdiff_t count = SPECPDL_INDEX ();
1931 specbind (Qinhibit_quit, hook);
1932 1935
1936 specbind (Qinhibit_quit, hook);
1933 run_hook_with_args (1, &hook, safe_run_hook_funcall); 1937 run_hook_with_args (1, &hook, safe_run_hook_funcall);
1934
1935 unbind_to (count, Qnil); 1938 unbind_to (count, Qnil);
1936} 1939}
1937 1940