emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-25 3ca44a1: Call 'window-size-change-functions' for


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 3ca44a1: Call 'window-size-change-functions' for mini-windows
Date: Sat, 21 Nov 2015 11:32:35 +0000

branch: emacs-25
commit 3ca44a1ad414c5e5b07f35959ce21f01064476a8
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Call 'window-size-change-functions' for mini-windows
    
    * src/window.c (grow_mini_window, shrink_mini_window): Set the
    frame's 'window_sizes_changed' flag.
    * src/xdisp.c (redisplay_internal): Call the hooks on
    'window-size-change-functions' if the call to 'echo_area_display'
    sets the frame's 'window_sizes_changed' flag.
    (syms_of_xdisp) <window-size-change-functions>:
    Update doc string to indicate the mini-window resizes trigger a
    call to the hooks, and don't promise that will happen "before
    redisplay".  (Bug#19576, Bug#21333)
    
    * doc/lispref/windows.texi (Window Hooks): Update the description
    of 'window-size-change-functions'.
---
 doc/lispref/windows.texi |    8 ++++----
 src/window.c             |    2 ++
 src/xdisp.c              |   36 ++++++++++++++++++++++++++++++++----
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index 357247e..d0f6254 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -4264,10 +4264,10 @@ work.
 @end defvar
 
 @defvar window-size-change-functions
-This variable holds a list of functions to be called if the size of any
-window changes for any reason.  The functions are called just once per
-redisplay, and just once for each frame on which size changes have
-occurred.
+This variable holds a list of functions to be called if the size of
+any window changes for any reason.  The functions are called at the
+beginning of a redisplay cycle, and just once for each frame on which
+size changes have occurred.
 
 Each function receives the frame as its sole argument.  There is no
 direct way to find out which windows on that frame have changed size, or
diff --git a/src/window.c b/src/window.c
index 0ac76d4..753c4ab 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4555,6 +4555,7 @@ grow_mini_window (struct window *w, int delta, bool 
pixelwise)
          /* Enforce full redisplay of the frame.  */
          /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
          fset_redisplay (f);
+         FRAME_WINDOW_SIZES_CHANGED (f) = true;
          adjust_frame_glyphs (f);
          unblock_input ();
        }
@@ -4594,6 +4595,7 @@ shrink_mini_window (struct window *w, bool pixelwise)
          /* Enforce full redisplay of the frame.  */
          /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
          fset_redisplay (f);
+         FRAME_WINDOW_SIZES_CHANGED (f) = true;
          adjust_frame_glyphs (f);
          unblock_input ();
        }
diff --git a/src/xdisp.c b/src/xdisp.c
index 30dfac5..85d356e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13536,6 +13536,32 @@ redisplay_internal (void)
     {
       echo_area_display (false);
 
+      /* If echo_area_display resizes the mini-window, the redisplay and
+        window_sizes_changed flags of the selected frame are set, but
+        it's too late for the hooks in window-size-change-functions,
+        which have been examined already in prepare_menu_bars.  So in
+        that case we call the hooks here only for the selected frame.  */
+      if (sf->redisplay && FRAME_WINDOW_SIZES_CHANGED (sf))
+       {
+         Lisp_Object functions;
+         ptrdiff_t count1 = SPECPDL_INDEX ();
+
+         record_unwind_save_match_data ();
+
+         /* Clear flag first in case we get an error below.  */
+         FRAME_WINDOW_SIZES_CHANGED (sf) = false;
+         functions = Vwindow_size_change_functions;
+
+         while (CONSP (functions))
+           {
+             if (!EQ (XCAR (functions), Qt))
+               call1 (XCAR (functions), selected_frame);
+             functions = XCDR (functions);
+           }
+
+         unbind_to (count1, Qnil);
+       }
+
       if (message_cleared_p)
        update_miniwindow_p = true;
 
@@ -31132,11 +31158,13 @@ the buffer when it becomes large.  */);
   Vmessage_log_max = make_number (1000);
 
   DEFVAR_LISP ("window-size-change-functions", Vwindow_size_change_functions,
-    doc: /* Functions called before redisplay, if window sizes have changed.
+    doc: /* Functions called during redisplay, if window sizes have changed.
 The value should be a list of functions that take one argument.
-Just before redisplay, for each frame, if any of its windows have changed
-size since the last redisplay, or have been split or deleted,
-all the functions in the list are called, with the frame as argument.  */);
+During the first part of redisplay, for each frame, if any of its windows
+have changed size since the last redisplay, or have been split or deleted,
+all the functions in the list are called, with the frame as argument.
+If redisplay decides to resize the minibuffer window, it calls these
+functions on behalf of that as well.  */);
   Vwindow_size_change_functions = Qnil;
 
   DEFVAR_LISP ("window-scroll-functions", Vwindow_scroll_functions,



reply via email to

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