emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 5472568 1/2: Handle split AnSiT messages for term


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 5472568 1/2: Handle split AnSiT messages for term.el (Bug#17231)
Date: Thu, 18 Jan 2018 22:27:50 -0500 (EST)

branch: emacs-26
commit 5472568a3c2338856d25380012ee4398e024c806
Author: Callum Cameron <address@hidden>
Commit: Noam Postavsky <address@hidden>

    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".
---
 lisp/term.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lisp/term.el b/lisp/term.el
index ca83b4f..e51b766 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)
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]