Subject: bug#18422: 24.3.93; Assertion violation when resizing mini-window on a TTY

From: Eli Zaretskii <[email-masked]>
Date: Tue, 09 Sep 2014 16:12:21 +0300

> Date: Mon, 08 Sep 2014 11:31:34 +0200
> From: martin rudalics <[email-masked]>
> 
> One possible fix would be:
> 
> === modified file 'lisp/window.el'
> --- lisp/window.el	2014-08-29 10:39:17 +0000
> +++ lisp/window.el	2014-09-08 08:45:23 +0000
> @@ -2388,6 +2388,8 @@
>   	;; why we do not do that.
>   	(window--resize-this-window root (- delta) nil nil t)
>   	(set-window-new-pixel window (+ height delta))
> +	(set-window-new-total window (/ (window-new-pixel window)
> +					(frame-char-height frame)))
>   	;; The following routine catches the case where we want to resize
>   	;; a minibuffer-only frame.
>   	(when (resize-mini-window-internal window)
> 
> 
> 
> But I'm afraid that other windows might be affected as well so I'd
> prefer to do this instead:
> 
> === modified file 'src/dispnew.c'
> --- src/dispnew.c	2014-09-08 06:00:58 +0000
> +++ src/dispnew.c	2014-09-08 09:04:18 +0000
> @@ -1708,7 +1708,7 @@
>       }
>   #endif /* HAVE_WINDOW_SYSTEM */
> 
> -  return WINDOW_TOTAL_LINES (w);
> +  return WINDOW_PIXEL_HEIGHT (w);
>   }
> 
> 
> @@ -1734,7 +1734,7 @@
>       }
>   #endif /* HAVE_WINDOW_SYSTEM */
> 
> -  return w->total_cols;
> +  return WINDOW_PIXEL_WIDTH (w);
>   }

I already tried this before reporting the bug.  It doesn't work,
because we then hit these assertions in fake_current_matrices:

	  eassert (m->matrix_h == WINDOW_TOTAL_LINES (w));
	  eassert (m->matrix_w == WINDOW_TOTAL_COLS (w));

In general, I think it's a bad idea to have bogus values in
WINDOW_TOTAL_LINES and WINDOW_TOTAL_COLS, they are not documented to
be invalid under any circumstances, so the code relies on them.

What exactly frightens you in your first proposal?  Perhaps we should
install my patch on the emacs-24 branch and your window.el patch on
the trunk?