X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/d91f490d2b745c44ed3be3d6ad297996fc48eaa7..1a4086d274b53fe340ffc9843e93b393bdab3099:/lisp/comint.el diff --git a/lisp/comint.el b/lisp/comint.el index b0135faf98..3cb4231d04 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -486,10 +486,10 @@ Entry to this mode runs the hooks on `comint-mode-hook'." (defun comint-check-proc (buffer) "Return t if there is a living process associated w/buffer BUFFER. -Living means the status is `run' or `stop'. +Living means the status is `open', `run', or `stop'. BUFFER can be either a buffer or the name of one." (let ((proc (get-buffer-process buffer))) - (and proc (memq (process-status proc) '(run stop))))) + (and proc (memq (process-status proc) '(open run stop))))) ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it () ;;; for the second argument (program). @@ -497,9 +497,13 @@ BUFFER can be either a buffer or the name of one." (defun make-comint (name program &optional startfile &rest switches) "Make a comint process NAME in a buffer, running PROGRAM. The name of the buffer is made by surrounding NAME with `*'s. -If there is already a running process in that buffer, it is not restarted. -Optional third arg STARTFILE is the name of a file to send the contents of to -the process. Any more args are arguments to PROGRAM." +PROGRAM should be either a string denoting an executable program to create +via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP +connection to be opened via `open-network-stream'. If there is already a +running process in that buffer, it is not restarted. Optional third arg +STARTFILE is the name of a file to send the contents of to the process. + +If PROGRAM is a string, any more args are arguments to PROGRAM." (let ((buffer (get-buffer-create (concat "*" name "*")))) ;; If no process, or nuked process, crank up a new one and put buffer in ;; comint mode. Otherwise, leave buffer and existing process alone. @@ -532,7 +536,10 @@ buffer. The hook `comint-exec-hook' is run after each exec." (let ((proc (get-buffer-process buffer))) ; Blast any old process. (if proc (delete-process proc))) ;; Crank up a new process - (let ((proc (comint-exec-1 name buffer command switches))) + (let ((proc + (if (consp command) + (open-network-stream name buffer (car command) (cdr command)) + (comint-exec-1 name buffer command switches)))) (set-process-filter proc 'comint-output-filter) (make-local-variable 'comint-ptyp) (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. @@ -1043,7 +1050,7 @@ We assume whitespace separates arguments, except within quotes. Also, a run of one or more of a single character in `comint-delimiter-argument-list' is a separate argument. Argument 0 is the command name." - (let ((argpart "[^ \"'`]+\\|\\(\"[^\"]*\"\\|'[^']*'\\|`[^`]*`\\)") + (let ((argpart "[^ \n\t\"'`]+\\|\\(\"[^\"]*\"\\|'[^']*'\\|`[^`]*`\\)") (args ()) (pos 0) (count 0) beg str value quotes) @@ -1279,6 +1286,20 @@ This function should be in the list `comint-output-filter-functions'." nil t)) (set-buffer current)))) +(defun comint-strip-ctrl-m (&optional string) + "Strip trailing `^M' characters from the current output group. + +This function could be in the list `comint-output-filter-functions' or bound to +a key." + (interactive) + (let ((pmark (process-mark (get-buffer-process (current-buffer))))) + (save-excursion + (goto-char + (if (interactive-p) comint-last-input-end comint-last-output-start)) + (while (re-search-forward "\r+$" pmark t) + (replace-match "" t t))))) +(defalias 'shell-strip-ctrl-m 'comint-strip-ctrl-m) + (defun comint-show-maximum-output () "Put the end of the buffer at the bottom of the window." (interactive) @@ -1416,31 +1437,8 @@ This function could be in the list `comint-output-filter-functions'." ;;; Low-level process communication -(defvar comint-input-chunk-size 512 - "*Long inputs are sent to comint processes in chunks of this size. -If your process is choking on big inputs, try lowering the value.") - -(defun comint-send-string (proc str) - "Send PROCESS the contents of STRING as input. -This is equivalent to `process-send-string', except that long input strings -are broken up into chunks of size `comint-input-chunk-size'. Processes -are given a chance to output between chunks. This can help prevent processes -from hanging when you send them long inputs on some OS's." - (let* ((len (length str)) - (i (min len comint-input-chunk-size))) - (process-send-string proc (substring str 0 i)) - (while (< i len) - (let ((next-i (+ i comint-input-chunk-size))) - (accept-process-output) - (sit-for 0) - (process-send-string proc (substring str i (min len next-i))) - (setq i next-i))))) - -(defun comint-send-region (proc start end) - "Sends to PROC the region delimited by START and END. -This is a replacement for `process-send-region' that tries to keep -your process from hanging on long inputs. See `comint-send-string'." - (comint-send-string proc (buffer-substring start end))) +(defalias 'comint-send-string 'process-send-string) +(defalias 'comint-send-region 'process-send-region) ;;; Random input hackage