unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: martin rudalics <rudalics@gmx.at>
Cc: 12766@debbugs.gnu.org
Subject: bug#12766: read-from-minibuffer does not preserve current-buffer
Date: Tue, 30 Oct 2012 09:51:18 -0400	[thread overview]
Message-ID: <jwvk3u8krdi.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <508FABAE.4050104@gmx.at> (martin rudalics's message of "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
> 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.  Could you check
read_minibuf to see which unwind is supposed to reset 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.

> Also, is this related to the comment
>        ;; FIXME: kill-buffer can change current-buffer in some odd cases.
> in `with-temp-buffer'?

No, (current-buffer) is evaluated before the buffer gets killed, and the
bug shows up with with-temp-buffer (the recipe is just shorter with
with-temp-buffer, but you can try it with (with-current-buffer
(get-buffer-create " *sm-test*") ...) to convince yourself).


        Stefan





  reply	other threads:[~2012-10-30 13:51 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 [this message]
2012-10-30 18:49     ` martin rudalics
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=jwvk3u8krdi.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=12766@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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).