all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Miles Bader <snogglethorpe@gmail.com>
Cc: lekktu@gmail.com, rms@gnu.org, emacs-devel@gnu.org
Subject: Re: with-current-buffer (was: fit-window-to-buffer)
Date: Mon, 27 Jun 2005 15:28:54 +0900	[thread overview]
Message-ID: <fc339e4a05062623285ca4563b@mail.gmail.com> (raw)
In-Reply-To: <87aclcu3vy.fsf@jurta.org>

On 6/27/05, Juri Linkov <juri@jurta.org> wrote:
>   (with-current-buffer "c"
>     (pop-to-buffer "b"))
>   (message "%s" (buffer-name (current-buffer))))
> 
> At the end, it print "a" as the current buffer name, but actually
> this command makes the buffer "b" current.  Shouldn't it print "b"?

I think this isn't a bug -- the `with-current-buffer' form of course
restores the current buffer to be "a" after the wrapped code is
finished; why would you expect differently?

As I understand it, what `pop-to-buffer' does is set the window-buffer
of the selected window, in _addition_ to setting the current buffer,
and the main emacs interaction loop always restores the current buffer
to be the window-buffer of the selected window when you look for the
next command.

So in your example, `pop-to-buffer' sets the current buffer and the
window-buffer-of-selected-widnow to be "b", then the
`with-current-buffer' form (correctly) restores the current buffer to
be "a" again, then you print your message [which says "current buffer
is a"], then the interaction loop goes to read a command, which sets
the current buffer based on the window state -- which is "b", because
of pop-to-buffer's effect.

-Miles
-- 
Do not taunt Happy Fun Ball.

  reply	other threads:[~2005-06-27  6:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-24  5:36 fit-window-to-buffer Richard M. Stallman
2005-06-24  8:21 ` fit-window-to-buffer Juanma Barranquero
2005-06-26 23:33 ` with-current-buffer (was: fit-window-to-buffer) Juri Linkov
2005-06-27  6:28   ` Miles Bader [this message]
2005-06-28  0:04     ` with-current-buffer Juri Linkov
2005-06-28 17:28       ` with-current-buffer Kevin Rodgers
2005-06-29  3:45         ` with-current-buffer Stefan Monnier
2005-06-29 17:45           ` with-current-buffer Kevin Rodgers
2005-06-28 18:47       ` with-current-buffer Richard M. Stallman
2005-06-28 23:52         ` next-error-hook (was: with-current-buffer) Juri Linkov
2005-06-27 16:46   ` with-current-buffer (was: fit-window-to-buffer) Richard M. Stallman

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

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

  git send-email \
    --in-reply-to=fc339e4a05062623285ca4563b@mail.gmail.com \
    --to=snogglethorpe@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=lekktu@gmail.com \
    --cc=miles@gnu.org \
    --cc=rms@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.