[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Native line numbers landed on master
From: |
Robert Pluim |
Subject: |
Re: Native line numbers landed on master |
Date: |
Tue, 08 Oct 2019 13:15:46 +0200 |
>>>>> On Mon, 07 Oct 2019 19:30:34 +0300, Eli Zaretskii <address@hidden> said:
Eli> We have a node about writing Emacs Lisp primitives; a node about Lisp
Eli> variables implemented in C still awaits its author. Patches are
Eli> welcome.
I donʼt know about a separate node. How about this:
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index c52999e1cd..54f1e8858d 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -945,7 +945,7 @@ Writing Emacs Primitives
@anchor{Defining Lisp variables in C}
@vindex byte-boolean-vars
@cindex defining Lisp variables in C
-@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}
+@cindex @code{DEFVAR_INT}, @code{DEFVAR_LISP}, @code{DEFVAR_BOOL},
@code{DEFSYM}
The function @code{syms_of_@var{filename}} is also the place to define
any C variables that are to be visible as Lisp variables.
@code{DEFVAR_LISP} makes a C variable of type @code{Lisp_Object} visible
@@ -956,6 +956,38 @@ Writing Emacs Primitives
defined with @code{DEFVAR_BOOL} are automatically added to the list
@code{byte-boolean-vars} used by the byte compiler.
+ These macros all expect three arguments:
+
+@table @code
+@item lname
+The Lisp-level name of the variable.
+@item vname
+The C-level name of the variable.
+@item doc
+The documentation for the variable, as a C comment.
+@end table
+
+ By convention, when defining variables of a ``native'' type
+(@code{int} and @code{bool}), the name of the C variable is the same
+as the name of the Lisp variable with ``-'' replaced by ``_''. When
+the variable can hold any Lisp object, the convention is
+to also prefix the C variable name with ``V''. i.e.
+
+@smallexample
+DEFVAR_INT ("my-int-variable", my_int_variable,
+ doc: /* An integer variable. */);
+
+DEFVAR_LISP ("my-lisp-variable", Vmy_lisp_variable,
+ doc: /* A Lisp variable. */);
+@end smallexample
+
+If you want to define a constant symbol rather than a variable, use
+@code{DEFSYM} instead. e.g.
+
+@smallexample
+DEFSYM ("Qmy_symbol", "my-symbol");
+@end smallexample
+
@cindex defining customization variables in C
If you want to make a Lisp variable that is defined in C behave
like one declared with @code{defcustom}, add an appropriate entry to
- Re: Native line numbers landed on master, (continued)
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/05
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/06
- Re: Native line numbers landed on master, Robert Pluim, 2019/10/07
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/07
- Re: Native line numbers landed on master, Robert Pluim, 2019/10/07
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/07
- Re: Native line numbers landed on master, Juri Linkov, 2019/10/07
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/07
- Re: Native line numbers landed on master, Juri Linkov, 2019/10/19
- Re: Native line numbers landed on master, Eli Zaretskii, 2019/10/07
- Re: Native line numbers landed on master,
Robert Pluim <=
- Re: Native line numbers landed on master, Eli Zaretskii, 2019/10/08
- Re: Native line numbers landed on master, Robert Pluim, 2019/10/09
- Re: Native line numbers landed on master, Eli Zaretskii, 2019/10/09
- Re: Native line numbers landed on master, Robert Pluim, 2019/10/09
- Re: Native line numbers landed on master, Eli Zaretskii, 2019/10/09
- Re: Native line numbers landed on master, Robert Pluim, 2019/10/09
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/09
- Re: Native line numbers landed on master, Ergus, 2019/10/04
- Re: Native line numbers landed on master, Juanma Barranquero, 2019/10/04
- Re: Native line numbers landed on master, Yuri Khan, 2019/10/03