diff options
author | Callum Cameron <cjcameron7@gmail.com> | 2014-04-09 11:12:25 +0100 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2018-01-18 22:17:07 -0500 |
commit | 5472568a3c2338856d25380012ee4398e024c806 (patch) | |
tree | d0f6efce7d489d9035449d71a31121f96b1bda08 /lisp/term.el | |
parent | 297dc41e2c6e84efac092e2d6f69824cb3b6d98d (diff) | |
download | emacs-5472568a3c2338856d25380012ee4398e024c806.tar.gz |
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".
Diffstat (limited to 'lisp/term.el')
-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 the user command `term-send-input'. `term-simple-send' just sends the string plus a newline.") +(defvar term-partial-ansi-terminal-message nil + "Keep partial ansi terminal messages for future processing.") + (defcustom term-eol-on-send t "Non-nil means go to the end of the line before sending input. See `term-send-input'." @@ -1077,6 +1080,8 @@ Entry to this mode runs the hooks on `term-mode-hook'." (make-local-variable 'ange-ftp-default-password) (make-local-variable 'ange-ftp-generate-anonymous-password) + (make-local-variable 'term-partial-ansi-terminal-message) + ;; You may want to have different scroll-back sizes -mm (make-local-variable 'term-buffer-maximum-size) @@ -2702,6 +2707,11 @@ See `term-prompt-regexp'." ;;difference ;-) -mm (defun term-handle-ansi-terminal-messages (message) + ;; Handle stored partial message + (when term-partial-ansi-terminal-message + (setq message (concat term-partial-ansi-terminal-message message)) + (setq term-partial-ansi-terminal-message nil)) + ;; Is there a command here? (while (string-match "\eAnSiT.+\n" message) ;; Extract the command code and the argument. @@ -2754,6 +2764,11 @@ See `term-prompt-regexp'." (setq ange-ftp-default-user nil) (setq ange-ftp-default-password nil) (setq ange-ftp-generate-anonymous-password nil))))) + ;; If there is a partial message at the end of the string, store it + ;; for future use. + (when (string-match "\eAnSiT.+$" message) + (setq term-partial-ansi-terminal-message (match-string 0 message)) + (setq message (replace-match "" t t message))) message) |