diff options
| author | Callum Cameron | 2014-04-09 11:12:25 +0100 |
|---|---|---|
| committer | Noam Postavsky | 2018-01-18 22:17:07 -0500 |
| commit | 5472568a3c2338856d25380012ee4398e024c806 (patch) | |
| tree | d0f6efce7d489d9035449d71a31121f96b1bda08 | |
| parent | 297dc41e2c6e84efac092e2d6f69824cb3b6d98d (diff) | |
| download | emacs-5472568a3c2338856d25380012ee4398e024c806.tar.gz emacs-5472568a3c2338856d25380012ee4398e024c806.zip | |
Handle split AnSiT messages for term.el (Bug#17231)
Check to see if there is an incomplete command at the end of
term-emulate-terminal's input string, and, if so, save it so the whole
command can be processed when the next string arrives.
* lisp/term.el (term-partial-ansi-terminal-message): New variable.
(term-mode): Make it buffer local.
(term-handle-ansi-terminal-messages): Prepend it to the received
message, and set it if a partial message was received.
Copyright-paperwork-exempt: yes
Do not merge to master, it will be solved differently there, see
"Switch term.el to lexical binding, and clean up code a bit".
| -rw-r--r-- | lisp/term.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/term.el b/lisp/term.el index ca83b4f8dcf..e51b7669e14 100644 --- a/lisp/term.el +++ b/lisp/term.el | |||
| @@ -593,6 +593,9 @@ massage the input string, this is your hook. This is called from | |||
| 593 | the user command `term-send-input'. `term-simple-send' just sends | 593 | the user command `term-send-input'. `term-simple-send' just sends |
| 594 | the string plus a newline.") | 594 | the string plus a newline.") |
| 595 | 595 | ||
| 596 | (defvar term-partial-ansi-terminal-message nil | ||
| 597 | "Keep partial ansi terminal messages for future processing.") | ||
| 598 | |||
| 596 | (defcustom term-eol-on-send t | 599 | (defcustom term-eol-on-send t |
| 597 | "Non-nil means go to the end of the line before sending input. | 600 | "Non-nil means go to the end of the line before sending input. |
| 598 | See `term-send-input'." | 601 | See `term-send-input'." |
| @@ -1077,6 +1080,8 @@ Entry to this mode runs the hooks on `term-mode-hook'." | |||
| 1077 | (make-local-variable 'ange-ftp-default-password) | 1080 | (make-local-variable 'ange-ftp-default-password) |
| 1078 | (make-local-variable 'ange-ftp-generate-anonymous-password) | 1081 | (make-local-variable 'ange-ftp-generate-anonymous-password) |
| 1079 | 1082 | ||
| 1083 | (make-local-variable 'term-partial-ansi-terminal-message) | ||
| 1084 | |||
| 1080 | ;; You may want to have different scroll-back sizes -mm | 1085 | ;; You may want to have different scroll-back sizes -mm |
| 1081 | (make-local-variable 'term-buffer-maximum-size) | 1086 | (make-local-variable 'term-buffer-maximum-size) |
| 1082 | 1087 | ||
| @@ -2702,6 +2707,11 @@ See `term-prompt-regexp'." | |||
| 2702 | ;;difference ;-) -mm | 2707 | ;;difference ;-) -mm |
| 2703 | 2708 | ||
| 2704 | (defun term-handle-ansi-terminal-messages (message) | 2709 | (defun term-handle-ansi-terminal-messages (message) |
| 2710 | ;; Handle stored partial message | ||
| 2711 | (when term-partial-ansi-terminal-message | ||
| 2712 | (setq message (concat term-partial-ansi-terminal-message message)) | ||
| 2713 | (setq term-partial-ansi-terminal-message nil)) | ||
| 2714 | |||
| 2705 | ;; Is there a command here? | 2715 | ;; Is there a command here? |
| 2706 | (while (string-match "\eAnSiT.+\n" message) | 2716 | (while (string-match "\eAnSiT.+\n" message) |
| 2707 | ;; Extract the command code and the argument. | 2717 | ;; Extract the command code and the argument. |
| @@ -2754,6 +2764,11 @@ See `term-prompt-regexp'." | |||
| 2754 | (setq ange-ftp-default-user nil) | 2764 | (setq ange-ftp-default-user nil) |
| 2755 | (setq ange-ftp-default-password nil) | 2765 | (setq ange-ftp-default-password nil) |
| 2756 | (setq ange-ftp-generate-anonymous-password nil))))) | 2766 | (setq ange-ftp-generate-anonymous-password nil))))) |
| 2767 | ;; If there is a partial message at the end of the string, store it | ||
| 2768 | ;; for future use. | ||
| 2769 | (when (string-match "\eAnSiT.+$" message) | ||
| 2770 | (setq term-partial-ansi-terminal-message (match-string 0 message)) | ||
| 2771 | (setq message (replace-match "" t t message))) | ||
| 2757 | message) | 2772 | message) |
| 2758 | 2773 | ||
| 2759 | 2774 | ||