Subject: bug#14616: 24.3.50; Excessive cursor movement on non-X Emacs

From: Eli Zaretskii <[email-masked]>
Date: Wed, 31 Jul 2013 20:34:55 +0300

> From: Lars Magne Ingebrigtsen <[email-masked]>
> Date: Wed, 31 Jul 2013 12:11:46 +0200
> 
> Here's an even more basic test case:
> 
> (dotimes (i 10)
>   (let ((process (make-network-process :name "nntp" :buffer nil
> 				       :host "news.gmane.org" :service "nntp")))
>     (delete-process process))
>   (sleep-for 5))
> 
> This redraws all the lines every five seconds for me, running
> emacs -Q -nw under an xterm.  

It doesn't actually redraw the lines, at least not on my system.  What
it does is examine each screen line in the 'desired' glyph matrix (a
structure that describes what _should_ be on the screen) with the
corresponding line in the 'current' glyph matrix (which describes what
_is_ on the screen).  Emacs compares each desired line with the
corresponding current line, sees that they are identical, and doesn't
redraw anything.

IOW, there is indeed a redisplay cycle triggered by your recipe, but
that redisplay ends up redrawing nothing, which is what I'd expect.

Do you see on your system any writes to the terminal, e.g., in strace?
If we really redraw the screen, you should see characters and escape
sequences being sent to the screen.  If there's no such traffic, then
this use case is not the bug we were looking for.

(If you wonder why each iteration through your recipe causes Emacs to
enter redisplay, then this is caused by delete-process: you will see
that it calls redisplay_preserve_echo_area, which enters redisplay.
Presumably, this is because deleting a process or a network connection
constitutes a status change, and we always call redisplay in that
case, I think for sentinels' sake.  So this is normal, or at least not
a regression.)