Various optimizations. The main one is to optimize for
simple output at the end of the buffer, with no paging, and in that
case to defer scrolling while we can.
(term-emulate-terminal): Don't call term-handle-scroll in
simple cases unless we are either paging or term-scroll-with-delete.
(term-down): Likewise.
(term-handle-scroll): Modify accordingly.
(term-emulate-terminal): Avoid deleting old text in common case.
Optimize the simple case of CRLF when we're at buffer end.
Handle deferred scroll when done processing output.
(term-handle-deferred-scroll): New function.
(term-down): Simplify - no longer take RIGHT argument. Tune.
(term-goto): Use term-move-columns to compensate for the above.