From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ami Fischman Newsgroups: gmane.emacs.devel Subject: Re: display-buffer vs. current-buffer vs. post-command-hook Date: Tue, 04 Oct 2016 20:03:51 +0000 Message-ID: References: <57F3C212.3020401@gmx.at> <57F3D3B6.7080201@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1144821ae17568053e0f8fbb X-Trace: blaine.gmane.org 1475611529 28436 195.159.176.226 (4 Oct 2016 20:05:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Oct 2016 20:05:29 +0000 (UTC) To: martin rudalics , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 04 22:05:25 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brVxT-0004C1-SQ for ged-emacs-devel@m.gmane.org; Tue, 04 Oct 2016 22:05:00 +0200 Original-Received: from localhost ([::1]:45056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVxS-0004VB-7G for ged-emacs-devel@m.gmane.org; Tue, 04 Oct 2016 16:04:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVwb-0004Tw-Qv for emacs-devel@gnu.org; Tue, 04 Oct 2016 16:04:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brVwa-0004Wt-0d for emacs-devel@gnu.org; Tue, 04 Oct 2016 16:04:05 -0400 Original-Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]:35359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brVwZ-0004WW-LQ for emacs-devel@gnu.org; Tue, 04 Oct 2016 16:04:03 -0400 Original-Received: by mail-io0-x234.google.com with SMTP id i202so84117422ioi.2 for ; Tue, 04 Oct 2016 13:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fischman-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=09jVA9tl6TS2bQh8edPxbp9pD8EydEzWttwBhJ3zlJk=; b=Jx483+sMiR7R6a4GDpKbXXSa4ohTKjlLqVLCucfB3HFwQmXr6SLVmRrr0tE6lxEtSt 6kZb+DiUbDiDWEri0++xjMoQ4WKEH38YJNtu07qK82TzRFY4ikgMwEwv5LYGNoTtHaLI q3+Wg7SzX81o+2CapN+S3nOG0xYT2VOYl9mrn1vmC4oQ6isTltV6T6lUfqcwTODV52vd tdA3LHcEYQ6iviXP+JYYPjdEeMUGpK+7+SeNy3XKnVrhFzX1Pja0UwbsiAiU59J9TyqQ A3K8SHmmPA1EPrPALJBNj2Glgx54qmZtbdPDpezEVAZYOlzaXWVZA60PooedOBLlFn8j s9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=09jVA9tl6TS2bQh8edPxbp9pD8EydEzWttwBhJ3zlJk=; b=I7v6n7hxFTSF8Uy43tbR7dNWBkPzFPm2/7TbFL43YLS/NSr9t2X38NafDroYUNLQS8 yrU6llk5uxXEftLk+9+ErMUOmO6PEwshL4bb+KOxSpKgaQgQx4fm4CtKIz5m1joWzVjv j1zHClmTFtZg+dToCVTaZ3HDKaD0BV8D6lw6aWtwBr4UH9pgKa0vtGS79aIQy9K7YwMV NBL2k/nYJjQufXptM1n6IvsGqGjnHf1GRSSDf2NeUNMNiJZEkjm3zxHY1DSMmkxTwXf5 JHWEeqeuB0kJ+Pr5U6k+Ypp1jExWDMRjQeNfUmeaSFkVMA2/t3dxY4r4QdcP895TfNIU RhVw== X-Gm-Message-State: AA6/9Rkp/FCAf0A+bpcu/p+xRoFRnczhDMe7vLukwfpAgWN+C4jQM8+hvSDEjr718PkDENib2OZaliAYTS2V7g== X-Received: by 10.107.174.134 with SMTP id n6mr6366343ioo.177.1475611442893; Tue, 04 Oct 2016 13:04:02 -0700 (PDT) In-Reply-To: <57F3D3B6.7080201@gmx.at> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c06::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207985 Archived-At: --001a1144821ae17568053e0f8fbb Content-Type: text/plain; charset=UTF-8 Thanks Martin! That's exactly the thing I was missing. https://www.gnu.org/software/emacs/manual/html_node/elisp/Current-Buffer.html#Current-Buffer On Tue, Oct 4, 2016 at 9:07 AM martin rudalics wrote: > > I'm sorry but I don't understand your statement. Should there not be an > > expectation that (current-buffer)'s return value does not change between > > the second and third call in my original snippet? > > No. The primary concern is that the current buffer must not be changed > by `describe-key' or any other function that uses a temporary buffer to > display its results. > > > Put another way, under what circumstances should one expect > > current-buffer's return value to be stable in user-written elisp? > > The current buffer should never be changed by any function, unless it is > a purpose of that function to change the current buffer. > > > Put a third way, what about describe-keys documentation should lead an > > elisp author to understand that current-buffer will not reflect its > effect > > until after a [run-at-time 0]? > > (sorry for the barrage of questions; I feel there's a fundamental > something > > I'm missing in play here and trying to see if you know what it is :)) > > I suppose you missed the following aspect described in section 26.2 of > the Elisp manual entitled "The Current Buffer": > > When an editing command returns to the editor command loop, Emacs > automatically calls `set-buffer' on the buffer shown in the selected > window. > > [run-at-time 0] clearly runs after that. > > martin > --001a1144821ae17568053e0f8fbb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Martin!=C2=A0 That's exactly the thing I was mi= ssing.=C2=A0

On Tue, Oct = 4, 2016 at 9:07 AM martin rudalics <r= udalics@gmx.at> wrote:
=C2= =A0> I'm sorry but I don't understand your statement.=C2=A0 Shou= ld there not be an
=C2=A0> expectation that (current-buffer)'s return value does not ch= ange between
=C2=A0> the second and third call in my original snippet?

No.=C2=A0 The primary concern is that the current buffer must not be change= d
by `describe-key' or any other function that uses a temporary buffer to=
display its results.

=C2=A0> Put another way, under what circumstances should one expect
=C2=A0> current-buffer's return value to be stable in user-written e= lisp?

The current buffer should never be changed by any function, unless it is a purpose of that function to change the current buffer.

=C2=A0> Put a third way, what about describe-keys documentation should l= ead an
=C2=A0> elisp author to understand that current-buffer will not reflect = its effect
=C2=A0> until after a [run-at-time 0]?
=C2=A0> (sorry for the barrage of questions; I feel there's a fundam= ental something
=C2=A0> I'm missing in play here and trying to see if you know what = it is :))

I suppose you missed the following aspect described in section 26.2 of
the Elisp manual entitled "The Current Buffer":

=C2=A0 =C2=A0When an editing command returns to the editor command loop, Em= acs
=C2=A0 =C2=A0automatically calls `set-buffer' on the buffer shown in th= e selected
=C2=A0 =C2=A0window.

[run-at-time 0] clearly runs after that.

martin
--001a1144821ae17568053e0f8fbb--