emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deffering redisplay in COMINT


From: Michael Mauger
Subject: Re: Deffering redisplay in COMINT
Date: Sun, 6 Jan 2013 00:09:52 -0800 (PST)

>________________________________
> Vitalie Spinu <address@hidden>
> on Tuesday, December 25, 2012 6:09 AM wrote:
> 
>  >> Michael Mauger <address@hidden>
>  >> on Thu, 6 Dec 2012 17:08:33 -0800 (PST) wrote:
>
>  > In sql-interactive-mode, a derivative of comint, I will submit a SELECT
>  > statement that returns many very long rows (2000+ characters per line).  
>The
>  > redisplay fireworks that follow are impressive but slow.   As text streams 
>to
>  > the buffer with `auto-hscroll-mode' enabled the screen flashes as it 
>redraws the
>  > buffer with more lines of data and scrolled horizontally in different 
>places
>  > until all the data stream is complete.  
>
....
>
>  > My only thought is that I could route the output to a temp buffer until I 
>see
>  > the prompt at the end of a chunk
>
>To the best of my knowledge this is the only way out. But it is not bad
>at all. You have to replace comint-output-filter with your own filter
>that does that. The filter is triggered each time emacs receives output
>from the sub-process (roughly 500 chars last time I counted).  It's
>pretty trivial to wait for a prompt at the end of output chunk, and you
>will be surprised how reliable this procedure actually is. 
>
>This is how we do it in ESS:
>
>   (defun ess-wait-for-process (proc &optional sec-prompt wait force-redisplay)
....
>
>

Thanks for your input.  I took a look, but that approach makes emacs 
modal, in that it locks up until the output is complete.  I want to still
have a responsive editor since it make take a while before results start
to appear.  But I've come up with a solution that gets reasonable 
performance and only has a minor functional impact.

I'll give a brief description here, and I'll release this as a SQL-related 
add-in in the ELPA shortly.

It's set up as a minor mode so it can be disabled in case it causes 
problems.  When it's enabled, it activates a pre and post output hooks.
The pre hook only activates if the mode is enabled and truncate-lines
is set.  When active, it disables auto-hscroll-mode.  It then appends 
the output text to a temporary buffer and then returns a window's
width worth of characters of each line in the temp buffer to 
be written to the output buffer.  The output appears to fill each 
line without the display slowdown due to long displayed lines.
And because hscroll is turned off, the text merely flows up the
screen quickly.

When the post output hook is called and it detects when the last
output text matches the prompt regexp, then it iterates thru 
the temporary buffer and the output buffer starting at 
comint-last-input-end.  It takes each line after the window-
width worth of characters from the temp buffer and inserts them
at the end of each line in the output buffer.  Once the output 
buffer has been filled in with all the off-window text it re-enables
the horizontal scrolling.

The result is fast smooth scrolling and an often unnoticeable 
hesitation when it is complete.  It's not vital to have this to 
use sql-mode, but having it as an add-on minor mode eliminates 
a significant distraction when doing query development in Emacs.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]