Subject: Re: bug#31193: 26.1; error in `term-down' after window configuration change

From: Phil Sainty <[email-masked]>
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")