GNU bug report logs - #24124
emacs terminal escape command error

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: modem <modem@HIDDEN>; dated Mon, 1 Aug 2016 15:03:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 24124 <at> debbugs.gnu.org:


Received: (at 24124) by debbugs.gnu.org; 8 Nov 2019 03:55:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 07 22:55:03 2019
Received: from localhost ([127.0.0.1]:44355 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iSvMV-0005vn-7a
	for submit <at> debbugs.gnu.org; Thu, 07 Nov 2019 22:55:03 -0500
Received: from host.gofardesign.uk ([208.79.239.190]:57221)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefan@HIDDEN>) id 1iSvMT-0005vB-Fn
 for 24124 <at> debbugs.gnu.org; Thu, 07 Nov 2019 22:55:01 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=marxist.se; 
 s=default;
 h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=8+1aaGP3gv+uJMudmsiZ7rGVFmGj8+D9RU/g4y6+E5U=; b=svNPb4DtJ9EsQx4zyD9F7pCCqN
 hTwh/UwOxfZ4wAZ5SfpeI5z8e0jOeJuGOP6Ah7iYLxc/+UxGVO+GUKky0phfE+6p9AANAOZQsD8qF
 yJqNNybriUnXFNNwM3zd8Wod80gxDwUZEdXM1GVV7YNS/YcdiPVTRnWWdjGKy/GIgNVU=;
Received: from h-70-69.a785.priv.bahnhof.se ([155.4.70.69]:50912
 helo=localhost)
 by host.gofardesign.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
 (Exim 4.92) (envelope-from <stefan@HIDDEN>)
 id 1iSvMN-00071c-4o; Thu, 07 Nov 2019 21:54:55 -0600
From: Stefan Kangas <stefan@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#24124: emacs terminal escape command error
In-Reply-To: <83k2fzmb76.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 02 Aug
 2016 18:39:57 +0300")
References: <57A06C4B.70603@HIDDEN> <83k2fzmb76.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
Date: Fri, 08 Nov 2019 04:54:53 +0100
Message-ID: <871rujvx82.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-OutGoing-Spam-Status: No, score=-1.0
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - host.gofardesign.uk
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - marxist.se
X-Get-Message-Sender-Via: host.gofardesign.uk: authenticated_id:
 stefan@HIDDEN
X-Authenticated-Sender: host.gofardesign.uk: stefan@HIDDEN
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 24124
Cc: 24124 <at> debbugs.gnu.org, modem <modem@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> [Please keep the bug address on the CC list.]
>
>> From: modem <modem@HIDDEN>
>> Date: Tue, 2 Aug 2016 11:47:55 +0200
>> 
>> Thanks you for your advises.
>> 
>> My terminfo: "echo $TERM" return "screen". Is that it ?
>
> Probably.
>
>> I recompiled emacs after commenting a few optimization in src/cm.c (cmgoto).
>> Unfortunately I can still reproduce the bug with this binary.
>> 
>> I am attaching you the patch I did.
>
> I think you disabled the wrong code.  What you need is force Emacs to
> always do this:
>
>       if (cost <= relcost)
> 	{	/* really is cheaper */
> 	  emacs_tputs (tty, p, 1, cmputc);
> 	  curY (tty) = row, curX (tty) = col;
> 	  return;
> 	}

That was 3 years ago.  Did you ever get a chance to try the suggested
fix by Eli above?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.

Message received at 24124 <at> debbugs.gnu.org:


Received: (at 24124) by debbugs.gnu.org; 4 Aug 2016 17:07:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 04 13:07:49 2016
Received: from localhost ([127.0.0.1]:55840 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bVM7Z-0006dA-Nu
	for submit <at> debbugs.gnu.org; Thu, 04 Aug 2016 13:07:49 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41708)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1bVM7X-0006cx-RN
 for 24124 <at> debbugs.gnu.org; Thu, 04 Aug 2016 13:07:48 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1bVM7P-0001VJ-57
 for 24124 <at> debbugs.gnu.org; Thu, 04 Aug 2016 13:07:42 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37698)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1bVM7P-0001V8-1q; Thu, 04 Aug 2016 13:07:39 -0400
Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4265
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1bVM7L-0004qw-M3; Thu, 04 Aug 2016 13:07:37 -0400
Date: Thu, 04 Aug 2016 20:07:16 +0300
Message-Id: <83shuklayj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: modem <modem@HIDDEN>
In-reply-to: <57A1EFD4.2060100@HIDDEN> (message from modem on Wed, 3
 Aug 2016 15:21:24 +0200)
Subject: Re: bug#24124: emacs terminal escape command error
References: <579F5E03.70201@HIDDEN> <57A1EFD4.2060100@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 24124
Cc: 24124 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.3 (------)

> From: modem <modem@HIDDEN>
> Date: Wed, 3 Aug 2016 15:21:24 +0200
> 
> > I think you disabled the wrong code.  What you need is force Emacs to
> > always do this:
> > 
> >       if (cost <= relcost)œ
> > 	{	/* really is cheaper */
> > 	  emacs_tputs (tty, p, 1, cmputc);
> > 	  curY (tty) = row, curX (tty) = col;
> > 	  return;
> > 	}
> 
> Hi Eli,
> 
> Thanks a lot. So I did another patch and another try. I can still
> reproduce the bug.
> 
> Any more advices on stuff I should try are welcomed ;-)

I'm stumped.  It could be some problem with some other piece of
software, not with Emacs.

Is there someone you could ask to produce a human-readable description
of the command Emacs sent to the terminal driver, both in the "good"
and in the "bad" cases?  I mean this citation which you brought
originally, but without any details:

> 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.

It would be nice to be able to understand what was meant by whoever
wrote this, as smcup, cvvis, etc. don't tell me much (I'm not a
terminfo expert).

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.

Message received at 24124 <at> debbugs.gnu.org:


Received: (at 24124) by debbugs.gnu.org; 3 Aug 2016 13:22:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 03 09:22:44 2016
Received: from localhost ([127.0.0.1]:54223 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bUw8B-0001SJ-Ur
	for submit <at> debbugs.gnu.org; Wed, 03 Aug 2016 09:22:44 -0400
Received: from relay4-d.mail.gandi.net ([217.70.183.196]:42164)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <modem@HIDDEN>) id 1bUw8A-0001SC-Ub
 for 24124 <at> debbugs.gnu.org; Wed, 03 Aug 2016 09:22:43 -0400
Received: from mfilter17-d.gandi.net (mfilter17-d.gandi.net [217.70.178.145])
 by relay4-d.mail.gandi.net (Postfix) with ESMTP id C46F917209A
 for <24124 <at> debbugs.gnu.org>; Wed,  3 Aug 2016 15:22:41 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter17-d.gandi.net
Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196])
 by mfilter17-d.gandi.net (mfilter17-d.gandi.net [::ffff:10.0.15.180])
 (amavisd-new, port 10024)
 with ESMTP id f-xPeUQDe6XA for <24124 <at> debbugs.gnu.org>;
 Wed,  3 Aug 2016 15:22:40 +0200 (CEST)
X-Originating-IP: 217.128.14.246
Received: from [10.0.0.225]
 (LAubervilliers-656-1-215-246.w217-128.abo.wanadoo.fr [217.128.14.246])
 (Authenticated sender: n.brito@HIDDEN)
 by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2589F172095
 for <24124 <at> debbugs.gnu.org>; Wed,  3 Aug 2016 15:22:39 +0200 (CEST)
Subject: Re: bug#24124: emacs terminal escape command error
To: 24124 <at> debbugs.gnu.org
From: modem <modem@HIDDEN>
Message-ID: <57A1EFD4.2060100@HIDDEN>
Date: Wed, 3 Aug 2016 15:21:24 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.1 Lightning/4.7.1.1
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------090709070509030101060602"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 24124
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

This is a multi-part message in MIME format.
--------------090709070509030101060602
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

> [Please keep the bug address on the CC list.]
>
>> Thanks you for your advises.
>> 
>> My terminfo: "echo $TERM" return "screen". Is that it ?
> 
> Probably.
> 
>> I recompiled emacs after commenting a few optimization in src/cm.c (cmgoto).
>> Unfortunately I can still reproduce the bug with this binary.
>> 
>> I am attaching you the patch I did.
> 
> I think you disabled the wrong code.  What you need is force Emacs to
> always do this:
> 
>       if (cost <= relcost)œ
> 	{	/* really is cheaper */
> 	  emacs_tputs (tty, p, 1, cmputc);
> 	  curY (tty) = row, curX (tty) = col;
> 	  return;
> 	}

Hi Eli,

Thanks a lot. So I did another patch and another try. I can still
reproduce the bug.

Any more advices on stuff I should try are welcomed ;-)


Here is the patch:

--- emacs24-24.4+1.orig/src/cm.c        2014-10-21 23:45:42.000000000 +0200
+++ /dev/shm/cm.c       2016-08-03 15:10:55.803193217 +0200
@@ -327,10 +327,12 @@
     char *p;
     const char *dcm;

+#if 0
   /* First the degenerate case */
     if (row == curY (tty) && col == curX (tty)) /* already there */
     return;
-
+#endif // XXX MODEM
+
     if (curY (tty) >= 0 && curX (tty) >= 0)
     {
       /* We may have quick ways to go to the upper-left, bottom-left,
@@ -375,7 +377,7 @@
    * In the following comparison, the = in <= is because when the costs
    * are the same, it looks nicer (I think) to move directly there.
    */
-  if (directcost <= relcost)
+    if (directcost <= relcost || 1) // XXX MODEM
     {
       /* compute REAL direct cost */
       cost = 0;
@@ -383,14 +385,14 @@
            ? tgoto (dcm, row, col)
            : tgoto (dcm, col, row));
       emacs_tputs (tty, p, 1, evalcost);
-      if (cost <= relcost)
+      if (cost <= relcost || 1) // XXX MODEM
        {       /* really is cheaper */
          emacs_tputs (tty, p, 1, cmputc);
          curY (tty) = row, curX (tty) = col;
          return;
        }
     }
-
+
   switch (use)
     {
     case USEHOME:

--------------090709070509030101060602
Content-Type: text/x-patch;
 name="second_try.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="second_try.patch"

--- emacs24-24.4+1.orig/src/cm.c	2014-10-21 23:45:42.000000000 +0200
+++ /dev/shm/cm.c	2016-08-03 15:10:55.803193217 +0200
@@ -327,10 +327,12 @@
     char *p;
     const char *dcm;
 
+#if 0
   /* First the degenerate case */
     if (row == curY (tty) && col == curX (tty)) /* already there */
     return;
-
+#endif // XXX MODEM
+    
     if (curY (tty) >= 0 && curX (tty) >= 0)
     {
       /* We may have quick ways to go to the upper-left, bottom-left,
@@ -375,7 +377,7 @@
    * In the following comparison, the = in <= is because when the costs
    * are the same, it looks nicer (I think) to move directly there.
    */
-  if (directcost <= relcost)
+    if (directcost <= relcost || 1) // XXX MODEM
     {
       /* compute REAL direct cost */
       cost = 0;
@@ -383,14 +385,14 @@
            ? tgoto (dcm, row, col)
            : tgoto (dcm, col, row));
       emacs_tputs (tty, p, 1, evalcost);
-      if (cost <= relcost)
+      if (cost <= relcost || 1) // XXX MODEM
 	{	/* really is cheaper */
 	  emacs_tputs (tty, p, 1, cmputc);
 	  curY (tty) = row, curX (tty) = col;
 	  return;
 	}
     }
-
+  
   switch (use)
     {
     case USEHOME:

--------------090709070509030101060602--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.

Message received at 24124 <at> debbugs.gnu.org:


Received: (at 24124) by debbugs.gnu.org; 2 Aug 2016 15:40:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 02 11:40:25 2016
Received: from localhost ([127.0.0.1]:53779 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bUbnt-0004bg-NF
	for submit <at> debbugs.gnu.org; Tue, 02 Aug 2016 11:40:25 -0400
Received: from eggs.gnu.org ([208.118.235.92]:43672)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1bUbnq-0004bR-CJ
 for 24124 <at> debbugs.gnu.org; Tue, 02 Aug 2016 11:40:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1bUbng-0002KA-4f
 for 24124 <at> debbugs.gnu.org; Tue, 02 Aug 2016 11:40:17 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33693)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1bUbng-0002Ju-1w; Tue, 02 Aug 2016 11:40:12 -0400
Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2496
 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1bUbne-0006zt-73; Tue, 02 Aug 2016 11:40:10 -0400
Date: Tue, 02 Aug 2016 18:39:57 +0300
Message-Id: <83k2fzmb76.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: modem <modem@HIDDEN>
In-reply-to: <57A06C4B.70603@HIDDEN> (message from modem on Tue, 2 Aug
 2016 11:47:55 +0200)
Subject: Re: bug#24124: emacs terminal escape command error
References: <57A06C4B.70603@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -6.2 (------)
X-Debbugs-Envelope-To: 24124
Cc: 24124 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.2 (------)

[Please keep the bug address on the CC list.]

> From: modem <modem@HIDDEN>
> Date: Tue, 2 Aug 2016 11:47:55 +0200
> 
> Thanks you for your advises.
> 
> My terminfo: "echo $TERM" return "screen". Is that it ?

Probably.

> I recompiled emacs after commenting a few optimization in src/cm.c (cmgoto).
> Unfortunately I can still reproduce the bug with this binary.
> 
> I am attaching you the patch I did.

I think you disabled the wrong code.  What you need is force Emacs to
always do this:

      if (cost <= relcost)
	{	/* really is cheaper */
	  emacs_tputs (tty, p, 1, cmputc);
	  curY (tty) = row, curX (tty) = col;
	  return;
	}




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.

Message received at 24124 <at> debbugs.gnu.org:


Received: (at 24124) by debbugs.gnu.org; 1 Aug 2016 15:18:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 01 11:18:28 2016
Received: from localhost ([127.0.0.1]:53076 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bUEz6-0007cS-LJ
	for submit <at> debbugs.gnu.org; Mon, 01 Aug 2016 11:18:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51129)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1bUEz5-0007cF-Dl
 for 24124 <at> debbugs.gnu.org; Mon, 01 Aug 2016 11:18:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1bUEyx-000532-FX
 for 24124 <at> debbugs.gnu.org; Mon, 01 Aug 2016 11:18:22 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44759)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1bUEyx-00052t-C7; Mon, 01 Aug 2016 11:18:19 -0400
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 <eliz@HIDDEN>)
 id 1bUEyv-0005zZ-Hc; Mon, 01 Aug 2016 11:18:17 -0400
Date: Mon, 01 Aug 2016 18:18:02 +0300
Message-Id: <83d1lso6vp.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: modem <modem@HIDDEN>
In-reply-to: <579F5E03.70201@HIDDEN> (message from modem on Mon, 1 Aug
 2016 16:34:43 +0200)
Subject: Re: bug#24124: emacs terminal escape command error
References: <579F5E03.70201@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -6.2 (------)
X-Debbugs-Envelope-To: 24124
Cc: 24124 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.2 (------)

> From: modem <modem@HIDDEN>
> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Aug 2016 15:02:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 01 11:02:16 2016
Received: from localhost ([127.0.0.1]:53070 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1bUEjL-0007FZ-1v
	for submit <at> debbugs.gnu.org; Mon, 01 Aug 2016 11:02:16 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41108)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <modem@HIDDEN>) id 1bUEKG-0006fv-BL
 for submit <at> debbugs.gnu.org; Mon, 01 Aug 2016 10:36:16 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <modem@HIDDEN>) id 1bUEKA-0006PH-2v
 for submit <at> debbugs.gnu.org; Mon, 01 Aug 2016 10:36:11 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:49265)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <modem@HIDDEN>) id 1bUEKA-0006PC-0Q
 for submit <at> debbugs.gnu.org; Mon, 01 Aug 2016 10:36:10 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60282)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <modem@HIDDEN>) id 1bUEK5-0003DM-Ki
 for bug-gnu-emacs@HIDDEN; Mon, 01 Aug 2016 10:36:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <modem@HIDDEN>) id 1bUEK0-0006Mo-Hc
 for bug-gnu-emacs@HIDDEN; Mon, 01 Aug 2016 10:36:05 -0400
Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35534)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <modem@HIDDEN>) id 1bUEK0-0006Mf-AS
 for bug-gnu-emacs@HIDDEN; Mon, 01 Aug 2016 10:36:00 -0400
Received: from mfilter46-d.gandi.net (mfilter46-d.gandi.net [217.70.178.177])
 by relay3-d.mail.gandi.net (Postfix) with ESMTP id 1B13DA80CE
 for <bug-gnu-emacs@HIDDEN>; Mon,  1 Aug 2016 16:35:59 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at mfilter46-d.gandi.net
Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195])
 by mfilter46-d.gandi.net (mfilter46-d.gandi.net [::ffff:10.0.15.180])
 (amavisd-new, port 10024)
 with ESMTP id hYePeBOYUp-1 for <bug-gnu-emacs@HIDDEN>;
 Mon,  1 Aug 2016 16:35:56 +0200 (CEST)
X-Originating-IP: 217.128.14.246
Received: from [10.0.0.225]
 (LAubervilliers-656-1-215-246.w217-128.abo.wanadoo.fr [217.128.14.246])
 (Authenticated sender: n.brito@HIDDEN)
 by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 9F4AFA80ED
 for <bug-gnu-emacs@HIDDEN>; Mon,  1 Aug 2016 16:35:55 +0200 (CEST)
To: bug-gnu-emacs@HIDDEN
From: modem <modem@HIDDEN>
Subject: emacs terminal escape command error
Message-ID: <579F5E03.70201@HIDDEN>
Date: Mon, 1 Aug 2016 16:34:43 +0200
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.1 Lightning/4.7.1.1
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Mon, 01 Aug 2016 11:02:09 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Hi,


I am facing a problem with emacs inside tmux.
The problem can be reproduced easily.

Emacs seems to have an terminal issue when being back from background
mode on shell.

Let me explain:
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.

This can be reproduced by hitting ^z and then "fg" in a loop for a
couples of minutes. If you run tmux with "tmux -vvvv" you will be able
to obtain the logs mentionned above. To observe the problem you can just
press PageUp each time you are back in emacs, when the bug will
reproduce you won't pageUp inside emacs but enter the tmux's copy-mode.
My ~/.tmux.conf only has 1 line:
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage"
"copy-mode -e -u"


If you need me to apply some patch and/or reproduce just let me know I
will happily helps.

Thanks a lot,


-- modem




Acknowledgement sent to modem <modem@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#24124; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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