emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c73cf35: Fix recent change in window.c


From: Eli Zaretskii
Subject: [Emacs-diffs] master c73cf35: Fix recent change in window.c
Date: Sat, 7 Jul 2018 03:46:44 -0400 (EDT)

branch: master
commit c73cf3548e7166a4ccffc578699c394b360ed0f5
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix recent change in window.c
    
    * src/window.c (scroll_command): Fix minor inefficiency in
    last change: don't call Fset_buffer if the buffer is already set to be
    what we want.  (Bug#31988)
---
 src/window.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/window.c b/src/window.c
index 8d1aed4..d3c7257 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5652,12 +5652,17 @@ scroll_command (Lisp_Object window, Lisp_Object n, int 
direction)
   w = XWINDOW (window);
   other_window = ! EQ (window, selected_window);
 
-  /* If given window's buffer isn't current, make it current for
-     the moment.  But don't screw up if window_scroll gets an error.  */
+  /* If given window's buffer isn't current, make it current for the
+     moment.  If the window's buffer is the same, but it is not the
+     selected window, we need to save-excursion to avoid affecting
+     point in the selected window (which would cause the selected
+     window to scroll).  Don't screw up if window_scroll gets an
+     error.  */
   if (other_window || XBUFFER (w->contents) != current_buffer)
     {
       record_unwind_protect_excursion ();
-      Fset_buffer (w->contents);
+      if (XBUFFER (w->contents) != current_buffer)
+       Fset_buffer (w->contents);
     }
 
   if (other_window)



reply via email to

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