Oh, wait, of course it's not working, it's "minibuffer" window. And I need mini window. But I don't know how to select that.
The echo area is also used to display the minibuffer
From: pinkanon pinkanon <pinkanon.pinkanon@yandex.com>
Date: Mon, 05 Oct 2020 10:34:49 +0300
Eval this:
(progn (minibuffer-message "hello world") (print (format "current message: %s" (current-message))))
to get "current message: nil" in the *Messages*. If message is used in place of minibuffer message, works
as expected.
I think your expectations are incorrect, and Emacs works correctly in
this case.
The reason I think current-message should work with minibuffer-message is due to its docstring: "Return the
string currently displayed in the echo area, or nil if none."
The echo area and the minibuffer are two different buffers. They both
use the same mini-window to display their text, but they are not the
same.
Sorry, should've included this, I am basing my assumption on the manual
"The echo area is used to display the minibuffer".
Hmm. I guess I just want the contents of the mini window then, whether it was produced by message or minibuffer-message. And the realization that it's a window yields the following code, but it's not working...
(progn
(minibuffer-message "hello world")
(with-selected-window (minibuffer-window)
(print (format "ms: %s" (buffer-substring-no-properties (point-min) (point-max))))))