From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#48264: [PATCH v3 15/15] Add and use BVAR_FIELD macros Date: Fri, 07 May 2021 14:03:28 +0300 Message-ID: <835yzudcvz.fsf@gnu.org> References: <877dkbsj9d.fsf@catern.com> <20210506213346.9730-16-sbaugh@catern.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23114"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48264@debbugs.gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 07 13:04:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1leyHC-0005tp-9g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 13:04:10 +0200 Original-Received: from localhost ([::1]:52566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leyHB-0004yI-9n for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 07:04:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leyH4-0004y8-BY for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 07:04:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59892) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leyH4-0008R4-4C for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 07:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1leyH3-0003DI-TJ for bug-gnu-emacs@gnu.org; Fri, 07 May 2021 07:04:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 07 May 2021 11:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48264 X-GNU-PR-Package: emacs Original-Received: via spool by 48264-submit@debbugs.gnu.org id=B48264.162038542312333 (code B ref 48264); Fri, 07 May 2021 11:04:01 +0000 Original-Received: (at 48264) by debbugs.gnu.org; 7 May 2021 11:03:43 +0000 Original-Received: from localhost ([127.0.0.1]:43199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leyGl-0003Cr-Ip for submit@debbugs.gnu.org; Fri, 07 May 2021 07:03:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leyGj-0003Cl-OO for 48264@debbugs.gnu.org; Fri, 07 May 2021 07:03:42 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:34526) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leyGe-0008Bh-HU; Fri, 07 May 2021 07:03:36 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2676 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1leyGd-0002mv-Vf; Fri, 07 May 2021 07:03:36 -0400 In-Reply-To: <20210506213346.9730-16-sbaugh@catern.com> (message from Spencer Baugh on Thu, 6 May 2021 17:33:46 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205915 Archived-At: > From: Spencer Baugh > Date: Thu, 6 May 2021 17:33:46 -0400 > Cc: Spencer Baugh > > diff --git a/src/buffer.c b/src/buffer.c > index abf112a898..e048e7559f 100644 > --- a/src/buffer.c > +++ b/src/buffer.c > @@ -122,17 +122,17 @@ fix_position (Lisp_Object pos) > static void > bset_abbrev_mode (struct buffer *b, Lisp_Object val) > { > - b->abbrev_mode_ = val; > + b->BVAR_DEFAULTED_FIELD(abbrev_mode) = val; Yuck! Can we avoid having a macro in the struct field names? I'd prefer that the BVAR_DEFAULTED_FIELD macro accepted the buffer as argument instead (if we need a macro at all; see below). > --- a/src/buffer.h > +++ b/src/buffer.h > @@ -280,13 +280,18 @@ struct buffer_text > bool_bf redisplay : 1; > }; > > +#define BVAR_FIELD(field) field ## _ > +#define BVAR_DEFAULTED_FIELD(field) field ## _defaulted_ I'm not sure these changes are for the better. Why not use _ and _defaulted_ literally? The macros don't make code easier to write, and at least for me make it harder to understand (because I need to look up the macro definition). > @@ -714,12 +719,12 @@ XBUFFER (Lisp_Object a) > INLINE void > bset_bidi_paragraph_direction (struct buffer *b, Lisp_Object val) > { > - b->bidi_paragraph_direction_ = val; > + b->BVAR_DEFAULTED_FIELD(bidi_paragraph_direction) = val; > } > INLINE void > bset_cache_long_scans (struct buffer *b, Lisp_Object val) > { > - b->cache_long_scans_ = val; > + b->BVAR_DEFAULTED_FIELD(cache_long_scans) = val; > } > INLINE void > bset_case_canon_table (struct buffer *b, Lisp_Object val) > @@ -744,12 +749,12 @@ bset_display_count (struct buffer *b, Lisp_Object val) > INLINE void > bset_left_margin_cols (struct buffer *b, Lisp_Object val) > { > - b->left_margin_cols_ = val; > + b->BVAR_DEFAULTED_FIELD(left_margin_cols) = val; > } Hmm... I'm not sure I understand the effect of these. Does it mean C code can no longer set the buffer-local value of these variables, only the default value? > +#define PER_BUFFER_VAR_DEFAULTED_OFFSET(VAR) \ > + offsetof (struct buffer, BVAR_DEFAULTED_FIELD(VAR)) Likewise here: I don't see how such macros make the code more readable. I think they make it less readable.