unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@catern.com>
To: emacs-devel@gnu.org
Cc: Spencer Baugh <sbaugh@catern.com>,
	Arnold Noronha <arnold@tdrhq.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	Dmitry Gutov <dgutov@yandex.ru>
Subject: [PATCH v2 06/16] Use bset_* functions instead of BVAR
Date: Sat, 21 Nov 2020 21:34:35 -0500	[thread overview]
Message-ID: <9b43dc231149dc6f272d39d966698b770efb276a.1606009917.git.sbaugh@catern.com> (raw)
In-Reply-To: <cover.1606009917.git.sbaugh@catern.com>

We move bset_save_length to buffer.h, and expand usage of the
pre-existing bset_last_selected_window and
bset_enable_multibyte_characters functions.

This removes some usage of BVAR as an lvalue, necessary for changing
BVAR into a function call.
---
 src/buffer.c | 13 ++++---------
 src/buffer.h |  5 +++++
 src/fileio.c | 12 ++++++------
 src/window.c |  5 ++---
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/buffer.c b/src/buffer.c
index defc4ac746..aa951ca78f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -327,11 +327,6 @@ bset_right_fringe_width (struct buffer *b, Lisp_Object val)
   b->right_fringe_width_ = val;
 }
 static void
-bset_save_length (struct buffer *b, Lisp_Object val)
-{
-  b->save_length_ = val;
-}
-static void
 bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
 {
   b->scroll_bar_width_ = val;
@@ -951,7 +946,7 @@ reset_buffer (register struct buffer *b)
   bset_directory (b, current_buffer ? BVAR (current_buffer, directory) : Qnil);
   b->modtime = make_timespec (0, UNKNOWN_MODTIME_NSECS);
   b->modtime_size = -1;
-  XSETFASTINT (BVAR (b, save_length), 0);
+  bset_save_length (b, make_fixed_natnum (0));
   b->last_window_start = 1;
   /* It is more conservative to start out "changed" than "unchanged".  */
   b->clip_changed = 0;
@@ -2275,7 +2270,7 @@ so the buffer is truly empty after this.  */)
   /* Prevent warnings, or suspension of auto saving, that would happen
      if future size is less than past size.  Use of erase-buffer
      implies that the future text is not really related to the past text.  */
-  XSETFASTINT (BVAR (current_buffer, save_length), 0);
+  bset_save_length (current_buffer, make_fixed_natnum (0));
   return Qnil;
 }
 
@@ -2763,8 +2758,8 @@ current buffer is cleared.  */)
       struct buffer *o = XBUFFER (other);
       if (o->base_buffer == current_buffer && BUFFER_LIVE_P (o))
 	{
-	  BVAR (o, enable_multibyte_characters)
-	    = BVAR (current_buffer, enable_multibyte_characters);
+	  bset_enable_multibyte_characters (o,
+            BVAR (current_buffer, enable_multibyte_characters));
 	  o->prevent_redisplay_optimizations_p = true;
 	}
     }
diff --git a/src/buffer.h b/src/buffer.h
index 2999036300..770a5d03e6 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -824,6 +824,11 @@ bset_width_table (struct buffer *b, Lisp_Object val)
 {
   b->width_table_ = val;
 }
+INLINE void
+bset_save_length (struct buffer *b, Lisp_Object val)
+{
+  b->save_length_ = val;
+}
 
 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
    the max (resp. min) p such that
diff --git a/src/fileio.c b/src/fileio.c
index 283813ff89..ba094a5705 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4697,7 +4697,7 @@ by calling `format-decode', which see.  */)
 
       SAVE_MODIFF = MODIFF;
       BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
-      XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+      bset_save_length (current_buffer, make_fixed_natnum (Z - BEG));
       if (NILP (handler))
 	{
 	  if (!NILP (BVAR (current_buffer, file_truename)))
@@ -5110,7 +5110,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
       if (visiting)
 	{
 	  SAVE_MODIFF = MODIFF;
-	  XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+          bset_save_length (current_buffer, make_fixed_natnum (Z - BEG));
 	  bset_filename (current_buffer, visit_file);
 	}
 
@@ -5361,7 +5361,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
   if (visiting)
     {
       SAVE_MODIFF = MODIFF;
-      XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+      bset_save_length (current_buffer, make_fixed_natnum (Z - BEG));
       bset_filename (current_buffer, visit_file);
       update_mode_lines = 14;
       if (auto_saving_into_visited_file)
@@ -5979,7 +5979,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
 		minibuffer_auto_raise = 0;
 		/* Turn off auto-saving until there's a real save,
 		   and prevent any more warnings.  */
-		XSETINT (BVAR (b, save_length), -1);
+                bset_save_length (current_buffer, make_fixed_natnum (-1));
 		Fsleep_for (make_fixnum (1), Qnil);
 		continue;
 	      }
@@ -5988,7 +5988,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
 	    internal_condition_case (auto_save_1, Qt, auto_save_error);
 	    auto_saved = 1;
 	    BUF_AUTOSAVE_MODIFF (b) = BUF_MODIFF (b);
-	    XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+            bset_save_length (current_buffer, make_fixed_natnum (Z - BEG));
 	    set_buffer_internal (old);
 
 	    after_time = current_timespec ();
@@ -6034,7 +6034,7 @@ No auto-save file will be written until the buffer changes again.  */)
   /* FIXME: This should not be called in indirect buffers, since
      they're not autosaved.  */
   BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
-  XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
+  bset_save_length (current_buffer, make_fixed_natnum (Z - BEG));
   current_buffer->auto_save_failure_time = 0;
   return Qnil;
 }
diff --git a/src/window.c b/src/window.c
index 6cd3122b43..ee435e395e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7117,9 +7117,8 @@ the return value is nil.  Otherwise the value is t.  */)
 	 Do not record the buffer here.  We do that in a separate call
 	 to select_window below.  See also Bug#16207.  */
       select_window (data->current_window, Qt, true);
-      BVAR (XBUFFER (XWINDOW (selected_window)->contents),
-	    last_selected_window)
-	= selected_window;
+      bset_last_selected_window (XBUFFER (XWINDOW (selected_window)->contents),
+                                 selected_window);
 
       if (NILP (data->focus_frame)
 	  || (FRAMEP (data->focus_frame)
-- 
2.28.0




  parent reply	other threads:[~2020-11-22  2:34 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14 16:34 ido-switch-buffer is slow with many buffers; others are fast catern
2020-11-14 18:22 ` Stefan Monnier
2020-11-14 20:06   ` sbaugh
2020-11-14 23:00     ` Stefan Monnier
2020-11-14 23:16 ` Dmitry Gutov
2020-11-15  0:19   ` Spencer Baugh
2020-11-15 15:15     ` Stefan Monnier
2020-11-15 20:49       ` Spencer Baugh
2020-11-15 23:58         ` Arnold Noronha
2020-11-19 15:38         ` [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER (Was: ido-switch-buffer is slow) Spencer Baugh
2020-11-19 17:29           ` [PATCH 00/10] Speeding up DEFVAR_PER_BUFFER Stefan Monnier
2020-11-22  2:34           ` [PATCH v2 00/16] " Spencer Baugh
2020-11-22  2:34             ` [PATCH v2 01/16] Add a test for let-binding unwinding Spencer Baugh
2020-11-25 20:53               ` Stefan Monnier
2020-11-30 17:31                 ` Spencer Baugh
2020-12-01 16:44               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 02/16] Assert not local-variable-p after setq in let_default binding Spencer Baugh
2020-11-25 20:54               ` Stefan Monnier
2020-12-01 16:45               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 03/16] Stop checking the constant default for enable_multibyte_characters Spencer Baugh
2020-11-25 20:57               ` Stefan Monnier
2020-12-01 16:52               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 04/16] Take buffer field name in DEFVAR_PER_BUFFER Spencer Baugh
2020-12-01 16:56               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 05/16] Add BVAR_DEFAULT for access to buffer defaults Spencer Baugh
2020-12-01 17:00               ` Eli Zaretskii
2020-11-22  2:34             ` Spencer Baugh [this message]
2020-12-01 17:12               ` [PATCH v2 06/16] Use bset_* functions instead of BVAR Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 07/16] Take offset not idx in PER_BUFFER_VALUE_P Spencer Baugh
2020-12-01 17:20               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 08/16] Combine unnecessarily separate loops in buffer.c Spencer Baugh
2020-12-01 17:22               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 09/16] Add and use BUFFER_DEFAULT_VALUE_P Spencer Baugh
2020-12-01 17:24               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 10/16] Add and use KILL_PER_BUFFER_VALUE Spencer Baugh
2020-12-01 17:26               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 11/16] Assert that PER_BUFFER_IDX for Lisp variables is not 0 Spencer Baugh
2020-12-01 17:32               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 12/16] Rearrange set_internal for buffer forwarded symbols Spencer Baugh
2020-12-01 17:35               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 13/16] Get rid of buffer_permanent_local_flags array Spencer Baugh
2020-11-22 16:16               ` Eli Zaretskii
2020-12-01 17:39               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 14/16] Remove unnecessary Qunbound check Spencer Baugh
2020-12-01 17:40               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 15/16] Remove local_flags array in struct buffer Spencer Baugh
2020-11-22 20:04               ` Stefan Monnier
2020-12-01 17:57               ` Eli Zaretskii
2020-11-22  2:34             ` [PATCH v2 16/16] Remove usage of buffer_local_flags Spencer Baugh
2020-12-01 18:05               ` Eli Zaretskii
2020-11-22 11:19             ` [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER Kévin Le Gouguec
2020-11-22 16:12             ` Eli Zaretskii
2020-11-22 16:28               ` Spencer Baugh
2020-11-22 17:13                 ` Eli Zaretskii
2020-11-29 17:41                   ` Spencer Baugh
2020-11-30 18:32                     ` Eli Zaretskii
2020-11-30 20:11                       ` Spencer Baugh
2020-11-30 22:10                         ` Stefan Monnier
2020-11-30 22:26                           ` Andrea Corallo via Emacs development discussions.
2020-12-01 15:15                           ` Eli Zaretskii
2020-12-01 15:56                             ` Stefan Monnier
2020-12-01 15:10                         ` Eli Zaretskii
2020-12-01 15:20                           ` Spencer Baugh
2020-12-01 16:01                           ` Stefan Monnier
2020-12-01 16:16                             ` Eli Zaretskii
2020-12-01 18:10                       ` Eli Zaretskii
2020-11-22 20:11                 ` Stefan Monnier
2020-11-19 15:38         ` [PATCH 01/10] Take buffer field name in DEFVAR_PER_BUFFER Spencer Baugh
2020-11-19 15:38         ` [PATCH 02/10] Add bset_save_length and use it Spencer Baugh
2020-11-19 15:38         ` [PATCH 03/10] Use bset_last_selected_window everywhere Spencer Baugh
2020-11-19 15:38         ` [PATCH 04/10] Use bset_enable_multibyte_characters everywhere Spencer Baugh
2020-11-19 15:38         ` [PATCH 05/10] Add BVAR_DEFAULT for access to buffer defaults Spencer Baugh
2020-11-19 15:38         ` [PATCH 06/10] Disallow using BVAR as an lvalue Spencer Baugh
2020-11-19 15:38         ` [PATCH 07/10] Reorder buffer.h for upcoming rework of BVAR Spencer Baugh
2020-11-19 15:38         ` [PATCH 08/10] Make cache_long_scans buffer-local when setting it Spencer Baugh
2020-11-19 15:38         ` [PATCH 09/10] Access buffer_defaults in BVAR if there's no local binding Spencer Baugh
2020-11-19 18:08           ` Stefan Monnier
2020-11-19 18:21             ` Eli Zaretskii
2020-11-19 15:38         ` [PATCH 10/10] Don't iterate over all buffers in set_default_internal Spencer Baugh
2020-11-19 18:21           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9b43dc231149dc6f272d39d966698b770efb276a.1606009917.git.sbaugh@catern.com \
    --to=sbaugh@catern.com \
    --cc=arnold@tdrhq.com \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).