Subject: pop-to-buffer + quit-window negates with-current-buffer
From: Stefan Kangas <[email-masked]>
To: [email-masked]
Date: Thu, 4 Jul 2019 14:22:28 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Steps to reproduce:

0. Run emacs -Q
1. Evaluate the following in *scratch* buffer:

(with-current-buffer (get-buffer-create "foo")
  (pop-to-buffer (get-buffer-create "bar"))
  (quit-window)
  (current-buffer))

Result:
#<buffer *scratch*>

Expected result:
#<buffer foo>

Please find attached also a suggested test case for this bug.

In GNU Emacs 27.0.50 (build 3, x86_64-apple-darwin15.6.0, NS
appkit-1404.47 Version 10.11.6 (Build 15G22010))
 of 2019-07-04 built on Stefans-MBP
Repository revision: 5b48dab412c61980bca63a67a5d548d07e56b404
Repository branch: master
Windowing system distributor 'Apple', version 10.3.1404
System Description:  Mac OS X 10.11.6