/* Minibuffer input and completion.
-Copyright (C) 1985-1986, 1993-2012 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
/* Choose the minibuffer window and frame, and take action on them. */
+ /* Prepare for restoring the current buffer since choose_minibuf_frame
+ calling Fset_frame_selected_window may change it (Bug#12766). */
+ record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
choose_minibuf_frame ();
record_unwind_protect (choose_minibuf_frame_1, Qnil);