Subject: bug#24124: emacs terminal escape command error

From: modem <[email-masked]>
Date: Wed, 3 Aug 2016 15:21:24 +0200

> [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:
--- 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: