unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 12766@debbugs.gnu.org
Subject: bug#12766: read-from-minibuffer does not preserve current-buffer
Date: Tue, 30 Oct 2012 19:49:23 +0100	[thread overview]
Message-ID: <50902133.1070703@gmx.at> (raw)
In-Reply-To: <jwvk3u8krdi.fsf-monnier+emacs@gnu.org>

 >>> % src/emacs -Q --eval "(setq initial-frame-alist '((minibuffer . nil)))"
 >>> M-: (with-temp-buffer (list (read-string "toto: ") (current-buffer))) RET
 >> 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.
 >
 > I think (1) is more likely to be the problem.

Verified (sloppily).

 > Could you check
 > read_minibuf to see which unwind is supposed to reset the
 > current buffer?

IIUC read_minibuf doesn't care about restoring the current buffer.

 > Maybe that code worked by accident (.e.g relying on the fact that
 > select-window didn't set current-buffer in that corner case) and the
 > right fix is simply to explicitly save&restore current buffer.

FWIW the problem already happens when choose_minibuf_frame calls
Fset_frame_selected_window.  The patch below seems to fix it.

martin, completely lost in the labyrinth of read_minibuf


*** src/minibuf.c	2012-10-11 16:23:37 +0000
--- src/minibuf.c	2012-10-30 18:25:26 +0000
***************
*** 472,477 ****
--- 472,479 ----

     /* Choose the minibuffer window and frame, and take action on them.  */

+   record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+
     choose_minibuf_frame ();

     record_unwind_protect (choose_minibuf_frame_1, Qnil);






  reply	other threads:[~2012-10-30 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-29 20:29 bug#12766: read-from-minibuffer does not preserve current-buffer Stefan Monnier
2012-10-30 10:27 ` martin rudalics
2012-10-30 13:51   ` Stefan Monnier
2012-10-30 18:49     ` martin rudalics [this message]
2012-10-30 19:21       ` Stefan Monnier
2012-10-31 10:27         ` martin rudalics
2012-10-31 14:07           ` Stefan Monnier
2012-11-09  9:50         ` martin rudalics
2012-11-09 14:20           ` Stefan Monnier
2012-11-10 11:07             ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50902133.1070703@gmx.at \
    --to=rudalics@gmx.at \
    --cc=12766@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).