11

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?

Drew
  • 75,699
  • 9
  • 109
  • 225
abo-abo
  • 13,943
  • 1
  • 29
  • 43
  • Your example in the question behaves fine (I can see both `foo` and `bar`). But I know that issue you are talking about and I have seen that frequently with `ido`, since last 2 or so weeks. But the issue doesn't repeat after the first few times you enter something in the minibuffer to increase its height. I am looking forward to the cause for this. I am using emacs built from master branch in git. – Kaushal Modi May 11 '15 at 18:48
  • What version of emacs are you using? I'm using 24.4.1 (from Debian unstable) and it works OK for me. When I go `M-x foobar`, I see `string: foo`[newline]`bar`. – edam Jun 24 '15 at 08:08
  • I tried 24.5 and 25. – abo-abo Jun 24 '15 at 08:22
  • You're right, it's a regression. It still works fine on 24.3.1, but is broken on 24.5 – abo-abo Jun 24 '15 at 08:26
  • It sounds like the consensus is that this is bug in 24.5. Someone please report it (`M-x report-emacs-bug`). And then post that as an answer (and OP please then accept that answer). – Drew Dec 04 '15 at 17:48
  • Any news on this? Did the bug get reported? Fixed? – Drew Oct 14 '16 at 20:37
  • @Drew Yes, it works fine on 27.2. – Akib Azmain Turja Jan 17 '22 at 12:24
  • Excellent. Please update your question with that info. And preferably provide a link to the bug report for anyone interested. (It's somewhere [here](https://debbugs.gnu.org/).) Comments can be deleted at any time. Questions and answers need to stand on their own, to be helpful (e.g. searchable). Thx. – Drew Jan 17 '22 at 17:29

0 Answers0