From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Miles Bader Newsgroups: gmane.emacs.devel Subject: Re: with-current-buffer (was: fit-window-to-buffer) Date: Mon, 27 Jun 2005 15:28:54 +0900 Message-ID: References: <87aclcu3vy.fsf@jurta.org> Reply-To: snogglethorpe@gmail.com, miles@gnu.org NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1119856494 3281 80.91.229.2 (27 Jun 2005 07:14:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2005 07:14:54 +0000 (UTC) Cc: lekktu@gmail.com, rms@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 27 09:14:49 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Dmnot-0001rx-Mg for ged-emacs-devel@m.gmane.org; Mon, 27 Jun 2005 09:14:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DmnwU-0005vj-FK for ged-emacs-devel@m.gmane.org; Mon, 27 Jun 2005 03:22:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DmnBk-00078Z-Rr for emacs-devel@gnu.org; Mon, 27 Jun 2005 02:33:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DmnBg-00077j-OO for emacs-devel@gnu.org; Mon, 27 Jun 2005 02:33:46 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DmnBg-000775-4D for emacs-devel@gnu.org; Mon, 27 Jun 2005 02:33:44 -0400 Original-Received: from [64.233.184.206] (helo=wproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DmnB9-00062m-GM for emacs-devel@gnu.org; Mon, 27 Jun 2005 02:33:11 -0400 Original-Received: by wproxy.gmail.com with SMTP id 40so255214wri for ; Sun, 26 Jun 2005 23:28:54 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HyhEWHZQG/1Bd/1hGXB54v83GLew1ScQsJqw+VCl8rKBN/FyIHJ8sGqlXm8E8IOGWAQzzqG98zkiFTfuchMk2CNV7vxPNUAUmCpRk8qhFzwr8BFqHnjq+jccjHUZNOsri3a5FfCux5a7FbeApif/4NYv7E74ydk6OgvPOWFOdCA= Original-Received: by 10.54.19.68 with SMTP id 68mr87067wrs; Sun, 26 Jun 2005 23:28:54 -0700 (PDT) Original-Received: by 10.54.19.31 with HTTP; Sun, 26 Jun 2005 23:28:54 -0700 (PDT) Original-To: Juri Linkov In-Reply-To: <87aclcu3vy.fsf@jurta.org> Content-Disposition: inline X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:39627 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:39627 On 6/27/05, Juri Linkov wrote: > (with-current-buffer "c" > (pop-to-buffer "b")) > (message "%s" (buffer-name (current-buffer)))) >=20 > 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 --=20 Do not taunt Happy Fun Ball.