Package: emacs;
Reported by: Phil Sainty <psainty <at> orcon.net.nz>
Date: Tue, 17 Apr 2018 13:01:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 26.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31193 in the body.
You can then email your comments to 31193 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Tue, 17 Apr 2018 13:01:02 GMT) Full text and rfc822 format available.Phil Sainty <psainty <at> orcon.net.nz>
:bug-gnu-emacs <at> gnu.org
.
(Tue, 17 Apr 2018 13:01:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: bug-gnu-emacs <at> gnu.org Subject: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 01:00:14 +1200
In a `term' buffer, seemingly after any window configuration change, the process filter triggers an error due to `term-current-row' being nil unexpectedly. Recipe: emacs -Q M-x toggle-debug-on-error M-x term RET RET #repeatedly -- all is fine at this point... C-c 2 RET Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) term-down(1 t) term-emulate-terminal(#<process terminal> "\015\033[K$ \015\n\032//home/phil\015\n") That window config change could be C-c 2 or C-c 3 or, if already split, C-c 1; it doesn't seem to matter. With an uncompiled `term-down': Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) =(nil 0) (and (= term-current-row 0) (< down 0)) (if (and (= term-current-row 0) (< down 0)) ...) (let ((start-column (term-horizontal-column))) ...) term-down(1 t) term-emulate-terminal(#<process terminal> "\015\033[K$ \015\n\032//home/phil\015\n") That test of (= term-current-row 0) occurs twice in the function. Trivially, testing (bound-and-true-p term-current-row) beforehand in both pieces of code circumvents the error and appears in practice to resolve the issue, but I don't know whether that's the *right* fix. -Phil In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 2018-04-15 built on shodan Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.4 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Debug on Error enabled globally Entering debugger... term-emulate-terminal: Wrong type argument: number-or-marker-p, nil Configured using: 'configure --prefix=/home/phil/emacs/26.1rc1/usr/local --with-x-toolkit=lucid --without-sound' Configured features: XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK DBUS GSETTINGS NOTIFY GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 THREADS LCMS2 Important settings: value of $LANG: en_NZ.UTF-8 locale-coding-system: utf-8-unix Major mode: Debugger Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t line-number-mode: t transient-mark-mode: (only . t) Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny seq dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode cl-print byte-opt gv bytecomp byte-compile cl-loaddefs cl-lib cconv debug term disp-table easymenu ehelp ring cus-start cus-load elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 108699 9507) (symbols 48 22248 1) (miscs 40 76 129) (strings 32 32773 1265) (string-bytes 1 829787) (vectors 16 14995) (vector-slots 8 503659 11454) (floats 8 61 115) (intervals 56 287 0) (buffers 992 13) (heap 1024 42349 1368))
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Tue, 17 Apr 2018 13:24:02 GMT) Full text and rfc822 format available.Message #8 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Noam Postavsky <npostavs <at> gmail.com> To: Phil Sainty <psainty <at> orcon.net.nz> Cc: 31193 <at> debbugs.gnu.org Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Tue, 17 Apr 2018 09:23:46 -0400
Phil Sainty <psainty <at> orcon.net.nz> writes: > In a `term' buffer, seemingly after any window configuration change, the > process filter triggers an error due to `term-current-row' being nil > unexpectedly. > > Recipe: > > emacs -Q > M-x toggle-debug-on-error > M-x term > RET > RET #repeatedly -- all is fine at this point... > C-c 2 > RET > > Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p > nil) > term-down(1 t) > term-emulate-terminal(#<process terminal> "\015\033[K$ > \015\n\032//home/phil\015\n") Hmm, I'm not able to reproduce this, even though it makes sense to me that my fix for Bug#30544 [1: a64c11a3aa] would cause this. Perhaps it depends on your shell prompt as well? > That test of (= term-current-row 0) occurs twice in the function. > > Trivially, testing (bound-and-true-p term-current-row) beforehand in > both pieces of code circumvents the error and appears in practice to > resolve the issue, but I don't know whether that's the *right* fix. I think changing them to function calls, i.e., (term-current-row) instead of term-current-row would be the right thing; all the other term functions use the function rather than accessing the variable directly. [1: a64c11a3aa]: 2018-04-02 06:57:53 -0400 Fix term.el rendering following a window resize (Bug#30544) https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=a64c11a3aa49121ceab79a2acc99c829d42417bd>
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Tue, 17 Apr 2018 13:50:01 GMT) Full text and rfc822 format available.Message #11 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: Noam Postavsky <npostavs <at> gmail.com> Cc: 31193 <at> debbugs.gnu.org Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 01:49:20 +1200
On 2018-04-18 01:23, Noam Postavsky wrote: > Hmm, I'm not able to reproduce this, even though it makes sense to me > that my fix for Bug#30544 [1: a64c11a3aa] would cause this. Perhaps it > depends on your shell prompt as well? I do have a non-trivial prompt; but after setting PS1="$ " I still see the same issue, so I'm unsure whether that's a factor. My shell is bash. > I think changing them to function calls, i.e., (term-current-row) > instead of term-current-row would be the right thing; all the other > term > functions use the function rather than accessing the variable directly. That sounds sane, and I can confirm that it fixes the problem.
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 00:08:02 GMT) Full text and rfc822 format available.Message #14 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Noam Postavsky <npostavs <at> gmail.com> To: Phil Sainty <psainty <at> orcon.net.nz> Cc: 31193 <at> debbugs.gnu.org Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Tue, 17 Apr 2018 20:07:41 -0400
[Message part 1 (text/plain, inline)]
tags 31193 + patch quit Phil Sainty <psainty <at> orcon.net.nz> writes: > On 2018-04-18 01:23, Noam Postavsky wrote: >> Hmm, I'm not able to reproduce this, even though it makes sense to me >> that my fix for Bug#30544 [1: a64c11a3aa] would cause this. Perhaps it >> depends on your shell prompt as well? > > I do have a non-trivial prompt; but after setting PS1="$ " I still see > the same issue, so I'm unsure whether that's a factor. My shell is > bash. Hmm, maybe it's a difference in bash versions? I tried adding a newline to my prompt with PS1=$'one\ntwo$ ', but bash doesn't send the newline after the terminal resizes. Seems it's clever enough just to redraw the last line. GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) And since terminal-emulate-terminal doesn't receive a \n character, it doesn't call term-down before calling (term-current-row) near the end of that function: (when (>= (term-current-row) term-height) (term-handle-deferred-scroll)) So I definitely can't see how you trigger this with PS1="$ ", but perhaps your version of bash sends a newline for some other reason? Can you show the backtrace with PS1="$ "? >> I think changing them to function calls, i.e., (term-current-row) >> instead of term-current-row would be the right thing; all the other >> term >> functions use the function rather than accessing the variable directly. > > That sounds sane, and I can confirm that it fixes the problem. Okay, here's the patch with message. Eli, should I apply this to emacs-26? I believe it's safe because the term-current-row function simply returns the value of the term-current-row variable if that is non-nil. Hence it should only affect cases where we were going to signal an error due to type-mismatch anyway.
[0001-Don-t-assume-term-current-row-cache-is-valid-Bug-311.patch (text/x-diff, inline)]
From c1faca2b07ac86f84450bbb95ecb6d8635410281 Mon Sep 17 00:00:00 2001 From: Noam Postavsky <npostavs <at> gmail.com> Date: Tue, 17 Apr 2018 19:17:18 -0400 Subject: [PATCH] Don't assume term-current-row cache is valid (Bug#31193) * lisp/term.el (term-down): Call `term-current-row' instead of directly accessing the variable `term-current-row. Following a resize of the terminal's window, `term-current-row' is reset to nil, so it is not safe to assume it is a number. --- lisp/term.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/term.el b/lisp/term.el index 0a5efa4abc..6860ea6934 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -3764,7 +3764,7 @@ term-down (let ((start-column (term-horizontal-column))) (when (and check-for-scroll (or term-scroll-with-delete term-pager-count)) (setq down (term-handle-scroll down))) - (unless (and (= term-current-row 0) (< down 0)) + (unless (and (= (term-current-row) 0) (< down 0)) (term-adjust-current-row-cache down) (when (or (/= (point) (point-max)) (< down 0)) (setq down (- down (term-vertical-motion down))))) @@ -3774,7 +3774,7 @@ term-down (setq term-current-column 0) (setq term-start-line-column 0)) (t - (when (= term-current-row 0) + (when (= (term-current-row) 0) ;; Insert lines if at the beginning. (save-excursion (term-insert-char ?\n (- down))) (save-excursion -- 2.11.0
Noam Postavsky <npostavs <at> gmail.com>
to control <at> debbugs.gnu.org
.
(Wed, 18 Apr 2018 00:08:02 GMT) Full text and rfc822 format available.bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 01:05:01 GMT) Full text and rfc822 format available.Message #19 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: Noam Postavsky <npostavs <at> gmail.com> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 13:04:13 +1200
On 2018-04-18 12:07, Noam Postavsky wrote: > Hmm, maybe it's a difference in bash versions? I tried adding a > newline > to my prompt with PS1=$'one\ntwo$ ', but bash doesn't send the newline > after the terminal resizes. Seems it's clever enough just to redraw > the > last line. > > GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) Mine is: GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) > Can you show the backtrace with PS1="$ "? Sure. This is with a .bashrc containing only that setting, and an otherwise blank-slate $HOME directory, in case anything else I was doing had an effect. It might still be due to system-wide config, but the bash version difference seems as likely as anything else? Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil) =(nil 0) (and (= term-current-row 0) (< down 0)) (if (and (= term-current-row 0) (< down 0)) nil (term-adjust-current-row-cache down) (if (or (/= (point) (point-max)) (< down 0)) (progn (setq down (- down (funcall term-vertical-motion down)))))) (let ((start-column (term-horizontal-column))) (if (and check-for-scroll (or term-scroll-with-delete term-pager-count)) (progn (setq down (term-handle-scroll down)))) (if (and (= term-current-row 0) (< down 0)) nil (term-adjust-current-row-cache down) (if (or (/= (point) (point-max)) (< down 0)) (progn (setq down (- down (funcall term-vertical-motion down)))))) (cond ((>= down 0) (term-insert-char 10 down) (setq term-current-column 0) (setq term-start-line-column 0)) (t (if (= term-current-row 0) (progn (save-excursion (term-insert-char 10 (- down))) (save-excursion (let (p) (forward-line term-height) (setq p (point)) (forward-line (- down)) (delete-region p (point)))))) (setq term-current-column 0) (setq term-start-line-column (current-column)))) (if start-column (progn (term-move-columns start-column)))) term-down(1 t) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t)) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char))) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i))) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state)) (save-current-buffer (unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state)))) (let* ((i 0) char funny count count-bytes decoded-substring save-point save-marker old-point temp win (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win handled-ansi-message (str-length (length str))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state))))) (save-current-buffer (set-buffer (process-buffer proc)) (let* ((i 0) char funny count count-bytes decoded-substring save-point save-marker old-point temp win (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win handled-ansi-message (str-length (length str))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (let ((newstr (term-handle-ansi-terminal-messages str))) (if (eq str newstr) nil (setq handled-ansi-message t str newstr))) (setq str-length (length str)) (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker (process-mark proc)) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point (point-marker)))) (setq term-vertical-motion (if (eq (window-buffer) (current-buffer)) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and (> (point-max) (process-mark proc)) (not (eq (current-local-map) term-raw-map))) (progn (narrow-to-region (point-min) (process-mark proc)))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str (concat term-terminal-undecoded-bytes str)) (setq str-length (length str)) (setq term-terminal-undecoded-bytes nil))) (cond ((eq term-terminal-state 4) (setq str (concat term-terminal-parameter str)) (setq term-terminal-parameter nil) (setq str-length (length str)) (setq term-terminal-state 0))) (while (< i str-length) (setq char (aref str i)) (cond ((< term-terminal-state 2) (setq funny (string-match "[\015\n\0\007\033\011\010\032\016\017]" str i)) (if (not funny) (progn (setq funny str-length))) (cond ((> funny i) (cond ((eq term-terminal-state 1) (term-down 1 t) (term-move-columns (- (term-current-column))) (setq term-terminal-state 0))) (setq decoded-substring (decode-coding-string (substring str i funny) locale-coding-system)) (setq count (length decoded-substring)) (if (= funny str-length) (progn (let ((partial 0)) (while (eq (char-charset (aref decoded-substring (- count 1 partial))) 'eight-bit) (setq partial (1+ partial))) (if (> partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring (- partial))) (setq decoded-substring (substring decoded-substring 0 (- partial))) (setq str-length (- str-length partial)) (setq count (- count partial)) (setq funny (- funny partial))))))) (setq temp (- (+ (term-horizontal-column) count) term-width)) (cond ((or term-suppress-hard-newline (<= temp 0))) ((> count temp) (setq count (- count temp)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq temp 0) (setq funny (+ count-bytes i))) ((or (not (or term-pager-count term-scroll-with-delete)) (> (term-handle-scroll 1) 0)) (term-adjust-current-row-cache 1) (setq count (min count term-width)) (setq count-bytes (length (encode-coding-string (substring decoded-substring 0 count) 'binary))) (setq funny (+ count-bytes i)) (setq term-start-line-column term-current-column)) (t (setq count 0 funny i) (setq term-current-column nil) (setq term-start-line-column nil))) (setq old-point (point)) (let ((old-column (current-column)) columns pos) (insert (decode-coding-string (substring str i funny) locale-coding-system)) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (setq pos (point)) (term-move-columns columns) (delete-region pos (point)))) (if term-insert-mode (progn (setq pos (point)) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- (point) (- (current-column) term-width)) (point)))) (goto-char pos)))) (setq term-current-column nil) (put-text-property old-point (point) 'font-lock-face term-current-face) (cond ((eq temp 0) (term-move-columns -1) (setq term-terminal-state 1))) (setq i (1- funny))) ((and (setq term-terminal-state 0) (eq char 9)) (setq count (term-current-column)) (setq count (min term-width (+ count 8 (- (mod count 8))))) (if (> term-width count) (progn (term-move-columns (- count (term-current-column))) (setq term-current-column count)) (if (> term-width (term-current-column)) (progn (term-move-columns (1- (- term-width (term-current-column)))))) (if (= term-width (term-current-column)) (progn (term-move-columns -1))))) ((eq char 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eq char 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eq char 8) (term-move-columns -1)) ((eq char 27) (setq term-terminal-state 2)) ((eq char 0)) ((eq char 14)) ((eq char 15)) ((eq char 7) (beep t)) ((eq char 26) (let ((end (string-match "\015?\n" str i))) (if end (progn (if handled-ansi-message nil (funcall term-command-hook (decode-coding-string (substring str (1+ i) end) locale-coding-system))) (setq i (1- (match-end 0)))) (setq term-terminal-parameter (substring str i)) (setq term-terminal-state 4) (setq i str-length)))) (t (term-move-columns 1) (backward-delete-char 1) (insert char)))) ((eq term-terminal-state 2) (cond ((eq char 91) (setq term-terminal-parameter 0) (setq term-terminal-previous-parameter -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-more-parameters 0) (setq term-terminal-state 3)) ((eq char 68) (term-handle-deferred-scroll) (term-down 1 t) (setq term-terminal-state 0)) ((eq char 77) (if (or (< (term-current-row) term-scroll-start) (>= (1- (term-current-row)) term-scroll-start)) (term-down -1) (term-down -1 t)) (setq term-terminal-state 0)) ((eq char 55) (term-handle-deferred-scroll) (setq term-saved-cursor (list (term-current-row) (term-horizontal-column) term-ansi-current-bg-color term-ansi-current-bold term-ansi-current-color term-ansi-current-invisible term-ansi-current-reverse term-ansi-current-underline term-current-face)) (setq term-terminal-state 0)) ((eq char 56) (if term-saved-cursor (progn (term-goto (nth 0 term-saved-cursor) (nth 1 term-saved-cursor)) (setq term-ansi-current-bg-color (nth 2 term-saved-cursor) term-ansi-current-bold (nth 3 term-saved-cursor) term-ansi-current-color (nth 4 term-saved-cursor) term-ansi-current-invisible (nth 5 term-saved-cursor) term-ansi-current-reverse (nth 6 term-saved-cursor) term-ansi-current-underline (nth 7 term-saved-cursor) term-current-face (nth 8 term-saved-cursor)))) (setq term-terminal-state 0)) ((eq char 99) (setq term-terminal-state 0) (term-reset-terminal)) ((setq term-terminal-state 0)))) ((eq term-terminal-state 3) (cond ((and (>= char 48) (<= char 57)) (setq term-terminal-parameter (+ (* 10 term-terminal-parameter) (- char 48)))) ((eq char 59) (setq term-terminal-more-parameters 1) (setq term-terminal-previous-parameter-4 term-terminal-previous-parameter-3) (setq term-terminal-previous-parameter-3 term-terminal-previous-parameter-2) (setq term-terminal-previous-parameter-2 term-terminal-previous-parameter) (setq term-terminal-previous-parameter term-terminal-parameter) (setq term-terminal-parameter 0)) ((eq char 63)) (t (term-handle-ansi-escape proc char) (setq term-terminal-more-parameters 0) (setq term-terminal-previous-parameter-4 -1) (setq term-terminal-previous-parameter-3 -1) (setq term-terminal-previous-parameter-2 -1) (setq term-terminal-previous-parameter -1) (setq term-terminal-state 0))))) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-parameter (substring str i)) (if (= 0 i) (setq term-terminal-parameter (concat "\015" (substring str i))) (setq term-terminal-parameter (substring str (1- i))) (aset term-terminal-parameter 0 13)) (goto-char (point-max))) (setq term-terminal-state 4) (make-local-variable 'term-pager-old-filter) (setq term-pager-old-filter (process-filter proc)) (set-process-filter proc term-pager-filter) (setq i str-length))) (setq i (1+ i)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq (window-buffer selected) (current-buffer))) (progn (term-display-line (car term-pending-frame) (cdr term-pending-frame)) (setq term-pending-frame nil))) (setq win selected) (while (window-minibuffer-p win) (setq win (next-window win nil t))) (setq last-win win) (while (progn (setq win (next-window win nil t)) (if (eq (window-buffer win) (process-buffer proc)) (progn (let ((scroll term-scroll-to-bottom-on-output)) (select-window win) (if (or (= (point) save-marker) (eq scroll t) (eq scroll 'all) (and (eq selected win) (or (eq scroll 'this) (not save-point))) (and (eq scroll 'others) (not (eq selected win)))) (progn (goto-char term-home-marker) (recenter 0) (goto-char (process-mark proc)) (if (not (pos-visible-in-window-p (point) win)) (recenter -1)))) (if (and term-scroll-show-maximum-output (>= (point) (process-mark proc))) (progn (save-excursion (goto-char (point-max)) (recenter -1))))))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process (current-buffer)))) (forward-line (- term-buffer-maximum-size)) (beginning-of-line) (delete-region (point-min) (point))))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state))))) (if (get-buffer-window (current-buffer)) (progn (redisplay)))) term-emulate-terminal(#<process terminal> "\015\033[K$ \015\n\032//home/phil/emacs/26/26.1rc1/usr/local/share/emacs/26.1/lisp\015\n")
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 02:05:01 GMT) Full text and rfc822 format available.Message #22 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Noam Postavsky <npostavs <at> gmail.com> To: Phil Sainty <psainty <at> orcon.net.nz> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Tue, 17 Apr 2018 22:04:30 -0400
Phil Sainty <psainty <at> orcon.net.nz> writes: > On 2018-04-18 12:07, Noam Postavsky wrote: >> Hmm, maybe it's a difference in bash versions? I tried adding a >> newline to my prompt with PS1=$'one\ntwo$ ', but bash doesn't send >> the newline after the terminal resizes. Seems it's clever enough >> just to redraw the last line. >> >> GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) > > Mine is: > GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) > > >> Can you show the backtrace with PS1="$ "? > > Sure. This is with a .bashrc containing only that setting, and an > otherwise blank-slate $HOME directory, in case anything else I was > doing had an effect. It might still be due to system-wide config, > but the bash version difference seems as likely as anything else? > term-emulate-terminal(#<process terminal> "\015\033[K$ > \015\n\032//home/phil/emacs/26/26.1rc1/usr/local/share/emacs/26.1/lisp\015\n") Hmm, yeah, it looks like your bash adds a "\r\n" (\015 is \r) after the prompt, while mine doesn't. Although, wouldn't that extra \n leave your cursor one row below the prompt? I also don't get the \032/<path>\r\n unless I do a 'cd'.
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 04:24:02 GMT) Full text and rfc822 format available.Message #25 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: Noam Postavsky <npostavs <at> gmail.com> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 16:23:37 +1200
On 2018-04-18 14:04, Noam Postavsky wrote: >> term-emulate-terminal(#<process terminal> "\015\033[K$ >> \015\n\032//home/phil/emacs/26/26.1rc1/usr/local/share/emacs/26.1/lisp\015\n") > > Hmm, yeah, it looks like your bash adds a "\r\n" (\015 is \r) after the > prompt, while mine doesn't. Although, wouldn't that extra \n leave > your > cursor one row below the prompt? In practice the carriage return shunts the cursor back to the start of the prompt that I was already at, and then gets 'stuck' there -- no new line is created. Typing RET again triggers the same error (with no change to the buffer), but as soon as I start typing other keys, functionality is restored. > I also don't get the \032/<path>\r\n unless I do a 'cd'. I observe that whenever I execute a shell command (or just enter a blank line) and then trigger the error, I get this the first time: term-emulate-terminal(#<process terminal> "\015\033[K$\015\n") but repeatedly re-triggering the error gives me this every time: term-emulate-terminal(#<process terminal> "\015\033[K$\015\n\032/<path>\015\n$") (until I next enter a command or blank line.) The <path> matches the directory tracking -- I can affect it with cd. (but setting default-directory does not affect it).
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 05:06:02 GMT) Full text and rfc822 format available.Message #28 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: Noam Postavsky <npostavs <at> gmail.com> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 17:05:36 +1200
On 2018-04-18 13:04, Phil Sainty wrote: > On 2018-04-18 12:07, Noam Postavsky wrote: >> Hmm, maybe it's a difference in bash versions? >> GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu) > > GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) I've just compiled bash 4.4.12 and confirmed that this issue does not occur with that version. GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 05:38:01 GMT) Full text and rfc822 format available.Message #31 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Phil Sainty <psainty <at> orcon.net.nz> To: Noam Postavsky <npostavs <at> gmail.com> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 17:37:19 +1200
On 2018-04-18 17:05, Phil Sainty wrote: > I've just compiled bash 4.4.12 and confirmed that this issue > does not occur with that version. And conversely the issue *does* occur with both bash-4.3.tar.gz and bash-4.3.30.tar.gz if I compile those from source, so you ought to be able to replicate that behaviour for yourself with either of those.
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 06:26:01 GMT) Full text and rfc822 format available.Message #34 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Eli Zaretskii <eliz <at> gnu.org> To: Noam Postavsky <npostavs <at> gmail.com> Cc: psainty <at> orcon.net.nz, 31193 <at> debbugs.gnu.org Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 09:25:41 +0300
> From: Noam Postavsky <npostavs <at> gmail.com> > Date: Tue, 17 Apr 2018 20:07:41 -0400 > Cc: 31193 <at> debbugs.gnu.org > > Okay, here's the patch with message. Eli, should I apply this to > emacs-26? Yes, please. > I believe it's safe because the term-current-row function > simply returns the value of the term-current-row variable if that is > non-nil. Hence it should only affect cases where we were going to > signal an error due to type-mismatch anyway. Agreed. Thanks.
bug-gnu-emacs <at> gnu.org
:bug#31193
; Package emacs
.
(Wed, 18 Apr 2018 12:16:02 GMT) Full text and rfc822 format available.Message #37 received at 31193 <at> debbugs.gnu.org (full text, mbox):
From: Noam Postavsky <npostavs <at> gmail.com> To: Phil Sainty <psainty <at> orcon.net.nz> Cc: 31193 <at> debbugs.gnu.org, bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=orcon.net.nz <at> gnu.org> Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change Date: Wed, 18 Apr 2018 08:15:23 -0400
tags 31193 fixed close 31193 quit I could reproduce the error when using bash 4.3. The main difference in versions seems to be that bash-4.4 repaints the last line of the prompt in reponse to the resize event, whereas bash-4.3 doesn't respond to that event; it just waits for the next user input. Phil Sainty <psainty <at> orcon.net.nz> writes: > I observe that whenever I execute a shell command (or just enter a blank > line) and then trigger the error, I get this the first time: > > term-emulate-terminal(#<process terminal> "\015\033[K$\015\n") Although I never got this short string. I always get "\015\033[K<prompt>\015\n\032/<path>\015\n<prompt>". Not really that important, it's just kind of tickling my curiosity. Anyways, pushed the fixed to emacs-26. [1: b89ff0efdb]: 2018-04-18 07:33:27 -0400 Don't assume term-current-row cache is valid (Bug#31193) https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=b89ff0efdb65e9febe4c3ed2586a48a2b42233aa
Noam Postavsky <npostavs <at> gmail.com>
to control <at> debbugs.gnu.org
.
(Wed, 18 Apr 2018 12:16:02 GMT) Full text and rfc822 format available.Noam Postavsky <npostavs <at> gmail.com>
to control <at> debbugs.gnu.org
.
(Wed, 18 Apr 2018 12:16:02 GMT) Full text and rfc822 format available.Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Thu, 17 May 2018 11:24:05 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.