The bi-directional text support introduced in Emacs 24 interacts badly with term.el when large numbers of spaces or tabs are inserted, and many applications clear the screen (often drawing a new background colour) by writing WIDTHxHEIGHT spaces (which, if the terminal’s dimensions are sufficiently large, may take several seconds).
The workaround is to prevent Emacs from guessing the text direction in term-mode, and simply enforce a left-to-right direction:
;; Terminal buffer configuration.
(add-hook 'term-mode-hook 'my-term-mode-hook)
(defun my-term-mode-hook ()
;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20611
(setq bidi-paragraph-direction 'left-to-right))
I've also updatedThis workaround is enabled by default in https://www.emacswiki.org/emacs/AnsiTermHints with the same informationterm-mode
for Emacs 25.1 (and current pre-releases thereof), so manually configuring term-mode-hook
should only be necessary for Emacs 24.x.
edit: ThisThe root of the problem has been fixed in the Emacs master branch, such (such that thisthe workaround is not necessaryneeded at all). TheThat fix should be included in either Emacs 25.2 or 25.3.
I've also updated https://www.emacswiki.org/emacs/AnsiTermHints with the same information.
For the sake of searchability, here are the names of the applications I'm aware of which trigger this problem. These are mostly (if not all) curses- or ncurses-based -- presumably this method of screen refresh is a commonly-used curses function -- and so it is highly probable that many other curses applications will do the same thing.
- alsamixer
- dialog
- dpkg-reconfigure
- lynx
- mc (midnight commander)
- mutt