diff options
| author | Karl Heuer | 1995-07-25 19:36:42 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-07-25 19:36:42 +0000 |
| commit | b0b667cb9012ff1b99b16bf5179278580dfb6835 (patch) | |
| tree | 5aca2fed96901f1ab7fb697aac75829e7acd4fe4 /src | |
| parent | 7baf1f090b96eb951f25f897a60015cb724779ad (diff) | |
| download | emacs-b0b667cb9012ff1b99b16bf5179278580dfb6835.tar.gz emacs-b0b667cb9012ff1b99b16bf5179278580dfb6835.zip | |
(Frun_hook_with_args): New C function, formerly in subr.el.
Diffstat (limited to 'src')
| -rw-r--r-- | src/eval.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c index 6c2b984940d..00f821a085a 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -1816,6 +1816,65 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.") | |||
| 1816 | RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args)); | 1816 | RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args)); |
| 1817 | } | 1817 | } |
| 1818 | 1818 | ||
| 1819 | DEFUN ("run-hook-with-args", Frun_hook_with_args, Srun_hook_with_args, 1, MANY, 0, | ||
| 1820 | "Run HOOK with the specified arguments ARGS.\n\ | ||
| 1821 | HOOK should be a symbol, a hook variable. If HOOK has a non-nil\n\ | ||
| 1822 | value, that value may be a function or a list of functions to be\n\ | ||
| 1823 | called to run the hook. If the value is a function, it is called with\n\ | ||
| 1824 | the given arguments and its return value is returned. If it is a list\n\ | ||
| 1825 | of functions, those functions are called, in order,\n\ | ||
| 1826 | with the given arguments ARGS.\n\ | ||
| 1827 | It is best not to depend on the value return by `run-hook-with-args',\n\ | ||
| 1828 | as that may change.\n\ | ||
| 1829 | \n\ | ||
| 1830 | To make a hook variable buffer-local, use `make-local-hook', not\n\ | ||
| 1831 | `make-local-variable'.") | ||
| 1832 | (nargs, args) | ||
| 1833 | int nargs; | ||
| 1834 | Lisp_Object *args; | ||
| 1835 | { | ||
| 1836 | Lisp_Object sym, val; | ||
| 1837 | |||
| 1838 | sym = args[0]; | ||
| 1839 | CHECK_SYMBOL (sym, 0); | ||
| 1840 | val = XSYMBOL (sym)->value; | ||
| 1841 | if (BUFFER_LOCAL_VALUEP (val) | ||
| 1842 | || SOME_BUFFER_LOCAL_VALUEP (val)) | ||
| 1843 | val = swap_in_symval_forwarding (sym, val); | ||
| 1844 | if (EQ (val, Qunbound) || NILP (val)) | ||
| 1845 | return Qnil; | ||
| 1846 | else if (!CONSP (val) || EQ (XCONS (val)->car, Qlambda)) | ||
| 1847 | { | ||
| 1848 | args[0] = val; | ||
| 1849 | return Ffuncall (nargs, args); | ||
| 1850 | } | ||
| 1851 | else | ||
| 1852 | { | ||
| 1853 | for (; CONSP (val); val = XCONS (val)->cdr) | ||
| 1854 | { | ||
| 1855 | if (EQ (XCONS (val)->car, Qt)) | ||
| 1856 | { | ||
| 1857 | /* t indicates this hook has a local binding; | ||
| 1858 | it means to run the global binding too. */ | ||
| 1859 | Lisp_Object globals; | ||
| 1860 | |||
| 1861 | for (globals = Fdefault_value (sym); CONSP (globals); | ||
| 1862 | globals = XCONS (globals)->cdr) | ||
| 1863 | { | ||
| 1864 | args[0] = XCONS (globals)->car; | ||
| 1865 | Ffuncall (nargs, args); | ||
| 1866 | } | ||
| 1867 | } | ||
| 1868 | else | ||
| 1869 | { | ||
| 1870 | args[0] = XCONS (val)->car; | ||
| 1871 | Ffuncall (nargs, args); | ||
| 1872 | } | ||
| 1873 | } | ||
| 1874 | return Qnil; | ||
| 1875 | } | ||
| 1876 | } | ||
| 1877 | |||
| 1819 | /* Apply fn to arg */ | 1878 | /* Apply fn to arg */ |
| 1820 | Lisp_Object | 1879 | Lisp_Object |
| 1821 | apply1 (fn, arg) | 1880 | apply1 (fn, arg) |