From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#24124: emacs terminal escape command error Date: Mon, 01 Aug 2016 18:18:02 +0300 Message-ID: <83d1lso6vp.fsf@gnu.org> References: <579F5E03.70201@member.fsf.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine X-Trace: blaine.gmane.org 1470067589 14779 195.159.176.226 (1 Aug 2016 16:06:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 1 Aug 2016 16:06:29 +0000 (UTC) Cc: 24124@debbugs.gnu.org To: modem Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 01 18:06:24 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUFcd-0000VB-Ks for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Aug 2016 17:59:19 +0200 Original-Received: from localhost ([::1]:50923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUEzp-0004T4-K2 for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Aug 2016 11:19:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUEzi-0004Sk-8z for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 11:19:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUEze-0005AZ-Io for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 11:19:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55783) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUEze-0005AV-Ed for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 11:19:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bUEze-0007dY-B1 for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 11:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Aug 2016 15:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24124 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24124-submit@debbugs.gnu.org id=B24124.147006470829296 (code B ref 24124); Mon, 01 Aug 2016 15:19:02 +0000 Original-Received: (at 24124) by debbugs.gnu.org; 1 Aug 2016 15:18:28 +0000 Original-Received: from localhost ([127.0.0.1]:53076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUEz6-0007cS-LJ for submit@debbugs.gnu.org; Mon, 01 Aug 2016 11:18:28 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUEz5-0007cF-Dl for 24124@debbugs.gnu.org; Mon, 01 Aug 2016 11:18:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUEyx-000532-FX for 24124@debbugs.gnu.org; Mon, 01 Aug 2016 11:18:22 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUEyx-00052t-C7; Mon, 01 Aug 2016 11:18:19 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1485 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bUEyv-0005zZ-Hc; Mon, 01 Aug 2016 11:18:17 -0400 In-reply-to: <579F5E03.70201@member.fsf.org> (message from modem on Mon, 1 Aug 2016 16:34:43 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121758 Archived-At: > From: modem > Date: Mon, 1 Aug 2016 16:34:43 +0200 > > When I put emacs in background (^z) and then in foreground again ("fg", > bash) sometime emacs will not reset properly the terminal and I won't be > able to scroll up (using PageUp/PageDown). > > After debugging the issue with a tmux developer, we tracked it down to > emacs and believe this is an emacs issue with terminal handling when > going back from background mode. > > I am attaching a snippet of the technical detail about this issue : > > > When you ^Z, tmux gets 112 bytes in all cases: > > > > input_parse: %0 ground, 40 bytes: > \n\n\033[K\033[?1l\033>\033[34h\033[?25h\033[?1049l\033[39;49m\r > > input_parse: %0 ground, 72 bytes: \r\n[1]+ Stopped > emacs large_text_file.txt\r\nroot@milu:~# > > > > \033[?1049l is rmcup which exits cursor positioning (alternate > screen) mode. > > > > Then when you type fg, it gets: > > > > input_parse: %0 ground, 694 bytes: > \033[?1049h\033[34l\033[?1h\033=\033[24;1H\033[K\033[H\033[?25l\033[3mFile > Edit Options Buffers ... > > > > \033[?1049h is smcup which turns it on again. > > > > But sometimes, it gets: > > > > input_parse: %0 ground, 674 bytes: > \033[24;1H\033[K\033[H\033[?25l\033[3mFile Edit Options Buffers ... > > > > Where emacs is not sending \033[1049h, or in fact any of the smcup, > > cvvis, smkx sequence it normally sends. Probably because Emacs tries to optimize the cursor motion commands for minimal cost. See the code of the cmgoto function (in cm.c in Emacs sources). But you didn't tell what terminfo entry is used by Emacs on your system, and didn't tell what the above terminal commands do on your terminal, so it's hard to proceed in investigating this issue. Thanks.