emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master afd3619b86: src/xdisp.c: Use same test in `redisplay_window` and


From: Stefan Monnier
Subject: master afd3619b86: src/xdisp.c: Use same test in `redisplay_window` and `prepare_menu_bars`
Date: Wed, 27 Apr 2022 18:17:09 -0400 (EDT)

branch: master
commit afd3619b86ddf42c0591d394d95a7510758eaffb
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    src/xdisp.c: Use same test in `redisplay_window` and `prepare_menu_bars`
    
    This consolidates the test made in those two functions so as to make
    sure they agree whether a window needs to be redisplayed.
    At the same time, change this test so it uses the window's point
    rather than the buffer's point when comparing to `w->last_point`.
    
    * src/xdisp.c (needs_no_redisplay): New function, extracted from
    `redisplay_window`.
    (redisplay_window, prepare_menu_bars): Use it.
    
    * src/window.c (window_point): New function, extracted from `Fwindow_point`.
    (Fwindow_point): Use it.
    * src/window.h (window_point): Declare it.
---
 src/window.c | 15 +++++++++------
 src/window.h |  1 +
 src/xdisp.c  | 32 +++++++++++++++++---------------
 3 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/window.c b/src/window.c
index 4cca60e23d..48da783931 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1692,6 +1692,14 @@ column 0.  */)
                                  0, false, false);
 }
 
+ptrdiff_t
+window_point (struct window *w)
+{
+  return (w == XWINDOW (selected_window)
+          ? BUF_PT (XBUFFER (w->contents))
+          : XMARKER (w->pointm)->charpos);
+}
+
 DEFUN ("window-point", Fwindow_point, Swindow_point, 0, 1, 0,
        doc: /* Return current value of point in WINDOW.
 WINDOW must be a live window and defaults to the selected one.
@@ -1705,12 +1713,7 @@ correct to return the top-level value of `point', 
outside of any
 `save-excursion' forms.  But that is hard to define.  */)
   (Lisp_Object window)
 {
-  register struct window *w = decode_live_window (window);
-
-  if (w == XWINDOW (selected_window))
-    return make_fixnum (BUF_PT (XBUFFER (w->contents)));
-  else
-    return Fmarker_position (w->pointm);
+  return make_fixnum (window_point (decode_live_window (window)));
 }
 
 DEFUN ("window-old-point", Fwindow_old_point, Swindow_old_point, 0, 1, 0,
diff --git a/src/window.h b/src/window.h
index 94c9b7124f..387a3be36a 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1191,6 +1191,7 @@ extern void replace_buffer_in_windows_safely 
(Lisp_Object);
 /* This looks like a setter, but it is a bit special.  */
 extern void wset_buffer (struct window *, Lisp_Object);
 extern bool window_outdated (struct window *);
+extern ptrdiff_t window_point (struct window *w);
 extern void init_window_once (void);
 extern void init_window (void);
 extern void syms_of_window (void);
diff --git a/src/xdisp.c b/src/xdisp.c
index dccff9f2ea..6516f13c82 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13250,6 +13250,20 @@ gui_consider_frame_title (Lisp_Object frame)
    && (update_mode_lines == 0                          \
        || update_mode_lines == REDISPLAY_SOME))
 
+static bool
+needs_no_redisplay (struct window *w)
+{
+  struct buffer *buffer = XBUFFER (w->contents);
+  struct frame *f = XFRAME (w->frame);
+  return (REDISPLAY_SOME_P ()
+          && !w->redisplay
+          && !w->update_mode_line
+          && !f->face_change
+          && !f->redisplay
+          && !buffer->text->redisplay
+          && window_point (w) == w->last_point);
+}
+
 /* Prepare for redisplay by updating menu-bar item lists when
    appropriate.  This can call eval.  */
 
@@ -13271,13 +13285,8 @@ prepare_menu_bars (void)
              struct window *w = XWINDOW (this);
              /* Cf. conditions for redisplaying a window at the
                 beginning of redisplay_window.  */
-             if (w->redisplay
-                 || XFRAME (w->frame)->redisplay
-                 || XBUFFER (w->contents)->text->redisplay
-                 || BUF_PT (XBUFFER (w->contents)) != w->last_point)
-               {
-                 windows = Fcons (this, windows);
-               }
+             if (!needs_no_redisplay (w))
+               windows = Fcons (this, windows);
            }
        }
       safe__call1 (true, Vpre_redisplay_function, windows);
@@ -18946,14 +18955,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
   *w->desired_matrix->method = 0;
 #endif
 
-  if (!just_this_one_p
-      && REDISPLAY_SOME_P ()
-      && !w->redisplay
-      && !w->update_mode_line
-      && !f->face_change
-      && !f->redisplay
-      && !buffer->text->redisplay
-      && BUF_PT (buffer) == w->last_point)
+  if (!just_this_one_p && needs_no_redisplay (w))
     return;
 
   /* Make sure that both W's markers are valid.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]