Subject: Re: bug#17724: 24.4.50; regression: error "`recenter'ing a window that does not display current-buffer." when opening org-mode file

From: Eli Zaretskii <[email-masked]>
Date: Sat, 07 Jun 2014 19:26:35 +0300

> From: Gregor Zattler <[email-masked]>
> Date: Sat, 07 Jun 2014 17:57:17 +0200
> 
> since
> 
> GNU Emacs 24.4.50.1 (i686-pc-linux-gnu, GTK+ Version 3.12.2) of 2014-06-06 on boo
> 
> emacs-snapshot -Q file.org
> 
> gives:
> 
> File mode specification error: (error "`recenter'ing a window that does not display current-buffer.")
> 
> Note that this error occurs even if file.org is empty or does not exist.
> 
> The same error message prevents computation of the org-agenda with my usual setup which why I found this error and report it.
> 
> 
> I assume that this error is related to this commit:
> commit 0ce71d38bf295205067fd334e1993906f7fb0ba7
> Author:     Stefan Monnier <[email-masked]>
> AuthorDate: Fri Jun 6 10:37:05 2014 -0400
> Commit:     Stefan Monnier <[email-masked]>
> CommitDate: Fri Jun 6 10:37:05 2014 -0400
> 
> * src/window.c (Frecenter): Signal an error if window-buffer is not
>   current-buffer.

It's a bug in Org, IMO: it recenters the window without making sure
the current buffer's window is selected.  The backtrace below suggests
that org-mode is turned on inside a call to find-file-noselect, which
doesn't select the window of the current buffer.  So this call to
recenter actually recenters the wrong window, the one that displays
*scratch*.

Bastien, could you please look into this?

Breakpoint 3, Frecenter (arg=83507246) at window.c:5644
5644      struct window *w = XWINDOW (selected_window);
(gdb) n
5645      struct buffer *buf = XBUFFER (w->contents);
(gdb)
5646      bool center_p = 0;
(gdb) p buf->name_
$1 = 22325705
(gdb) xtype
Lisp_String
(gdb) xstring
$2 = (struct Lisp_String *) 0x154a9c8 <dumped_data+36648>
"*scratch*"
(gdb) p current_buffer->name_
$3 = 16540225
(gdb) xstring
$4 = (struct Lisp_String *) 0xfc6240
"file.org"
(gdb) bt
#0  Frecenter (arg=83507246) at window.c:5646
#1  0x0118b071 in Ffuncall (nargs=2, args=0x82dd74) at eval.c:2815
#2  0x011cf2cd in exec_byte_code (bytestr=83861729, vector=83857157,
    maxdepth=20, args_template=22298242, nargs=0, args=0x0) at bytecode.c:918
#3  0x0118bbef in funcall_lambda (fun=83857213, nargs=0, arg_vector=0x82df58)
    at eval.c:3049
#4  0x0118b2af in Ffuncall (nargs=1, args=0x82df54) at eval.c:2864
#5  0x011cf2cd in exec_byte_code (bytestr=83856689, vector=83856925,
    maxdepth=8, args_template=22298242, nargs=0, args=0x0) at bytecode.c:918
#6  0x0118bbef in funcall_lambda (fun=83856997, nargs=0, arg_vector=0x82e128)
    at eval.c:3049
#7  0x0118b2af in Ffuncall (nargs=1, args=0x82e124) at eval.c:2864
#8  0x011cf2cd in exec_byte_code (bytestr=83765417, vector=83766885,
    maxdepth=32, args_template=22298242, nargs=0, args=0x0) at bytecode.c:918
#9  0x0118bbef in funcall_lambda (fun=83767565, nargs=0, arg_vector=0x82e320)
    at eval.c:3049
#10 0x0118b2af in Ffuncall (nargs=1, args=0x82e31c) at eval.c:2864
#11 0x011cf2cd in exec_byte_code (bytestr=19649353, vector=19649373,
    maxdepth=20, args_template=2052, nargs=2, args=0x82e520) at bytecode.c:918
#12 0x0118b844 in funcall_lambda (fun=19649333, nargs=2, arg_vector=0x82e518)
    at eval.c:2983
#13 0x0118b2af in Ffuncall (nargs=3, args=0x82e514) at eval.c:2864
#14 0x011cf2cd in exec_byte_code (bytestr=19648737, vector=19648757,
    maxdepth=64, args_template=1024, nargs=0, args=0x82e708) at bytecode.c:918
#15 0x0118b844 in funcall_lambda (fun=19648717, nargs=0, arg_vector=0x82e708)
    at eval.c:2983
#16 0x0118b2af in Ffuncall (nargs=1, args=0x82e704) at eval.c:2864
#17 0x011cf2cd in exec_byte_code (bytestr=19498393, vector=19643621,
    maxdepth=4, args_template=0, nargs=0, args=0x82e8e4) at bytecode.c:918
#18 0x0118b844 in funcall_lambda (fun=19643597, nargs=0, arg_vector=0x82e8e4)
    at eval.c:2983
#19 0x0118b2af in Ffuncall (nargs=1, args=0x82e8e0) at eval.c:2864
#20 0x01189bba in eval_sub (form=26867454) at eval.c:2157
#21 0x01187dd3 in internal_lisp_condition_case (var=23885034,
    bodyform=26867454, handlers=26867246) at eval.c:1323
#22 0x011cff2b in exec_byte_code (bytestr=19643497, vector=19643517,
    maxdepth=28, args_template=1024, nargs=1, args=0x82ec60)
    at bytecode.c:1164
#23 0x0118b844 in funcall_lambda (fun=19643469, nargs=1, arg_vector=0x82ec5c)
    at eval.c:2983
#24 0x0118b2af in Ffuncall (nargs=2, args=0x82ec58) at eval.c:2864
#25 0x011cf2cd in exec_byte_code (bytestr=19642817, vector=19642837,
    maxdepth=44, args_template=5120, nargs=2, args=0x82ee5c) at bytecode.c:918
#26 0x0118b844 in funcall_lambda (fun=19642797, nargs=2, arg_vector=0x82ee54)
    at eval.c:2983
#27 0x0118b2af in Ffuncall (nargs=3, args=0x82ee50) at eval.c:2864
#28 0x011cf2cd in exec_byte_code (bytestr=19641705, vector=19641725,
    maxdepth=76, args_template=6168, nargs=6, args=0x82f088) at bytecode.c:918
#29 0x0118b844 in funcall_lambda (fun=19641685, nargs=6, arg_vector=0x82f070)
    at eval.c:2983
#30 0x0118b2af in Ffuncall (nargs=7, args=0x82f06c) at eval.c:2864
#31 0x011cf2cd in exec_byte_code (bytestr=19640897, vector=19640917,
    maxdepth=72, args_template=4100, nargs=4, args=0x82f270) at bytecode.c:918
#32 0x0118b844 in funcall_lambda (fun=19640877, nargs=4, arg_vector=0x82f260)
    at eval.c:2983
#33 0x0118b2af in Ffuncall (nargs=5, args=0x82f25c) at eval.c:2864
#34 0x011cf2cd in exec_byte_code (bytestr=19637793, vector=19637813,
    maxdepth=28, args_template=2052, nargs=2, args=0x82f4b0) at bytecode.c:918
#35 0x0118b844 in funcall_lambda (fun=19637765, nargs=2, arg_vector=0x82f4a8)
    at eval.c:2983
#36 0x0118b2af in Ffuncall (nargs=3, args=0x82f4a4) at eval.c:2864
#37 0x01182a9c in Ffuncall_interactively (nargs=3, args=0x82f4a4)
    at callint.c:250
#38 0x0118af56 in Ffuncall (nargs=4, args=0x82f4a0) at eval.c:2796
#39 0x0118a5b4 in Fapply (nargs=3, args=0x82f590) at eval.c:2354
#40 0x01182f05 in Fcall_interactively (function=23468594,
    record_flag=22298242, keys=22323917) at callint.c:399
#41 0x0118b0d3 in Ffuncall (nargs=4, args=0x82f6fc) at eval.c:2822
#42 0x011cf2cd in exec_byte_code (bytestr=19899513, vector=19899533,
    maxdepth=52, args_template=4100, nargs=1, args=0x82f8f0) at bytecode.c:918
#43 0x0118b844 in funcall_lambda (fun=19899493, nargs=1, arg_vector=0x82f8ec)
    at eval.c:2983
#44 0x0118b2af in Ffuncall (nargs=2, args=0x82f8e8) at eval.c:2864
#45 0x0118ab65 in call1 (fn=22344058, arg1=23468594) at eval.c:2614
#46 0x010f9c81 in command_loop_1 () at keyboard.c:1553
#47 0x01187ee1 in internal_condition_case (bfun=0x10f9621 <command_loop_1>,
    handlers=22351570, hfun=0x10f8e92 <cmd_error>) at eval.c:1354
#48 0x010f92f7 in command_loop_2 (ignore=22298242) at keyboard.c:1171
#49 0x011874cc in internal_catch (tag=22344730,
    func=0x10f92d4 <command_loop_2>, arg=22298242) at eval.c:1118
#50 0x010f92af in command_loop () at keyboard.c:1150
#51 0x010f8a4c in recursive_edit_1 () at keyboard.c:771
#52 0x010f8bfc in Frecursive_edit () at keyboard.c:842
#53 0x010f6caf in main (argc=2, argv=0xa427c0) at emacs.c:1656

Lisp Backtrace:
"recenter" (0x82dd78)
"org-overview" (0x82df58)
"org-set-startup-visibility" (0x82e128)
"org-mode" (0x82e320)
"set-auto-mode-0" (0x82e518)
"set-auto-mode" (0x82e708)
0x12bbcc8 PVEC_COMPILED
"funcall" (0x82e8e0)
"normal-mode" (0x82ec5c)
"after-find-file" (0x82ee54)
"find-file-noselect-1" (0x82f070)
"find-file-noselect" (0x82f260)
"find-file" (0x82f4a8)
"funcall-interactively" (0x82f4a4)
"call-interactively" (0x82f700)
"command-execute" (0x82f8ec)