all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>, martin rudalics <rudalics@gmx.at>
Cc: 19576@debbugs.gnu.org, andlind@gmail.com, juri@linkov.net
Subject: bug#19576: write-file writes the wrong buffer
Date: Wed, 18 Nov 2015 19:45:03 +0200	[thread overview]
Message-ID: <83lh9v9p7k.fsf@gnu.org> (raw)
In-Reply-To: <20151117200204.GA5054@acm.fritz.box>

> Date: Tue, 17 Nov 2015 20:02:04 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: 19576@debbugs.gnu.org
> 
> On Tue, Nov 17, 2015 at 02:55:39AM +0200, Juri Linkov wrote:
> > >> Conceptually it should be easy to do that.  Save/restore current buffer,
> > >> selected window and frame.  But Alan (concerned about ‘follow-mode’),
> > >> Pip (who unfortunately disappeared) and Eli are currently discussing how
> > >> to fix ‘window-size-change-functions’ in various other ways as well.
> 
> I have a fix for the `window-size-change-functions' problem, which I
> posted just over an hour ago (see bug #21869 or #21333).  The fix
> consists of only invoking w-s-c-f after any change to the echo area size
> has been done.  This might have some relevance for the current bug.  (I
> haven't followed the current bug, I'm afraid.)  I really need the
> go-ahead from Eli before I can commit the fix to the emacs-25 or master
> branch.

Thanks for working on this, and sorry for the delay in reviewing your
suggested changes.

> I propose the following strategy to fix the bug:
> 
> 1. Call resize_mini_window from redisplay_internal before the call to
>   prepare_menu_bars.
> 2. Remove the call to resize_mini_window from display_echo_area_1, and
>   make that function of type void.
> 3. Change the contract of echo_area_display, such that the echo area
>   must have been set to the correct height before calling it.
> 4. Adapt message3_nolog (the only other function which calls
>   echo_area_display) to call resize_mini_window.
> 
> As a result of these changes, any change in the size of the echo area
> would be taken into account when invoking window-size-change-functions.

I must say I prefer to avoid changes in the processing order of the
display engine, unless they are absolutely necessary and we understand
very well the effect of the order change.  Which IMO is not the case
here.

Could you try a simpler patch below?  It seems to fix both your test
case and the one originally reported in bug#21333.

Martin, is there any reason why window_resize_apply doesn't set the
frame's window_sizes_changed flag, but instead relies on its callers
to do that?

--- src/window.c~0	2015-11-11 07:57:56.000000000 +0200
+++ src/window.c	2015-11-18 18:47:51.875303700 +0200
@@ -4555,6 +4555,7 @@ grow_mini_window (struct window *w, int 
 	  /* 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, bo
 	  /* 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 ();
 	}
--- src/xdisp.c~0	2015-11-11 07:57:43.000000000 +0200
+++ src/xdisp.c	2015-11-18 18:53:32.333087700 +0200
@@ -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;
 






  parent reply	other threads:[~2015-11-18 17:45 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 23:37 bug#19576: 24.4; Broken function in `window-size-change-functions' cause `write-file' to write the wrong buffer Anders Lindgren
2015-11-16 19:18 ` bug#19576: write-file writes " Anders Lindgren
2015-11-16 19:46   ` martin rudalics
2015-11-16 20:05     ` Anders Lindgren
2015-11-17  0:55       ` Juri Linkov
2015-11-17 20:02         ` Alan Mackenzie
2015-11-17 21:52           ` Anders Lindgren
2015-11-18  0:27             ` Juri Linkov
2015-11-18  1:37               ` Drew Adams
2015-11-18  7:54               ` Anders Lindgren
2015-11-18 17:45           ` Eli Zaretskii [this message]
2015-11-18 23:23             ` Alan Mackenzie
2015-11-19 16:03               ` Eli Zaretskii
2015-11-20  8:22                 ` martin rudalics
2015-11-20 10:17                   ` Eli Zaretskii
2015-11-20 10:48                     ` martin rudalics
2015-11-20 11:16                       ` Eli Zaretskii
2015-11-20 11:25                         ` martin rudalics
2015-11-20 11:40                           ` Eli Zaretskii
2015-11-20 14:21                             ` martin rudalics
2015-11-20 14:54                               ` Eli Zaretskii
2015-11-21 11:35                 ` Eli Zaretskii
2015-11-21 15:56                   ` Alan Mackenzie
2015-11-21 16:01                     ` Eli Zaretskii
2015-11-21 16:49                       ` Anders Lindgren
2015-11-21 17:10                         ` Eli Zaretskii
2015-11-21 18:27                         ` martin rudalics
2015-11-21 18:33                           ` Eli Zaretskii
2015-11-21 18:44                             ` martin rudalics
2015-11-21 19:08                               ` Eli Zaretskii
2015-11-21 20:33                                 ` Anders Lindgren
2015-11-22 10:44                                 ` martin rudalics
2015-11-22 15:36                                   ` Eli Zaretskii
2015-11-21 16:02                     ` bug#21333: " Eli Zaretskii
2015-11-22 11:08                   ` martin rudalics
2015-11-22 15:39                     ` Eli Zaretskii
2015-11-22 17:46                       ` martin rudalics
2015-11-23 18:21                         ` Eli Zaretskii
2015-11-23 18:28                           ` Alan Mackenzie
2015-11-24  8:27                           ` martin rudalics
2015-11-24 16:19                             ` Eli Zaretskii
2015-11-28 10:26                   ` martin rudalics
2015-11-28 11:27                     ` Eli Zaretskii
2015-11-30 13:30                       ` martin rudalics
2015-11-30 16:28                         ` Eli Zaretskii
2015-11-30 17:27                           ` martin rudalics
2015-11-19  8:13             ` martin rudalics
2015-11-19 15:45               ` Eli Zaretskii
2015-11-20  8:22                 ` martin rudalics
2015-11-20  8:34                   ` Eli Zaretskii
2015-11-20 10:25                     ` martin rudalics
2015-11-20 11:15                       ` Eli Zaretskii
2015-11-20 11:25                         ` martin rudalics
2015-11-20 11:39                           ` Eli Zaretskii
2015-11-20 14:21                             ` martin rudalics
2015-11-20 11:32                         ` Alan Mackenzie
2015-11-20 11:41                           ` Eli Zaretskii
2015-11-17 21:15         ` Anders Lindgren
2015-11-18 17:52           ` Eli Zaretskii
2015-11-18 19:23             ` Anders Lindgren
2015-11-18 20:52               ` Eli Zaretskii
2015-11-19  2:06                 ` John Wiegley
2015-11-19  6:54                 ` Anders Lindgren
2015-11-19 15:31                   ` Eli Zaretskii
2015-11-22 18:44                     ` Johan Bockgård
2015-11-22 18:55                       ` Johan Bockgård
2015-11-22 19:02                       ` Eli Zaretskii
2015-11-17  8:34       ` martin rudalics
2015-11-17 19:08         ` Anders Lindgren
2015-11-18 17:24         ` Eli Zaretskii
2015-11-19  8:12           ` martin rudalics
2015-11-19 15:44             ` Eli Zaretskii
2015-11-20  8:22               ` martin rudalics
2015-11-20  8:32                 ` Eli Zaretskii
     [not found] ` <mailman.9.1447720293.31583.bug-gnu-emacs@gnu.org>
2015-11-17 22:10   ` Alan Mackenzie
2015-11-18  7:09     ` martin rudalics
2015-11-20 20:17 ` bug#19576: Fixed: " Anders Lindgren

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

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

  git send-email \
    --in-reply-to=83lh9v9p7k.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=19576@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=andlind@gmail.com \
    --cc=juri@linkov.net \
    --cc=rudalics@gmx.at \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.