help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: [External] : M-. vs C-h o


From: Hongyi Zhao
Subject: Re: [External] : M-. vs C-h o
Date: Fri, 22 Oct 2021 10:43:00 +0800

On Fri, Oct 22, 2021 at 10:31 AM Óscar Fuentes <ofv@wanadoo.es> wrote:
>
> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>
> > Thank you for pointing this out.  I've `rg'ed the local Emacs git
> > source code repo, and it seems still difficult to pinpoint the
> > corresponding C source code implementation of DEFUN.
> >
> > HZ
>
> DEFUN is a macro. If you search for
>
> #define DEFUN
>
> you will find it in src/lisp.h

Do you mean the following search result?

$ rg -A17 -B27 -uu '#define DEFUN\(lname' src/
src/lisp.h
3022-/* Define a built-in function for calling from Lisp.
3023- `lname' should be the name to give the function in Lisp,
3024-    as a null-terminated C string.
3025- `fnname' should be the name of the function in C.
3026-    By convention, it starts with F.
3027- `sname' should be the name for the C constant structure
3028-    that records information on this function for internal use.
3029-    By convention, it should be the same as `fnname' but with S
instead of F.
3030-    It's too bad that C macros can't compute this from `fnname'.
3031- `minargs' should be a number, the minimum number of arguments allowed.
3032- `maxargs' should be a number, the maximum number of arguments allowed,
3033-    or else MANY or UNEVALLED.
3034-    MANY means pass a vector of evaluated arguments,
3035-     in the form of an integer number-of-arguments
3036-     followed by the address of a vector of Lisp_Objects
3037-     which contains the argument values.
3038-    UNEVALLED means pass the list of unevaluated arguments
3039- `intspec' says how interactive arguments are to be fetched.
3040-    If the string starts with a `(', `intspec' is evaluated and
the resulting
3041-    list is the list of arguments.
3042-    If it's a string that doesn't start with `(', the value should follow
3043-    the one of the doc string for `interactive'.
3044-    A null string means call interactively with no arguments.
3045- `doc' is documentation for the user.  */
3046-
3047-/* This version of DEFUN declares a function prototype with the right
3048-   arguments, so we can catch errors with maxargs at compile-time.  */
3049:#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
3050-  SUBR_SECTION_ATTRIBUTE                                                \
3051-  static union Aligned_Lisp_Subr sname =                                \
3052-     {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                \
3053-       { .a ## maxargs = fnname },                    \
3054-       minargs, maxargs, lname, {intspec}, 0}};                \
3055-   Lisp_Object fnname
3056-
3057-/* defsubr (Sname);
3058-   is how we define the symbol for function `name' at start-up time.  */
3059-extern void defsubr (union Aligned_Lisp_Subr *);
3060-
3061-enum maxargs
3062-  {
3063-    MANY = -2,
3064-    UNEVALLED = -1
3065-  };
3066-

HZ



reply via email to

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