From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#48264: [PATCH v3 05/15] Add and use KILL_PER_BUFFER_VALUE Date: Thu, 6 May 2021 17:33:36 -0400 Message-ID: <20210506213346.9730-6-sbaugh@catern.com> References: <877dkbsj9d.fsf@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39182"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: 48264@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 06 23:34:57 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 1lele4-000A3r-Cp for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 May 2021 23:34:56 +0200 Original-Received: from localhost ([::1]:33670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lele3-000639-F0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 May 2021 17:34:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leldI-0005LF-R6 for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 17:34:09 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leldI-0001pd-Jk for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 17:34:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1leldI-0000CP-HQ for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 17:34:08 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 May 2021 21:34:08 +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.1620336847742 (code B ref 48264); Thu, 06 May 2021 21:34:08 +0000 Original-Received: (at 48264) by debbugs.gnu.org; 6 May 2021 21:34:07 +0000 Original-Received: from localhost ([127.0.0.1]:39868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leldG-0000Bj-0x for submit@debbugs.gnu.org; Thu, 06 May 2021 17:34:06 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:41484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1leld9-0000A5-Ed for 48264@debbugs.gnu.org; Thu, 06 May 2021 17:33:59 -0400 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1620336839; bh=vmnkif9/rZF+ZdexRziKCgrUoZJvh/Kad9BfutRrerE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ld5zOvKcShCSr0iWj8/85KJXYbh6YuI0M0uXDAxCW0NqZKshP6PbnA1s12F+jXUiX Jn/SYxqAYKE/WakyOSsZtgfZ7e1GcNtmRXbk/GigbuYcusreGdZsXztshR614BpfJe b+Z8pl4RDPS6dzYk1xErFJiGz8a+GBhci4qUP7V8= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id 24FBB2E87C0; Thu, 6 May 2021 21:33:59 +0000 (UTC) X-Mailer: git-send-email 2.31.1 In-Reply-To: <877dkbsj9d.fsf@catern.com> 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:205883 Archived-At: This makes the code more clear and allows us to more easily change how this function is implemented. * src/buffer.h (KILL_PER_BUFFER_VALUE): New function. * src/buffer.c (reset_buffer_local_variables): * src/data.c (Fkill_local_variable): Use KILL_PER_BUFFER_VALUE. --- src/buffer.c | 5 +---- src/buffer.h | 10 ++++++++++ src/data.c | 8 +------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index c2a268adec..c75dcbcffb 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1107,10 +1107,7 @@ reset_buffer_local_variables (struct buffer *b, bool permanent_too) if ((BUFFER_DEFAULT_VALUE_P (offset) && (permanent_too || buffer_permanent_local_flags[idx] == 0))) - { - SET_PER_BUFFER_VALUE_P (b, idx, 0); - set_per_buffer_value (b, offset, per_buffer_default (offset)); - } + KILL_PER_BUFFER_VALUE (b, offset); } } diff --git a/src/buffer.h b/src/buffer.h index 2125d1b907..fff2d27ea0 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1502,6 +1502,16 @@ PER_BUFFER_VALUE_P (struct buffer *b, int offset) return idx == -1 || b->local_flags[idx]; } +/* Kill the per-buffer binding for this value, if there is one. */ + +INLINE void +KILL_PER_BUFFER_VALUE (struct buffer *b, int offset) +{ + int idx = PER_BUFFER_IDX (offset); + SET_PER_BUFFER_VALUE_P (b, idx, 0); + set_per_buffer_value (b, offset, per_buffer_default (offset)); +} + /* Downcase a character C, or make no change if that cannot be done. */ INLINE int downcase (int c) diff --git a/src/data.c b/src/data.c index 9bd935fe09..75ebcceb93 100644 --- a/src/data.c +++ b/src/data.c @@ -2154,14 +2154,8 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) if (BUFFER_OBJFWDP (valcontents)) { int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - if (BUFFER_DEFAULT_VALUE_P (offset)) - { - SET_PER_BUFFER_VALUE_P (current_buffer, idx, 0); - set_per_buffer_value (current_buffer, offset, - per_buffer_default (offset)); - } + KILL_PER_BUFFER_VALUE (current_buffer, offset); } return variable; } -- 2.31.1