unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Mauger <mmaug@yahoo.com>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Deffering redisplay in COMINT
Date: Sun, 6 Jan 2013 00:09:52 -0800 (PST)	[thread overview]
Message-ID: <1357459792.82082.YahooMailNeo@web160901.mail.bf1.yahoo.com> (raw)
In-Reply-To: <87obhi1j85.fsf@gmail.com>

>________________________________
> Vitalie Spinu <spinuvit@gmail.com>
> on Tuesday, December 25, 2012 6:09 AM wrote:
> 
>  >> Michael Mauger <mmaug@yahoo.com>
>  >> 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	other threads:[~2013-01-06  8:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07  1:08 Deffering redisplay in COMINT Michael Mauger
2012-12-25 11:09 ` Vitalie Spinu
2013-01-06  8:09   ` Michael Mauger [this message]
2013-01-08 18:19     ` Stefan Monnier
2013-01-11 14:40       ` Michael Mauger
2013-01-11 15:55         ` Stefan Monnier
2013-01-13  8:14           ` Michael Mauger
2013-01-13 16:46             ` Eli Zaretskii
2013-01-16 14:39             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1357459792.82082.YahooMailNeo@web160901.mail.bf1.yahoo.com \
    --to=mmaug@yahoo.com \
    --cc=emacs-devel@gnu.org \
    --cc=spinuvit@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).