Suppose that I have this function, that inserts some stuff into the minibuffer:
(defun foobar () (interactive) (minibuffer-with-setup-hook (lambda () (let ((resize-mini-windows t)) (save-excursion (insert "foo\nbar") (fit-window-to-buffer)))) (read-from-minibuffer "string: "))) (global-set-key (kbd "M-RET") 'foobar)
It works fine if I call it from any buffer, except when I'm already in the minibuffer.
For example, if I eval
(read-from-minibuffer "test: "), and then press M-RET, my minibuffer becomes
string: foo (note the 1 line height). After I press any character, I see that
bar is also in the minibuffer. The problem is that the minibuffer height won't update until I press any character.
Why does this happen and how to get around it?