Subject: bug#70038: 29.3.50; Shift up/down in buffer with images on M-x other-window with some fonts

From: martin rudalics <[email-masked]>
Date: Mon, 8 Apr 2024 11:07:50 +0200

IIUC the basic idea of all this is to preserve window start positions
when enlarging a mini window unless that would move a window's point
outside that window.  Once upon a time, resize_mini_window used window
configurations to get back the previous start positions but that was
maybe considered too costly and Gerd decided to "Don't save window
configuration, freeze window starts instead."

A possibly heretical question is in which way freezing start positions
permanently can harm.  IIUC, after a minibuffer interaction, currently
the only way to unfreeze start positions is to resize the minibuffer
window and trigger the corresponding call in shrink_mini_window.  But
setting the start position of any window while a minibuffer interaction
is going on seems to work here without problems.

Let's assume it can harm:

 >> If the only
 >> problem is that of restore_window_configuration, then minibuffer_unwind
 >> looks like the right place.

That was silly.  minibuffer_unwind seems to care only about replacing
one minibuffer with another.  read_minibuf_unwind already should handle
this here (don't ask me what a future_mini_window is)

   /* When we get to the outmost level, make sure we resize the
      mini-window back to its normal size.  */
   if (minibuf_level == 0
       || !EQ (selected_frame, WINDOW_FRAME (XWINDOW (future_mini_window))))
     resize_mini_window (XWINDOW (minibuf_window), 0);

The only problem is that if the mini window was _not_ enlarged,
shrink_mini_window won't unfreeze starts.  Unconditionally unfreezing
start positions there as I mentioned in my first mail should fix that.

 > Hmm...  read_char_help_form_unwind is called after we invoke
 > help-form-show, and that one pops up a special buffer:
 >
 >    (defun help-form-show ()
 >      "Display the output of a non-nil `help-form'."
 >      (let ((msg (eval help-form t)))
 >        (if (stringp msg)
 > 	  (with-output-to-temp-buffer " *Char Help*"
 > 	    (princ msg)))))
 >
 > Is there a way to make that use the echo-area? if so, can you tell how
 > to do that?

IIUC that is called in a situation where the minibuffer is active.
Showing that text in the echo area (albeit shortly) doesn't look like
TRT to me.

IIUC read_char can resize the mini window here

	  if (minibuf_level
	      && EQ (minibuf_window, echo_area_window)
	      /* The case where minibuffer-message-timeout is a number
		 was already handled near the beginning of command_loop_1.  */
	      && !NUMBERP (Vminibuffer_message_timeout))
	    resize_mini_window (XWINDOW (minibuf_window), false);

so this should be covered by read_minibuf_unwind already.

martin