[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-hgcmd 15c2c27 23/87: Communication with tty process
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vc-hgcmd 15c2c27 23/87: Communication with tty process |
Date: |
Sat, 5 Jun 2021 16:11:39 -0400 (EDT) |
branch: externals/vc-hgcmd
commit 15c2c27dd25f5219de6dfb7abc5d412486861684
Author: muffinmad <andreyk.mad@gmail.com>
Commit: muffinmad <andreyk.mad@gmail.com>
Communication with tty process
For remote files process communication type is tty instead of pipe.
In this case prepend each character in binary data with ^V (literal next).
Also send "\n" after data so tty process can read it.
---
vc-hgcmd.el | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/vc-hgcmd.el b/vc-hgcmd.el
index 19a1cae..7175fc8 100644
--- a/vc-hgcmd.el
+++ b/vc-hgcmd.el
@@ -250,6 +250,8 @@ Insert output to process buffer and check if amount of data
is enought to parse
;; TODO parse encoding
(while (not (vc-hgcmd--read-output))
(accept-process-output process 0.1 nil t))
+ ;; send \n after command data so tty process can read data
+ (process-send-string process "runcommand\n")
(set-process-filter process #'vc-hgcmd--cmdserver-process-filter)
process)))))
@@ -308,20 +310,26 @@ Insert 'Running command' and display buffer text if
COMMAND"
(when window (set-window-start window window-start))))
buffer))
-(defun vc-hgcmd--prepare-command-to-send (command)
- "Prepare COMMAND to send to hg process."
- (let ((args (mapconcat #'identity command "\0")))
- (concat (bindat-pack '((l u32)) `((l . ,(length args)))) args)))
+(defun vc-hgcmd--prepare-command-to-send (command tty)
+ "Prepare COMMAND to send to hg process. Escape each character in binary data
with ^V if TTY."
+ (let* ((args (mapconcat #'identity command "\0"))
+ (binary-data (bindat-pack '((l u32)) `((l . ,(length args))))))
+ (concat (if tty
+ (mapconcat #'identity (mapcar (lambda (c) (concat "\x16"
(char-to-string c))) binary-data) "")
+ binary-data)
+ args)))
(defun vc-hgcmd--run-command (cmd)
"Run hg CMD."
(let* ((buffer (vc-hgcmd--process-buffer))
- (process (get-buffer-process buffer)))
+ (process (get-buffer-process buffer))
+ (tty (process-tty-name process)))
(with-current-buffer buffer
(while vc-hgcmd--current-command
(accept-process-output process 0.1 nil t))
(setq vc-hgcmd--current-command cmd)
- (process-send-string process (concat "runcommand\n"
(vc-hgcmd--prepare-command-to-send (vc-hgcmd--command-command cmd))))
+ ;; send \n after command data so tty process can read data
+ (process-send-string process (concat (vc-hgcmd--prepare-command-to-send
(vc-hgcmd--command-command cmd) tty) "runcommand\n"))
(when (vc-hgcmd--command-wait cmd)
(while vc-hgcmd--current-command
(accept-process-output process 0.1 nil t))))))
- [elpa] externals/vc-hgcmd c62c14e 33/87: Use process-send-eof for pty processes, (continued)
- [elpa] externals/vc-hgcmd c62c14e 33/87: Use process-send-eof for pty processes, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 5416977 36/87: command callback must be called in output buffer, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 088aaa4 37/87: lazy completion table on branch merge, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3e5782c 39/87: Handle unexpected output; Handle non-latin branch/file names, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 261ef39 21/87: version 1.3.1, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 39dddda 22/87: Use relative filename on check status, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd d9bc82c 09/87: fixed typo, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd c05d560 16/87: melpa-stable badge, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3b2d060 17/87: Show command output on command error, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 876f7cb 20/87: Handle nil on reading parents, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 15c2c27 23/87: Communication with tty process,
Stefan Monnier <=
- [elpa] externals/vc-hgcmd 0bd38be 24/87: User parent info from summary in there are no log, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd e6f1105 25/87: Use relative file names for all commands, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f093b75 34/87: Message if hg command is running when running another, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f92c39b 40/87: Fixed regexp, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 323b4ab 41/87: Option to skip data on error channel, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd d439b43 42/87: Running command indicator in output buffer mode line, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3f8c60b 45/87: Create output buffer before actually running command, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 6379ef2 50/87: process-environment order, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f87a21d 54/87: next/previous revison respects files, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd adb7cb5 11/87: directories are always registered, Stefan Monnier, 2021/06/05