aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1995-08-05 22:53:03 +0000
committerRichard M. Stallman1995-08-05 22:53:03 +0000
commitc933ea05f809c1367a1bcbc9a42a11ffcda66b88 (patch)
treeb5fad920ae31fbf82c434b57f58065be2ac2df0b /src
parentb2a30870b013fa712bf3bcd82b8ce42aceadacbf (diff)
downloademacs-c933ea05f809c1367a1bcbc9a42a11ffcda66b88.tar.gz
emacs-c933ea05f809c1367a1bcbc9a42a11ffcda66b88.zip
(run_hook_with_args): Add gcpros.
(run_hook_list_with_args): New function.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index bc09eb2871e..07fbf871b68 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1906,6 +1906,14 @@ not `make-local-variable'.")
1906 return run_hook_with_args (nargs, args, until_failure); 1906 return run_hook_with_args (nargs, args, until_failure);
1907} 1907}
1908 1908
1909/* ARGS[0] should be a hook symbol.
1910 Call each of the functions in the hook value, passing each of them
1911 as arguments all the rest of ARGS (all NARGS - 1 elements).
1912 COND specifies a condition to test after each call
1913 to decide whether to stop.
1914 The caller (or its caller, etc) must gcpro all of ARGS,
1915 except that it isn't necessary to gcpro ARGS[0]. */
1916
1909Lisp_Object 1917Lisp_Object
1910run_hook_with_args (nargs, args, cond) 1918run_hook_with_args (nargs, args, cond)
1911 int nargs; 1919 int nargs;
@@ -1913,11 +1921,14 @@ run_hook_with_args (nargs, args, cond)
1913 enum run_hooks_condition cond; 1921 enum run_hooks_condition cond;
1914{ 1922{
1915 Lisp_Object sym, val, ret; 1923 Lisp_Object sym, val, ret;
1924 struct gcpro gcpro1, gcpro2;
1916 1925
1917 sym = args[0]; 1926 sym = args[0];
1918 val = find_symbol_value (sym); 1927 val = find_symbol_value (sym);
1919 ret = (cond == until_failure ? Qt : Qnil); 1928 ret = (cond == until_failure ? Qt : Qnil);
1920 1929
1930 GCPRO2 (sym, val);
1931
1921 if (EQ (val, Qunbound) || NILP (val)) 1932 if (EQ (val, Qunbound) || NILP (val))
1922 return ret; 1933 return ret;
1923 else if (!CONSP (val) || EQ (XCONS (val)->car, Qlambda)) 1934 else if (!CONSP (val) || EQ (XCONS (val)->car, Qlambda))
@@ -1958,6 +1969,52 @@ run_hook_with_args (nargs, args, cond)
1958 return ret; 1969 return ret;
1959 } 1970 }
1960} 1971}
1972
1973/* Run a hook symbol ARGS[0], but use FUNLIST instead of the actual
1974 present value of that symbol.
1975 Call each element of FUNLIST,
1976 passing each of them the rest of ARGS.
1977 The caller (or its caller, etc) must gcpro all of ARGS,
1978 except that it isn't necessary to gcpro ARGS[0]. */
1979
1980Lisp_Object
1981run_hook_list_with_args (funlist, nargs, args)
1982 Lisp_Object funlist;
1983 int nargs;
1984 Lisp_Object *args;
1985{
1986 Lisp_Object sym;
1987 Lisp_Object val;
1988 struct gcpro gcpro1, gcpro2;
1989
1990 sym = args[0];
1991 GCPRO2 (sym, val);
1992
1993 for (val = funlist; CONSP (val); val = XCONS (val)->cdr)
1994 {
1995 if (EQ (XCONS (val)->car, Qt))
1996 {
1997 /* t indicates this hook has a local binding;
1998 it means to run the global binding too. */
1999 Lisp_Object globals;
2000
2001 for (globals = Fdefault_value (sym);
2002 CONSP (globals);
2003 globals = XCONS (globals)->cdr)
2004 {
2005 args[0] = XCONS (globals)->car;
2006 Ffuncall (nargs, args);
2007 }
2008 }
2009 else
2010 {
2011 args[0] = XCONS (val)->car;
2012 Ffuncall (nargs, args);
2013 }
2014 }
2015 UNGCPRO;
2016 return Qnil;
2017}
1961 2018
1962/* Apply fn to arg */ 2019/* Apply fn to arg */
1963Lisp_Object 2020Lisp_Object