emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arbitrary function: find the number(s) of expected arguments


From: Eli Zaretskii
Subject: Re: Arbitrary function: find the number(s) of expected arguments
Date: Sat, 02 Apr 2016 12:48:53 +0300

> Date: Sat, 26 Mar 2016 12:42:17 +0100
> From: Paul Pogonyshev <address@hidden>
> Cc: address@hidden
> 
> > There's one potential issue left:
> >
> >  (func-arity 'with-temp-buffer) => error-> Invalid function: 
> > with-temp-buffer
> >
> > Is it possible to support macros as well?  If not, how about producing
> > a more meaningful error message?
> 
> Well, according to `functionp' macros are not functions, so it's
> sort of correct.  On the other hand, it seems (symbol-function ...)
> works, returning ('macro . FUNCTION) for them.  However, I can't
> find any real C-level way to handle macros, e.g. `macrop' is even
> not a builtin.
> 
> Or is just treating them as lists fine?  If so, we could add
> something like this (untested):
> 
> diff --git a/src/eval.c b/src/eval.c
> index 64a6655..5c594b8 100644
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -2958,6 +2958,9 @@ function with `&rest' args, or `unevalled' for a
> special form.  */)
>        && (function = XSYMBOL (function)->function, SYMBOLP (function)))
>      function = indirect_function (function);
> 
> +  if (CONSP (function) && EQ (XCAR (function), Qmacro))
> +    function = XCDR (function);
> +
>    if (SUBRP (function))
>      result = Fsubr_arity (function);
>    else if (COMPILEDP (function))
> 
> However, I'm not exactly sure what will happen with autoloaded
> macros.

Thanks, I installed the above.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]