Subject: Re: bug#67715: 28.2; Minibuffer content is sometimes unexpectedly partially hidden

From: Eli Zaretskii <[email-masked]>
Date: Sun, 10 Dec 2023 07:44:34 +0200

> From: Markus Triska <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 09 Dec 2023 22:11:34 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > I'm not sure I understood, but if you put a face on some text, and
> > then type at the end of that text, the additional text you type is
> > supposed to "inherit" that face, no?
> 
> I mean: When my program runs, I do not type anything myself, but the
> program simulates that something is being typed by me. For example, when
> I ask the program to perform one step, it may simulate that M-x is
> pressed, by inserting the text "M-x " in the minibuffer, and then wait
> for further instructions (by me). When I then ask the program to perform
> the next step, it may simulate that "emacs-uptime" is being typed, and
> thus incrementally add the letters "e", "m", "a", ... to the minibuffer
> while waiting for a short amount of time after each letter, until (in
> total) "M-x emacs-uptime" appears in the minibuffer. The goal is that we
> can simulate the effects of typing while minimizing manual effort.
> 
> This all already works as expected in Emacs versions before 28.2, and it
> works to a large extent also in later versions. The only remaining
> problem I have with Emacs 28.2 and later versions is that in situations
> like the one I posted, the minibuffer is no longer adequately grown to
> fully display the text it contains (because the program wrote it there).
> 
> With your snippet, I can work around a very specific case of this, where
> a single string is shown in the minibuffer. For my use case though, this
> is not yet enough, because my program simulates manual edits by changing
> text in the minibuffer, such as adding or removing individual letters.

You could perhaps use 'message'.  Here's a trivial demo:

  (defun my-msg ()
    (interactive)
    (message (propertize "something" 'face '(:height 2.0))))
  (defun my-msg2 ()
    (interactive)
    (message (propertize "something else" 'face '(:height 2.0))))
  (global-set-key [f5] 'my-msg)
  (global-set-key [f6] 'my-msg2)

Evaluate the above, then press F5 followed by F6.

> I am therefore interested in ways to grow the minibuffer so that it is
> large enough, while allowing very flexible editing operations to be
> simulated in it that go beyond showing a single string.

I'm showing you all the methods I can come up with.  Maybe Martin or
others will have better ideas (so please don't elide their addresses
when replying).