Subject: bug#51877: 27.2; term: error in process filter

From: Christopher Howard <[email-masked]>
Date: Thu, 20 Jan 2022 13:01:12 -0900

On Thu, Jan 20, 2022 at 10:02:10PM +0200, Eli Zaretskii wrote:
> I don't think this would help.  Can you manually modify the function
> term-emulate-terminal to use 'raw-text instead of
> locale-coding-system, and then re-run the scenario in which you get
> these problems?

This seems to generate the same result, except with more elaborate debugger output:

```
Debugger entered--Lisp error: (args-out-of-range "l \3\220\0332Nn\f\217" 0 -48)
  substring("l \3\220\0332Nn\f\217" 0 -48)
  (insert (substring decoded-substring 0 (- term-width old-column)))
  (while (> (+ (length decoded-substring) old-column) term-width) (insert (substring decoded-substring 0 (- term-width old-column))) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- (term-current-column))) (add-text-properties (1- (point)) (point) '(term-line-wrap t rear-nonsticky t)) (setq decoded-substring (substring decoded-substring (- term-width old-column))) (setq old-column 0))
  (if term-suppress-hard-newline nil (while (> (+ (length decoded-substring) old-column) term-width) (insert (substring decoded-substring 0 (- term-width old-column))) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- (term-current-column))) (add-text-properties (1- (point)) (point) '(term-line-wrap t rear-nonsticky t)) (setq decoded-substring (substring decoded-substring (- term-width old-column))) (setq old-column 0)))
  (let ((old-column (term-horizontal-column)) (old-point (point)) columns) (if term-suppress-hard-newline nil (while (> (+ (length decoded-substring) old-column) term-width) (insert (substring decoded-substring 0 (- term-width old-column))) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- (term-current-column))) (add-text-properties (1- (point)) (point) '(term-line-wrap t rear-nonsticky t)) (setq decoded-substring (substring decoded-substring (- term-width old-column))) (setq old-column 0))) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (let ((pos (point))) (term-move-columns columns) (delete-region pos (point)) (setq term-current-column nil)))) (if term-insert-mode (progn (let ((pos (point))) (end-of-line) (if (> (current-column) term-width) (progn (delete-region (- ... ...) (point)))) (goto-char pos)))) (put-text-property old-point (point) 'font-lock-face term-current-face))
  (progn (if term-do-line-wrapping (progn (term-down 1 t) (term-move-to-column 0) (setq term-do-line-wrapping nil))) (setq decoded-substring (decode-coding-string (substring str i funny) 'raw-text t)) (if (= funny str-length) (progn (let ((partial 0) (count (length decoded-substring))) (while (and (< partial count) (eq (char-charset ...) 'eight-bit)) (setq partial (1+ partial))) (if (> count partial 0) (progn (setq term-terminal-undecoded-bytes (substring decoded-substring ...)) (setq decoded-substring (substring decoded-substring 0 ...)) (setq str-length (- str-length partial)) (setq funny (- funny partial))))))) (let ((old-column (term-horizontal-column)) (old-point (point)) columns) (if term-suppress-hard-newline nil (while (> (+ (length decoded-substring) old-column) term-width) (insert (substring decoded-substring 0 (- term-width old-column))) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- (term-current-column))) (add-text-properties (1- (point)) (point) '(term-line-wrap t rear-nonsticky t)) (setq decoded-substring (substring decoded-substring (- term-width old-column))) (setq old-column 0))) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (let ((pos (point))) (term-move-columns columns) (delete-region pos (point)) (setq term-current-column nil)))) (if term-insert-mode (progn (let ((pos (point))) (end-of-line) (if (> (current-column) term-width) (progn (delete-region ... ...))) (goto-char pos)))) (put-text-property old-point (point) 'font-lock-face term-current-face)) (if (eq (term-current-column) term-width) (progn (term-move-columns -1) (setq term-do-line-wrapping (point)))) (setq term-current-column nil) (setq i funny))
  (if (> funny i) (progn (if term-do-line-wrapping (progn (term-down 1 t) (term-move-to-column 0) (setq term-do-line-wrapping nil))) (setq decoded-substring (decode-coding-string (substring str i funny) 'raw-text t)) (if (= funny str-length) (progn (let ((partial 0) (count (length decoded-substring))) (while (and (< partial count) (eq ... ...)) (setq partial (1+ partial))) (if (> count partial 0) (progn (setq term-terminal-undecoded-bytes ...) (setq decoded-substring ...) (setq str-length ...) (setq funny ...)))))) (let ((old-column (term-horizontal-column)) (old-point (point)) columns) (if term-suppress-hard-newline nil (while (> (+ (length decoded-substring) old-column) term-width) (insert (substring decoded-substring 0 (- term-width old-column))) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- (term-current-column))) (add-text-properties (1- (point)) (point) '(term-line-wrap t rear-nonsticky t)) (setq decoded-substring (substring decoded-substring (- term-width old-column))) (setq old-column 0))) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (let ((pos ...)) (term-move-columns columns) (delete-region pos (point)) (setq term-current-column nil)))) (if term-insert-mode (progn (let ((pos ...)) (end-of-line) (if (> ... term-width) (progn ...)) (goto-char pos)))) (put-text-property old-point (point) 'font-lock-face term-current-face)) (if (eq (term-current-column) term-width) (progn (term-move-columns -1) (setq term-do-line-wrapping (point)))) (setq term-current-column nil) (setq i funny)))
  (let ((ctl-params (and funny (match-string 1 str))) (ctl-params-end (and funny (match-end 1))) (ctl-end (if funny (match-end 0) (setq funny (string-match term-control-seq-prefix-regexp str i)) (if funny (setq term-terminal-undecoded-bytes (substring str funny)) (setq funny str-length)) (1+ str-length)))) (if (> funny i) (progn (if term-do-line-wrapping (progn (term-down 1 t) (term-move-to-column 0) (setq term-do-line-wrapping nil))) (setq decoded-substring (decode-coding-string (substring str i funny) 'raw-text t)) (if (= funny str-length) (progn (let ((partial 0) (count ...)) (while (and ... ...) (setq partial ...)) (if (> count partial 0) (progn ... ... ... ...))))) (let ((old-column (term-horizontal-column)) (old-point (point)) columns) (if term-suppress-hard-newline nil (while (> (+ ... old-column) term-width) (insert (substring decoded-substring 0 ...)) (delete-region (point) (line-end-position)) (term-down 1 t) (term-move-columns (- ...)) (add-text-properties (1- ...) (point) '...) (setq decoded-substring (substring decoded-substring ...)) (setq old-column 0))) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or (eobp) term-insert-mode)) (progn (let (...) (term-move-columns columns) (delete-region pos ...) (setq term-current-column nil)))) (if term-insert-mode (progn (let (...) (end-of-line) (if ... ...) (goto-char pos)))) (put-text-property old-point (point) 'font-lock-face term-current-face)) (if (eq (term-current-column) term-width) (progn (term-move-columns -1) (setq term-do-line-wrapping (point)))) (setq term-current-column nil) (setq i funny))) (let* ((val (and (<= ctl-end str-length) (aref str i)))) (cond ((eql val 9) (let ((col (term-current-column))) (term-move-to-column (min (1- term-width) (+ col 8 ...))))) ((eql val 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eql val 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eql val 8) (term-move-columns -1)) ((eql val 7) (beep t)) ((eql val 26) (funcall term-command-function (decode-coding-string (substring str (1+ i) (- ctl-end ...)) locale-coding-system t))) ((eql val 27) (let* ((val (aref str ...))) (cond ((eql val 91) (if ... ...)) ((eql val 68) (term-handle-deferred-scroll) (term-down 1 t)) ((eql val 77) (if ... ... ...)) ((eql val 55) (term-handle-deferred-scroll) (setq term-saved-cursor ...)) ((eql val 56) (if term-saved-cursor ...)) ((eql val 99) (term-reset-terminal)) ((eql val 65) (term-handle-ansi-terminal-messages ...)) (t nil)))) ((memql val '(nil 15 14 0)) nil) (t (let ((x0 val)) (error "No clause matching `%S'" x0))))) (if (eq term-do-line-wrapping (point)) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-undecoded-bytes (substring str i)) (if (= 0 i) (setq term-terminal-undecoded-bytes (concat "\15" (substring str i))) (setq term-terminal-undecoded-bytes (substring str (1- i))) (aset term-terminal-undecoded-bytes 0 13)) (goto-char (point-max))) (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 ctl-end)))
  (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let ((ctl-params (and funny (match-string 1 str))) (ctl-params-end (and funny (match-end 1))) (ctl-end (if funny (match-end 0) (setq funny (string-match term-control-seq-prefix-regexp str i)) (if funny (setq term-terminal-undecoded-bytes (substring str funny)) (setq funny str-length)) (1+ str-length)))) (if (> funny i) (progn (if term-do-line-wrapping (progn (term-down 1 t) (term-move-to-column 0) (setq term-do-line-wrapping nil))) (setq decoded-substring (decode-coding-string (substring str i funny) 'raw-text t)) (if (= funny str-length) (progn (let (... ...) (while ... ...) (if ... ...)))) (let ((old-column (term-horizontal-column)) (old-point (point)) columns) (if term-suppress-hard-newline nil (while (> ... term-width) (insert ...) (delete-region ... ...) (term-down 1 t) (term-move-columns ...) (add-text-properties ... ... ...) (setq decoded-substring ...) (setq old-column 0))) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not (or ... term-insert-mode)) (progn (let ... ... ... ...))) (if term-insert-mode (progn (let ... ... ... ...))) (put-text-property old-point (point) 'font-lock-face term-current-face)) (if (eq (term-current-column) term-width) (progn (term-move-columns -1) (setq term-do-line-wrapping (point)))) (setq term-current-column nil) (setq i funny))) (let* ((val (and (<= ctl-end str-length) (aref str i)))) (cond ((eql val 9) (let ((col ...)) (term-move-to-column (min ... ...)))) ((eql val 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eql val 10) (if (and term-kill-echo-list (term-check-kill-echo-list)) nil (term-down 1 t))) ((eql val 8) (term-move-columns -1)) ((eql val 7) (beep t)) ((eql val 26) (funcall term-command-function (decode-coding-string (substring str ... ...) locale-coding-system t))) ((eql val 27) (let* ((val ...)) (cond (... ...) (... ... ...) (... ...) (... ... ...) (... ...) (... ...) (... ...) (t nil)))) ((memql val '(nil 15 14 0)) nil) (t (let ((x0 val)) (error "No clause matching `%S'" x0))))) (if (eq term-do-line-wrapping (point)) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn (if (> (% (current-column) term-width) 0) (setq term-terminal-undecoded-bytes (substring str i)) (if (= 0 i) (setq term-terminal-undecoded-bytes (concat "\15" ...)) (setq term-terminal-undecoded-bytes (substring str ...)) (aset term-terminal-undecoded-bytes 0 13)) (goto-char (point-max))) (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 ctl-end))))
  (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))) (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let ((ctl-params (and funny (match-string 1 str))) (ctl-params-end (and funny (match-end 1))) (ctl-end (if funny (match-end 0) (setq funny (string-match term-control-seq-prefix-regexp str i)) (if funny (setq term-terminal-undecoded-bytes ...) (setq funny str-length)) (1+ str-length)))) (if (> funny i) (progn (if term-do-line-wrapping (progn (term-down 1 t) (term-move-to-column 0) (setq term-do-line-wrapping nil))) (setq decoded-substring (decode-coding-string (substring str i funny) 'raw-text t)) (if (= funny str-length) (progn (let ... ... ...))) (let ((old-column ...) (old-point ...) columns) (if term-suppress-hard-newline nil (while ... ... ... ... ... ... ... ...)) (insert decoded-substring) (setq term-current-column (current-column) columns (- term-current-column old-column)) (if (not ...) (progn ...)) (if term-insert-mode (progn ...)) (put-text-property old-point (point) 'font-lock-face term-current-face)) (if (eq (term-current-column) term-width) (progn (term-move-columns -1) (setq term-do-line-wrapping ...))) (setq term-current-column nil) (setq i funny))) (let* ((val (and (<= ctl-end str-length) (aref str i)))) (cond ((eql val 9) (let (...) (term-move-to-column ...))) ((eql val 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eql val 10) (if (and term-kill-echo-list ...) nil (term-down 1 t))) ((eql val 8) (term-move-columns -1)) ((eql val 7) (beep t)) ((eql val 26) (funcall term-command-function (decode-coding-string ... locale-coding-system t))) ((eql val 27) (let* (...) (cond ... ... ... ... ... ... ... ...))) ((memql val '...) nil) (t (let (...) (error "No clause matching `%S'" x0))))) (if (eq term-do-line-wrapping (point)) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn (if (> (% ... term-width) 0) (setq term-terminal-undecoded-bytes (substring str i)) (if (= 0 i) (setq term-terminal-undecoded-bytes ...) (setq term-terminal-undecoded-bytes ...) (aset term-terminal-undecoded-bytes 0 13)) (goto-char (point-max))) (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 ctl-end)))))
  (progn (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))) (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let ((ctl-params (and funny (match-string 1 str))) (ctl-params-end (and funny (match-end 1))) (ctl-end (if funny (match-end 0) (setq funny ...) (if funny ... ...) (1+ str-length)))) (if (> funny i) (progn (if term-do-line-wrapping (progn ... ... ...)) (setq decoded-substring (decode-coding-string ... ... t)) (if (= funny str-length) (progn ...)) (let (... ... columns) (if term-suppress-hard-newline nil ...) (insert decoded-substring) (setq term-current-column ... columns ...) (if ... ...) (if term-insert-mode ...) (put-text-property old-point ... ... term-current-face)) (if (eq ... term-width) (progn ... ...)) (setq term-current-column nil) (setq i funny))) (let* ((val (and ... ...))) (cond ((eql val 9) (let ... ...)) ((eql val 13) (funcall term-vertical-motion 0) (setq term-current-column term-start-line-column)) ((eql val 10) (if ... nil ...)) ((eql val 8) (term-move-columns -1)) ((eql val 7) (beep t)) ((eql val 26) (funcall term-command-function ...)) ((eql val 27) (let* ... ...)) ((memql val ...) nil) (t (let ... ...)))) (if (eq term-do-line-wrapping (point)) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn (if (> ... 0) (setq term-terminal-undecoded-bytes ...) (if ... ... ... ...) (goto-char ...)) (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 ctl-end))))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn (term-watch-for-password-prompt decoded-substring))) (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 ... ... ... ... ...) (progn ... ... ... ...)) (if (and term-scroll-show-maximum-output ...) (progn ...))))) (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 (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))) (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let ((ctl-params (and funny ...)) (ctl-params-end (and funny ...)) (ctl-end (if funny ... ... ... ...))) (if (> funny i) (progn (if term-do-line-wrapping ...) (setq decoded-substring ...) (if ... ...) (let ... ... ... ... ... ... ...) (if ... ...) (setq term-current-column nil) (setq i funny))) (let* ((val ...)) (cond (... ...) (... ... ...) (... ...) (... ...) (... ...) (... ...) (... ...) (... nil) (t ...))) (if (eq term-do-line-wrapping (point)) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn (if ... ... ... ...) (make-local-variable ...) (setq term-pager-old-filter ...) (set-process-filter proc term-pager-filter) (setq i str-length)) (setq i ctl-end))))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn (term-watch-for-password-prompt decoded-substring))) (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 (...) (select-window win) (if ... ...) (if ... ...)))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark (get-buffer-process ...))) (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 (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 ... 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))) (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let ((ctl-params ...) (ctl-params-end ...) (ctl-end ...)) (if (> funny i) (progn ... ... ... ... ... ... ...)) (let* (...) (cond ... ... ... ... ... ... ... ... ...)) (if (eq term-do-line-wrapping ...) nil (setq term-do-line-wrapping nil)) (if term-pager-old-local-map (progn ... ... ... ... ...) (setq i ctl-end))))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn (term-watch-for-password-prompt decoded-substring))) (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 ... ... ... ...))) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char (process-mark ...)) (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 (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 (> ... ...) (not ...)) (progn (narrow-to-region ... ...))) (if term-log-buffer (progn (princ str term-log-buffer))) (if term-terminal-undecoded-bytes (progn (setq str ...) (setq str-length ...) (setq term-terminal-undecoded-bytes nil))) (while (< i str-length) (setq funny (string-match term-control-seq-regexp str i)) (let (... ... ...) (if ... ...) (let* ... ...) (if ... nil ...) (if term-pager-old-local-map ... ...)))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn (term-watch-for-password-prompt decoded-substring))) (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 ... ...) (progn ...)) (not (eq win last-win)))) (if (> term-buffer-maximum-size 0) (progn (save-excursion (goto-char ...) (forward-line ...) (beginning-of-line) (delete-region ... ...)))) (set-marker save-marker nil)) (internal--after-save-selected-window save-selected-window--state))))
  (let* ((i 0) funny decoded-substring save-point save-marker win (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win (str-length (length str))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (if (marker-buffer term-pending-delete-marker) (progn (delete-region term-pending-delete-marker ...) (set-marker term-pending-delete-marker nil))) (if (/= (point) (process-mark proc)) (progn (setq save-point ...))) (setq term-vertical-motion (if (eq ... ...) 'vertical-motion 'term-buffer-vertical-motion)) (setq save-marker (copy-marker (process-mark proc))) (goto-char (process-mark proc)) (save-restriction (if (and ... ...) (progn ...)) (if term-log-buffer (progn ...)) (if term-terminal-undecoded-bytes (progn ... ... ...)) (while (< i str-length) (setq funny ...) (let ... ... ... ... ...))) (if (>= (term-current-row) term-height) (progn (term-handle-deferred-scroll))) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn (term-watch-for-password-prompt decoded-substring))) (if save-point (progn (goto-char save-point) (set-marker save-point nil))) (if (and term-pending-frame (eq ... ...)) (progn (term-display-line ... ...) (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 ...) (if ... ...) (not ...))) (if (> term-buffer-maximum-size 0) (progn (save-excursion ... ... ... ...))) (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) funny decoded-substring save-point save-marker win (inhibit-read-only t) (buffer-undo-list t) (selected (selected-window)) last-win (str-length (length str))) (let ((save-selected-window--state (internal--before-save-selected-window))) (save-current-buffer (unwind-protect (progn (if (marker-buffer term-pending-delete-marker) (progn ... ...)) (if (/= ... ...) (progn ...)) (setq term-vertical-motion (if ... ... ...)) (setq save-marker (copy-marker ...)) (goto-char (process-mark proc)) (save-restriction (if ... ...) (if term-log-buffer ...) (if term-terminal-undecoded-bytes ...) (while ... ... ...)) (if (>= ... term-height) (progn ...)) (set-marker (process-mark proc) (point)) (if (stringp decoded-substring) (progn ...)) (if save-point (progn ... ...)) (if (and term-pending-frame ...) (progn ... ...)) (setq win selected) (while (window-minibuffer-p win) (setq win ...)) (setq last-win win) (while (progn ... ... ...)) (if (> term-buffer-maximum-size 0) (progn ...)) (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> "l\0$\334\236\217\2\214#\2\342n\4\4\f\204\4l\344\fc|\216\203\3\344\23\333r\223B\204\fc\204\373oN\276\0lNn\234\343\354\fc\34p...")
```