GNU bug report logs -
#14191
24.3.50; (buffer-list) returns list with non-current buffer as its first element
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14191 in the body.
You can then email your comments to 14191 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Fri, 12 Apr 2013 12:39:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Joost Kremers <joostkremers <at> fastmail.fm>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 12 Apr 2013 12:39:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(buffer-list) returns a list of buffers, but the first buffer in the
list is not the current buffer.
Recipe to reproduce:
- start Emacs with `emacs -Q'
- M-x ielm RET
- at the prompt, type (buffer-list)
Output (list of buffers wrapped for better readability):
,----
| *** Welcome to IELM *** Type (describe-mode) for help.
| ELISP> (buffer-list)
| (#<buffer *scratch*> #<buffer *Minibuf-1*> #<buffer *Minibuf-0*>
| #<buffer *Messages*> #<buffer *code-conversion-work*>
| #<buffer *Echo Area 0*> #<buffer *Echo Area 1*> #<buffer *ielm*>)
`----
Although the *ielm* buffer is current, the first buffer in the list is
the *scratch* buffer.
Doing the same thing in an Emacs Debian (Ubuntu) snapshot from a few
weeks ago:
,----
| *** Welcome to IELM *** Type (describe-mode) for help.
| ELISP> (buffer-list)
| (#<buffer *ielm*> #<buffer *scratch*> #<buffer *Minibuf-1*>
| #<buffer *Minibuf-0*> #<buffer *Messages*>
| #<buffer *code-conversion-work*> #<buffer *Echo Area 0*>
| #<buffer *Echo Area 1*>)
|
| ELISP> (emacs-version)
| "GNU Emacs 24.3.50.1 (i686-pc-linux-gnu)\n of 2013-03-19 on gold, modified by Debian"
`----
Here, the output of buffer-list has the *ielm* buffer as its first
element. (Note, I've included the output of (emacs-version) here: this
is obviously *not* the version in which the bug occurs. That version is
given below.)
Note that I'm just using the *ielm* buffer to show the output of
(buffer-list). It has nothing to do with the bug itself. Using `M-x eval
RET (buffer-list) RET' gives the same result, as does using
(buffer-list) in Elisp. (Which is how I ran into the bug: swbuff.el from
http://emhacks.sourceforge.net/ stopped working properly. I traced the
problem to this changed behaviour of buffer-list.)
HTH
Joost Kremers
In GNU Emacs 24.3.50.1 (i686-pc-linux-gnu, GTK+ Version 3.6.0)
of 2013-04-11 on fermium, modified by Debian
(emacs-snapshot package, version 2:20130410-1~ppa1~quantal1)
Windowing system distributor `The X.Org Foundation', version 11.0.11300000
System Description: Ubuntu 12.10
Configured using:
`configure --build i686-linux-gnu --host i686-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var
--infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.3.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3.50/site-lisp:/usr/share/emacs/site-lisp
--without-compress-info --with-crt-dir=/usr/lib/i386-linux-gnu/
--with-x=yes --with-x-toolkit=gtk3 --with-imagemagick=yes
CFLAGS='-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2'
CPPFLAGS='-D_FORTIFY_SOURCE=2' LDFLAGS='-g -Wl,--as-needed
-znocombreloc''
Important settings:
value of $LC_MONETARY: en_US.UTF-8
value of $LC_NUMERIC: en_US.UTF-8
value of $LC_TIME: en_US.UTF-8
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: IELM
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
M-x i e l m <return> ( b u f f e r - l i s t ) <return>
<help-echo> <help-echo> <help-echo> <up> <up> <up>
<up> C-a a <backspace> <up> <left> <left> <left> <left>
<left> <left> <left> C-SPC <down> <down> <down> <down>
<down> <down> M-w ( e m a c s - v e r s i o n ) <return>
<help-echo> <help-echo> <up> <up> <up> <right> C-SPC
<down> <down> M-w C-x C-g M-x e m a c <tab> b u <tab>
<M-backspace> <M-backspace> r e p <tab> o r <tab>
<return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
End of buffer
Mark set
Making completion list...
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-mode easymenu ielm pp comint ansi-color ring
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face macroexp files text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind inotify
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)
--
Joost Kremers
Life has its moments
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Fri, 12 Apr 2013 17:37:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Joost Kremers <joostkremers <at> fastmail.fm>
:
bug acknowledged by developer.
(Fri, 12 Apr 2013 17:37:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 14191-done <at> debbugs.gnu.org (full text, mbox):
> - 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;
}
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Fri, 12 Apr 2013 17:56:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 14191-done <at> debbugs.gnu.org (full text, mbox):
> + /* `switch-to-buffer' uses (select-window
> + (selected-window)) as a "clever"
> + way to call record_buffer from Elisp
As your quote-marks are no doubt meant to suggest here, there's really nothing
clever about code that relies on behavior that is somewhat obscure.
Why not take away some of the mystery and make the behavior here more
transparent by creating a function whose name suggests it?
(defun record-selected-window-buffer () ; Or `defsubst', if you prefer.
"Move the buffer of the selected window to the front of `buffer-list'."
(select-window (selected-window)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Fri, 12 Apr 2013 19:04:05 GMT)
Full text and
rfc822 format available.
Message #16 received at 14191 <at> debbugs.gnu.org (full text, mbox):
Joost Kremers <joostkremers <at> fastmail.fm> writes:
> (buffer-list) returns a list of buffers, but the first buffer in the
> list is not the current buffer.
Nor is it documented to do so.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Sat, 13 Apr 2013 08:07:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 14191-done <at> debbugs.gnu.org (full text, mbox):
> Why not take away some of the mystery and make the behavior here more
> transparent by creating a function whose name suggests it?
`record-window-buffer' ?
martin
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Sat, 13 Apr 2013 15:13:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 14191-done <at> debbugs.gnu.org (full text, mbox):
> > Why not take away some of the mystery and make the behavior
> > here more transparent by creating a function whose name
> > suggests it?
>
> `record-window-buffer' ?
;-)
I wasn't aware of it. I was just basing my off-the-cuff suggestion on what the
code was apparently trying to do here.
But `record-window-buffer' is apparently quite a bit more than just
(select-window (selected-window)).
Should `record-window-buffer' be used in its place at this occurrence? If not,
should another function be defined to do only (select-window (selected-window))
- essentially an alias to better communicate the intention?
You're the expert here, not I. My feeling is just that using (select-window
(selected-window)) to take advantage of a less-than-obvious side effect is
obfuscating, not clever or wise.
Without an informative alias for this action, the code really needs to be
commented to indicate the unobvious intention/effect, at the least. But is
probably better to have a function name & doc string communicate this than code
comments and bug reports.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Sun, 14 Apr 2013 12:52:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 14191 <at> debbugs.gnu.org (full text, mbox):
On Fri, Apr 12 2013, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> Joost Kremers <joostkremers <at> fastmail.fm> writes:
>
>> (buffer-list) returns a list of buffers, but the first buffer in the
>> list is not the current buffer.
>
> Nor is it documented to do so.
True, of course. But it seems it has always been the case, so perhaps it
should be documented?
--
Joost Kremers
Life has its moments
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#14191
; Package
emacs
.
(Mon, 15 Apr 2013 07:16:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 14191-done <at> debbugs.gnu.org (full text, mbox):
> But `record-window-buffer' is apparently quite a bit more than just
> (select-window (selected-window)).
More and less, I think.
> Should `record-window-buffer' be used in its place at this occurrence? If not,
> should another function be defined to do only (select-window (selected-window))
> - essentially an alias to better communicate the intention?
>
> You're the expert here, not I. My feeling is just that using (select-window
> (selected-window)) to take advantage of a less-than-obvious side effect is
> obfuscating, not clever or wise.
>
> Without an informative alias for this action, the code really needs to be
> commented to indicate the unobvious intention/effect, at the least. But is
> probably better to have a function name & doc string communicate this than code
> comments and bug reports.
As Andreas already remarked, the behavior of Emacs in this regard was
never clearly documented. Unfortunately, I don't know more about its
"unobvious intention/effect" than you.
martin
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 13 May 2013 11:24:04 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 17 May 2013 15:50:02 GMT)
Full text and
rfc822 format available.
Forcibly Merged 14191 14415.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 17 May 2013 15:50:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 15 Jun 2013 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 59 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.