* bug#36497: pop-to-buffer + quit-window negates with-current-buffer
@ 2019-07-04 12:22 Stefan Kangas
2019-07-04 12:50 ` martin rudalics
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2019-07-04 12:22 UTC (permalink / raw)
To: 36497
[-- Attachment #1: Type: text/plain, Size: 665 bytes --]
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
[-- Attachment #2: with-current-buffer-test.diff --]
[-- Type: application/octet-stream, Size: 585 bytes --]
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 06db8f5c90..aa04d84dc3 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -400,5 +400,12 @@ subr-tests-add-hook-depth
(should (equal subr-tests--hook '(f5 f10 f9 f6 f2 f1 f4 f3 f7 f8)))
)
+(ert-deftest ert-tests-with-current-buffer/bug-XXXXX ()
+ (let ((buf (get-buffer-create "foo")))
+ (with-current-buffer buf
+ (pop-to-buffer (get-buffer-create "bar"))
+ (quit-window)
+ (should (equal (current-buffer) buf)))))
+
(provide 'subr-tests)
;;; subr-tests.el ends here
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#36497: pop-to-buffer + quit-window negates with-current-buffer
2019-07-04 12:22 bug#36497: pop-to-buffer + quit-window negates with-current-buffer Stefan Kangas
@ 2019-07-04 12:50 ` martin rudalics
2019-07-04 19:33 ` Stefan Kangas
0 siblings, 1 reply; 3+ messages in thread
From: martin rudalics @ 2019-07-04 12:50 UTC (permalink / raw)
To: Stefan Kangas, 36497
> 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>
Both 'pop-to-buffer' and 'quit-window' may call 'select-window' which
implicitly makes that window's buffer current. In the case at hand,
'quit-window' deletes the window of *bar* since it didn't exist
before, selects the window selected before 'pop-to-buffer' was called
and makes that window's buffer current. So the current behavior is
the expected one.
martin
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#36497: pop-to-buffer + quit-window negates with-current-buffer
2019-07-04 12:50 ` martin rudalics
@ 2019-07-04 19:33 ` Stefan Kangas
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2019-07-04 19:33 UTC (permalink / raw)
To: martin rudalics; +Cc: 36497-done
martin rudalics <rudalics@gmx.at> writes:
> Both 'pop-to-buffer' and 'quit-window' may call 'select-window' which
> implicitly makes that window's buffer current. In the case at hand,
> 'quit-window' deletes the window of *bar* since it didn't exist
> before, selects the window selected before 'pop-to-buffer' was called
> and makes that window's buffer current. So the current behavior is
> the expected one.
Thanks for the detailed explanation -- that makes sense.
I'm closing the bug report. Sorry about the noise.
Thanks,
Stefan Kangas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-04 19:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-04 12:22 bug#36497: pop-to-buffer + quit-window negates with-current-buffer Stefan Kangas
2019-07-04 12:50 ` martin rudalics
2019-07-04 19:33 ` Stefan Kangas
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.