From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Native line numbers landed on master Date: Wed, 09 Oct 2019 11:16:36 +0300 Message-ID: <838spuwcyj.fsf@gnu.org> References: <834l4xbfmp.fsf@gnu.org> <20191001225254.mwjnxlynjdc3mz7y@Ergus> <83lfu389vn.fsf@gnu.org> <87ftk9v4kx.fsf@wavexx.thregr.org> <83wodl54yt.fsf@gnu.org> <87pnjchm7p.fsf@wavexx.thregr.org> <83pnj8zff9.fsf@gnu.org> <83blurxw6a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="207004"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Robert Pluim Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 09 18:59:08 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iIFIp-000rie-Vp for ged-emacs-devel@m.gmane.org; Wed, 09 Oct 2019 18:59:08 +0200 Original-Received: from localhost ([::1]:52656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIFIo-0000c1-9J for ged-emacs-devel@m.gmane.org; Wed, 09 Oct 2019 12:59:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44870) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iI79T-0005lU-2G for emacs-devel@gnu.org; Wed, 09 Oct 2019 04:16:56 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:37426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iI79S-0001Vc-US; Wed, 09 Oct 2019 04:16:54 -0400 Original-Received: from [176.228.60.248] (port=1152 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iI79S-0004FL-99; Wed, 09 Oct 2019 04:16:54 -0400 In-reply-to: (message from Robert Pluim on Wed, 09 Oct 2019 09:19:57 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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" Xref: news.gmane.org gmane.emacs.devel:240766 Archived-At: > From: Robert Pluim > Cc: emacs-devel@gnu.org > Date: Wed, 09 Oct 2019 09:19:57 +0200 > > Eli> Bonus points for adding information missing from the above, such as > Eli> how to define buffer-local variables (see init_buffer_once), and how > Eli> to define custom forms for variables defined in C. > > Youʼre a hard taskmaster Eli :-) . I've been told that, yes ;-) > Iʼve done my best, although I donʼt see where init_buffer_once comes > in. I meant the likes of this: XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx; Anyone who defines buffer-local variables should generally be familiar with this stuff. > + By convention, when defining variables of a ``native'' type > +(@code{int} and @code{bool}), the name of the C variable is the name > +of the Lisp variable with @code{-} replaced by @code{_}. When the > +variable has type @code{Lisp_Object}, the convention is to also prefix > +the C variable name with ``V''. i.e. ^^^^^ @code{V} > + There are situations in Lisp where you need to refer to the symbol > +itself rather than the value of that symbol. One such case is when > +temporarily overriding the value of a variable, which in Lisp is done > +with @code{let}. In C sources, this is done by defining a > +corresponding, constant symbol, and using @code{specbind}. By > +convention @code{Qmy_lisp_variable} corresponds to > +@code{Vmy_lisp_variable}; to define it, use the @code{DEFSYM} macro. > +i.e. > + > +@smallexample > +DEFSYM (Qmy_lisp_variable, "my-lisp-variable"); > +@end smallexample > + > + To perform the actual binding: > + > +@smallexample > +specbind (Qmy_lisp_variable, Qt); > +@end smallexample > + > + Another use for constant symbols is when creating a buffer-local > +variable (@pxref{Buffer-Local Variables}). In C this is done with > +@code{Fmake_variable_buffer_local} in combination with @code{DEFSYM}, > +i.e. > + > +@smallexample > +DEFSYM (Qmy_lisp_variable, "my-lisp-variable"); > +Fmake_variable_buffer_local (Qmy_lisp_variable); > +@end smallexample This is great, but I think it would be even better if we explained the general principle: the Qfoo symbol is needed where in Lisp you'd use a quoted symbol 'foo. > +@file{cus-start.el}. @xref{Variable Definitions} for a description of > +the format to use. ^ Comma is missing there, although recent versions of Texinfo no longer flag this. Otherwise, this is a very good addition; thank you.