GNU bug report logs - #14191
24.3.50; (buffer-list) returns list with non-current buffer as its first element

Previous Next

Package: emacs;

Reported by: Joost Kremers <joostkremers <at> fastmail.fm>

Date: Fri, 12 Apr 2013 12:39:03 UTC

Severity: normal

Merged with 14415

Found in versions 24.3.50, 24.3.50.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 14191-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Joost Kremers <joostkremers <at> fastmail.fm>
Cc: 14191-done <at> debbugs.gnu.org
Subject: Re: bug#14191: 24.3.50;
	(buffer-list) returns list with non-current buffer as its first
	element
Date: Fri, 12 Apr 2013 13:32:58 -0400
> - start Emacs with `emacs -Q'
> - M-x ielm RET
> - at the prompt, type (buffer-list)
[...]
> Although the *ielm* buffer is current, the first buffer in the list is
> the *scratch* buffer.

I've installed the patch below which should restore the old behavior.
Thanks for the nice test case.


        Stefan


=== modified file 'src/window.c'
--- src/window.c	2013-04-11 16:06:47 +0000
+++ src/window.c	2013-04-12 17:30:35 +0000
@@ -489,7 +489,10 @@
   Fset_buffer (w->contents);
 
   if (EQ (window, selected_window) && !inhibit_point_swap)
-    return window;
+    /* `switch-to-buffer' uses (select-window (selected-window)) as a "clever"
+       way to call record_buffer from Elisp, so it's important that we call
+       record_buffer before returning here.  */
+    goto record_and_return;
 
   sf = SELECTED_FRAME ();
   if (XFRAME (WINDOW_FRAME (w)) != sf)
@@ -508,7 +511,10 @@
     fset_selected_window (sf, window);
 
   select_window_1 (window, inhibit_point_swap);
+  bset_last_selected_window (XBUFFER (w->contents), window);
+  windows_or_buffers_changed++;
 
+ record_and_return:
   /* record_buffer can run QUIT, so make sure it is run only after we have
      re-established the invariant between selected_window and selected_frame,
      otherwise the temporary broken invariant might "escape" (bug#14161).  */
@@ -518,8 +524,6 @@
       record_buffer (w->contents);
     }
 
-  bset_last_selected_window (XBUFFER (w->contents), window);
-  windows_or_buffers_changed++;
   return window;
 }
 





This bug report was last modified 12 years and 63 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.