unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* comint-preoutput-filter-functions and flickering redisplay in TTY
@ 2014-06-03 11:59 Mario Lang
  2014-06-03 12:27 ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Lang @ 2014-06-03 11:59 UTC (permalink / raw
  To: emacs-devel

Hi.

chess.el can talk to internet chess servers.  This is based on comint.
ICS periodically announces "seeking game" messages which we collect
into a separate buffer, as there are potentially many of them, which
would totally clutter your comint output.  For this, we use
comint-preoutput-filter-functions to catch the output before it goes to
the buffer.  If the string arriving in comint matches, we insert it
somewhere else, and return "".  Now, I am noticing strange redisplay
behaviour if "seeking game" messages are on in Emacs -nw.
There is noticeable flickering of the whole screen.
As if the screen was cleared completely, and redrawn again from scratch.
But there are no big visual changes going on actually, the screen
content stays largely the same.

I am out of ideas on this one.  Does anyone have ideas why this might be
happening, and if there is some sort of work-around I could use from
Lisp-world to avoid it?

To reproduce: Install chess.el, call M-x chess-ics RET, login to
freechess.org (as guest is OK), and wait a bit.  Your screen (at least in -nw mode)
should start to flicker noticeably every once in a while.

Any ideas why?

-- 
Thanks,
  ⡍⠁⠗⠊⠕



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: comint-preoutput-filter-functions and flickering redisplay in TTY
  2014-06-03 11:59 comint-preoutput-filter-functions and flickering redisplay in TTY Mario Lang
@ 2014-06-03 12:27 ` Nicolas Richard
  2014-06-03 13:12   ` Mario Lang
  2014-06-04 12:30   ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Richard @ 2014-06-03 12:27 UTC (permalink / raw
  To: Mario Lang; +Cc: emacs-devel

Mario Lang <mlang@delysid.org> writes:
> To reproduce: Install chess.el, call M-x chess-ics RET, login to
> freechess.org (as guest is OK), and wait a bit.  Your screen (at least in -nw mode)
> should start to flicker noticeably every once in a while.
>
> Any ideas why?

I tried it in my GUI emacs (just to try chess.el, in fact) and noticed
very frequent recentering of my window, even when not in the *chess-ics*
buffer.

By tracing "recenter" I found that tabulated-list-print calls (recenter)
without checking what the selected window is. 

here's the patch I applied, perhaps you can try it out and see if it
fixes the problem for you.

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index d0d71dd..dd1166f 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -323,7 +323,9 @@ to the entry with the same ID element as the current line."
     (if saved-pt
 	(progn (goto-char saved-pt)
 	       (move-to-column saved-col)
-	       (recenter))
+	       (when (eq (window-buffer (selected-window))
+                         (current-buffer))
+                 (recenter)))
       (goto-char (point-min)))))
 
 (defun tabulated-list-print-entry (id cols)

-- 
Nico.



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: comint-preoutput-filter-functions and flickering redisplay in TTY
  2014-06-03 12:27 ` Nicolas Richard
@ 2014-06-03 13:12   ` Mario Lang
  2014-06-04 10:36     ` Nicolas Richard
  2014-06-04 12:30   ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Mario Lang @ 2014-06-03 13:12 UTC (permalink / raw
  To: emacs-devel

Nicolas Richard <theonewiththeevillook@yahoo.fr> writes:

> Mario Lang <mlang@delysid.org> writes:
>> To reproduce: Install chess.el, call M-x chess-ics RET, login to
>> freechess.org (as guest is OK), and wait a bit.  Your screen (at least in -nw mode)
>> should start to flicker noticeably every once in a while.
>>
>> Any ideas why?
>
> I tried it in my GUI emacs (just to try chess.el, in fact) and noticed
> very frequent recentering of my window, even when not in the *chess-ics*
> buffer.
>
> By tracing "recenter" I found that tabulated-list-print calls (recenter)
> without checking what the selected window is. 
>
> here's the patch I applied, perhaps you can try it out and see if it
> fixes the problem for you.

Very good catch!  Most of the flickering is now gone.
I think this should be committed, if others are fine with it as well.

> diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
> index d0d71dd..dd1166f 100644
> --- a/lisp/emacs-lisp/tabulated-list.el
> +++ b/lisp/emacs-lisp/tabulated-list.el
> @@ -323,7 +323,9 @@ to the entry with the same ID element as the current line."
>      (if saved-pt
>  	(progn (goto-char saved-pt)
>  	       (move-to-column saved-col)
> -	       (recenter))
> +	       (when (eq (window-buffer (selected-window))
> +                         (current-buffer))
> +                 (recenter)))
>        (goto-char (point-min)))))
>
>  (defun tabulated-list-print-entry (id cols)

-- 
CYa,
  ⡍⠁⠗⠊⠕



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: comint-preoutput-filter-functions and flickering redisplay in TTY
  2014-06-03 13:12   ` Mario Lang
@ 2014-06-04 10:36     ` Nicolas Richard
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Richard @ 2014-06-04 10:36 UTC (permalink / raw
  To: Mario Lang; +Cc: emacs-devel

Mario Lang <mlang@delysid.org> writes:
>>> To reproduce: Install chess.el, call M-x chess-ics RET, login to
>>> freechess.org (as guest is OK), and wait a bit.  Your screen (at least in -nw mode)
>>> should start to flicker noticeably every once in a while.

Perhaps you should file a bug report so as to ensure this does not get
forgotten. FWIW, I would even completely remove the call to (recenter)
in tabulated-list-print because I don't know what purpose it serves.

-- 
Nico.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: comint-preoutput-filter-functions and flickering redisplay in TTY
  2014-06-03 12:27 ` Nicolas Richard
  2014-06-03 13:12   ` Mario Lang
@ 2014-06-04 12:30   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2014-06-04 12:30 UTC (permalink / raw
  To: Nicolas Richard; +Cc: Mario Lang, emacs-devel

> -	       (recenter))
> +	       (when (eq (window-buffer (selected-window))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aka                               (window-buffer)

> +                         (current-buffer))
> +                 (recenter)))

Looks like you found a bug here indeed.  FWIW, we fixed a similar bug
a while ago elsewhere.  I think maybe `recenter' should signal an error
if (window-buffer) is different from (current-buffer) to help us catch
those problem.


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-04 12:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-03 11:59 comint-preoutput-filter-functions and flickering redisplay in TTY Mario Lang
2014-06-03 12:27 ` Nicolas Richard
2014-06-03 13:12   ` Mario Lang
2014-06-04 10:36     ` Nicolas Richard
2014-06-04 12:30   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).