Subject: bug#10959: 23.3; emacs -nw doesn't always restore the terminal screen

From: Vincent Lefevre <[email-masked]>
Date: Tue, 6 Mar 2012 16:01:04 +0100

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your report will be posted to the [email-masked] mailing list
and the gnu.emacs.bug news group, and at http://debbugs.gnu.org.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

When run in a terminal (at least in xterm, aterm and gnome-terminal),
emacs doesn't always restore the terminal screen (it remains in the
alternate screen). This can be reproduced, but not always, with:

  for i in `seq 1 200`
  do
    emacs -Q -nw --eval '(save-buffers-kill-terminal)'
  done

One sees that the screen isn't restored as expected. You can increase
the number of iterations to have a better chance to reproduce the bug.

I couldn't reproduce this bug in rxvt-unicode.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/local/emacs-23.3b/share/emacs/23.3/etc/DEBUG.

In GNU Emacs 23.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.8)
 of 2011-12-15 on xvii
configured using `configure  '--prefix=/usr/local/emacs-23.3b' '--enable-asserts' '--with-crt-dir=/usr/lib/x86_64-linux-gnu''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: POSIX
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: en_DK
  value of $LANG: POSIX
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  display-time-mode: t
  show-paren-mode: t
  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
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
ESC [ > 0 ; 2 7 6 ; 0 c ESC ] 1 1 ; r g b : 0 0 0 0 
/ 0 0 0 0 / 0 0 0 0 ESC \ C-h C-p C-s a l t e r n a 
C-s C-r C-r C-s C-s C-s C-s ESC O H C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s ESC O H C-s t e 
r m i n a l C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s ESC O H C-s s s 
h C-s C-s C-s C-s C-s C-s C-s C-s ESC O B ESC [ 6 ~ 
ESC [ 6 ~ ESC [ 6 ~ ESC [ 6 ~ q ESC x r e p o TAB r 
t TAB RET

Recent messages:
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Mark saved where search started
Mark set
Mark saved where search started
Mark set
Mark saved where search started
Mark set
Mark saved where search started
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils warnings emacsbug help-mode easymenu
multi-isearch goto-addr thingatpt noutline outline easy-mmode view time
cus-start cus-load paren cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win
x-dnd font-setting tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mldrag 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 loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind system-font-setting
font-render-setting gtk x-toolkit x multi-tty emacs)