From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: display-buffer vs. current-buffer vs. post-command-hook Date: Tue, 04 Oct 2016 16:52:02 +0200 Message-ID: <57F3C212.3020401@gmx.at> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1475593275 591 195.159.176.226 (4 Oct 2016 15:01:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Oct 2016 15:01:15 +0000 (UTC) To: Ami Fischman , "emacs-devel@gnu.org" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 04 17:01:12 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 1brRD6-00051c-Bx for ged-emacs-devel@m.gmane.org; Tue, 04 Oct 2016 17:00:48 +0200 Original-Received: from localhost ([::1]:43289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brRD5-0006Py-1R for ged-emacs-devel@m.gmane.org; Tue, 04 Oct 2016 11:00:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brR4t-00012D-68 for emacs-devel@gnu.org; Tue, 04 Oct 2016 10:52:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brR4o-0003oD-4M for emacs-devel@gnu.org; Tue, 04 Oct 2016 10:52:18 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:59607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brR4n-0003nZ-Py for emacs-devel@gnu.org; Tue, 04 Oct 2016 10:52:14 -0400 Original-Received: from [192.168.1.100] ([212.95.7.62]) by mail.gmx.com (mrgmx003) with ESMTPSA (Nemesis) id 0MYg42-1bM4K13Sfi-00VNZA; Tue, 04 Oct 2016 16:52:11 +0200 In-Reply-To: X-Provags-ID: V03:K0:met3TVxfgu5SnB/KVh7sd+wK/IKoN0XY1C+XKflHyGpt+CiVk+W WzIMqNrf7Y+8IhQshXZTlBoLSHGDDYwbRmPIOWxA0EE3ShtKi1cWSZtvtgutmwECPtSMA6Q gI8vnhldwNuVqXG0SKVTuTANMusEVMCtg4Ww0B2I9TcYZjjZGit2DmajeIzsE04rAhr1w01 HlKZSxUfBrA1isgLRPy/w== X-UI-Out-Filterresults: notjunk:1;V01:K0:Qjl+rQVg7mQ=:V79F7zFwMBMFWJxJCcLJOF E4N7O+HBmZxDJyP9x9F/DPblPoFj26+XbDBQfhhjYiL83oXjcavVYS5WHQjsybow+I+ifUsn5 cKI1G319X6p5+564pf3teowEx3zJ4gNUbtT4lhEjMXfSVeFE2TJ6uRHNJw6ONj4jX5MV5pjLP xX7h/naJEGSpZvMBANwn/5k5nfRiXE/CV5q987Kw6ry32Gw00choOVEIgwjDZMAY1MXwBFgVF M/nbDOOuT+SiJVwy7Uq9C+kJoDk+3KGoDU0walWYZjS55dUo3vRy7zJ0Bp2SoP4lSguAsNNM6 NvCVZYegAdG9pHQ2N+Yw6oAsIzb9ijn+zpvoCbUSyyV1mOQbMpR/HRnIH2LOfkQdlsNSAqPKO vZp1rbH6AGKN0LbQAMM6f5cXAjxEcoxN8T5cmaWo3Q5my7XxgNKzfuaHITPiw+bZycOWW9lzg rhfcAkszWShhtQf/8+GXGsLWSlpjlEHNb2Xg/bsF9xDxms/2MDC1t3uA/H+Ux7/xyquSNeVb7 sJPXSlIHQar1ThT9LuVynwTqxGyWI8oSBvIjNumo3ep9Rwk2oOdt9kr3Kp0CLvO4kvByATYxC mK0v+OvBhv+tTKfTOdFaZRS4oaRH1R5u+8Hvijp5/avbPxe+0o85tkCQWMlCQwYFVYvfdwT1v ni9G2X2ARrlvCWekM/dyeToP4cp64zfbECqjNIR632tNKd8qPA5YI3UoWVUz09DzHiX+ZYl9u lekHTepbP7jea7Znw76C7d2jyS7/HTDg0eZI3wxJ5b8+EVtLATYIAHScUVwmcLsEzwM7pFCU X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.18 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:207979 Archived-At: > The following snippet (saved in x.el), when loaded in 25.1.1 using > [google-emacs -Q -l x.el], generates the message: > *scratch* *scratch* *Help* > demonstrating that (current-buffer) has a stale value after describe-k= ey > returns (I expect post to match the [run-at-time 0] value, not the pre= > value). > > (progn > (setq display-buffer-alist '(("." (lambda (buffer alist) > (switch-to-buffer buffer))))) The preferred way to use the selected window for displaying a buffer is the action function =E2=80=98display-buffer-same-window=E2=80=99. > (setq pre (current-buffer)) > (describe-key (kbd "SPC")) > (setq post (current-buffer)) > (run-at-time 0 nil (lambda () (message "%s %s %s" pre post > (current-buffer))))) =E2=80=98describe-key=E2=80=99 is based on =E2=80=98with-temp-buffer-wind= ow=E2=80=99 which tries very hard to restore the current buffer after doing its work. So what you see here is not a stale value but one that has been correctly preserved. Please tell us what you want to accomplish. Then we might be able to tell you how to do that. martin