Subject: bug#12766: read-from-minibuffer does not preserve current-buffer

From: martin rudalics <[email-masked]>
Date: Tue, 30 Oct 2012 11:27:58 +0100

> % src/emacs -Q --eval "(setq initial-frame-alist '((minibuffer . nil)))"
 > M-: (with-temp-buffer (list (read-string "toto: ") (current-buffer))) RET
 >
 > In Emacs 24.2 this always shows the current-buffer to be the temp buffer
 > (which is a killed buffer by the time M-: prints its result).
 > But in Emacs trunk, the result depends on whether you issue the M-:
 > from the normal frame (where it works right) or from the special
 > minibuffer-only frame, where current-buffer after read-string is
 > *minibuf-0*!
 >
 > This is a serious problem, which introduces subtle bugs that can be
 > pretty difficult to track down.

Two changes I made could be involved:

(1) `select-window' now always makes the window's buffer current.

(2) read_minibuf now calls set_window_buffer instead of
     Fset_window_buffer.

And there's also bug#10851 where `read-char-by-name' could change the
current buffer.

Also, is this related to the comment

        ;; FIXME: kill-buffer can change current-buffer in some odd cases.

in `with-temp-buffer'?

martin