emacs-devel
[Top][All Lists]
Advanced

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

Re: In C code, how do I create and access a (lisp) variable?


From: Aurélien Aptel
Subject: Re: In C code, how do I create and access a (lisp) variable?
Date: Thu, 5 Nov 2015 12:28:09 +0100

On Thu, Nov 5, 2015 at 12:39 AM, Andreas Schwab <address@hidden> wrote:
> Aurélien Aptel <address@hidden> writes:
>
>> I think you're supposed to use DEFVAR_PER_BUFFER for definition and
>> BVAR for access.
>
> DEFVAR_PER_BUFFER and BVAR are only for variables that are part of
> struct buffer.  An ordinary variable can be made buffer-local even if
> not part of struct buffer.

Correct. A similar question was asked (and answered) in emacs-devel.
Here's the link the archived thread (look for Stephan replies).

    https://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00578.html

I'll quote him:

>> (defvar-local undo-buffer-undoably-changed nil
>>   "Non-nil means that that the buffer has had a recent undo-able change.
>
> This macroexpands to defvar + make-variable-buffer-local.
>
> In C defvar turns into DEFVAR_LISP, and make-variable-buffer-local turns
> into Fmake_variable_buffer_local.

And

>> Fsetq(Qfontification_functions,Qt)
>
> BTW, one notable difference (other than performance) between
>
>     Fset (Qfontification_functions, Qt);
> and
>     Vfontification_functions = Qt;
>
> is that the former will obey make-variable-buffer-local while the
> latter won't.  So if you want the var to be buffer-local, either use the
> former, or make sure to call Fmake_local_variable explicitly at
> some point.



reply via email to

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