From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Newsgroups: gmane.emacs.devel Subject: Re: In C code, how do I create and access a (lisp) variable? Date: Thu, 5 Nov 2015 12:28:09 +0100 Message-ID: References: <20151104210420.GA4618@acm.fritz.box> <87y4ed72rr.fsf@igel.home> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1446722921 20217 80.91.229.3 (5 Nov 2015 11:28:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Nov 2015 11:28:41 +0000 (UTC) Cc: Alan Mackenzie , Emacs development discussions To: Andreas Schwab Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 05 12:28:33 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZuIiV-0005Jw-Hv for ged-emacs-devel@m.gmane.org; Thu, 05 Nov 2015 12:28:32 +0100 Original-Received: from localhost ([::1]:59919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuIiU-0008MD-TA for ged-emacs-devel@m.gmane.org; Thu, 05 Nov 2015 06:28:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuIiF-0008M8-R9 for emacs-devel@gnu.org; Thu, 05 Nov 2015 06:28:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuIiA-0003O0-Ib for emacs-devel@gnu.org; Thu, 05 Nov 2015 06:28:15 -0500 Original-Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:35599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuIiA-0003N8-B5 for emacs-devel@gnu.org; Thu, 05 Nov 2015 06:28:10 -0500 Original-Received: by lbbes7 with SMTP id es7so33047407lbb.2 for ; Thu, 05 Nov 2015 03:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=YHAeP4A7GDggKUsMwRaBgbVONmGbuRAE7sBmEJm43E8=; b=J2pzfEUA7GVuDIO9L+xcnFG4KTshdK1bJRgiCAKcNbW2KrguZ6hd+i3Ib8Q5Ci1zzx gK4442RFdLPGSIfW2dRhNC+4BXb6emYEsbNsxc4wSxl5Tl3EjSgccmFGqdiesMnedaCy qQu8FuHvaO7hlwgCEUhPxiDtQcNW8e+oWLlSyANWYMKj4OkZ4JCG4RlIcPSfLgILZVIB +FcO4LmHYjtQS2b2uY8dOUAVjICElP0XL8C8ezUYfvkyHBmF4Wa9Nfvj1M3GSciERecU QifCOWCqFGX4aa8nMjpkNxsIdmCwGE+XBv/2wtMWMwExZl6oLzSFSwoY/yyYbTyLsbrR hH5w== X-Received: by 10.112.146.106 with SMTP id tb10mr3601299lbb.64.1446722889601; Thu, 05 Nov 2015 03:28:09 -0800 (PST) Original-Received: by 10.112.167.73 with HTTP; Thu, 5 Nov 2015 03:28:09 -0800 (PST) In-Reply-To: <87y4ed72rr.fsf@igel.home> X-Google-Sender-Auth: 7_ufIIBfMt-ORkcHglcWIP2Q26M X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:193285 Archived-At: On Thu, Nov 5, 2015 at 12:39 AM, Andreas Schwab wro= te: > Aur=C3=A9lien Aptel 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 =3D 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.