aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-08-12 18:06:50 +0200
committerLars Ingebrigtsen2020-08-12 18:06:50 +0200
commite3a08019933cd1ebfadc32fe9934cc202b25ba47 (patch)
treec5c77b5fb2e6a8d8ef3f83e96c7a35c9a24c12bf /lisp/eshell
parenta5b24a0c44dd603942c8cf531b47a3905927d3f4 (diff)
downloademacs-e3a08019933cd1ebfadc32fe9934cc202b25ba47.tar.gz
emacs-e3a08019933cd1ebfadc32fe9934cc202b25ba47.zip
Revert "Remove compat code from esh-proc.el"
This reverts commit 97c4d941daffba1635bd738fae9c4ff36e5ad0cf. We still have Emacs builds on systems with no multi-tasking.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-proc.el119
1 files changed, 85 insertions, 34 deletions
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index f612e875ffe..d2c17fe1f77 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -294,40 +294,91 @@ See `eshell-needs-pipe'."
294 delete-exited-processes)) 294 delete-exited-processes))
295 (process-environment (eshell-environment-variables)) 295 (process-environment (eshell-environment-variables))
296 proc decoding encoding changed) 296 proc decoding encoding changed)
297 (setq proc 297 (cond
298 (let ((process-connection-type 298 ((fboundp 'start-file-process)
299 (unless (eshell-needs-pipe-p command) 299 (setq proc
300 process-connection-type)) 300 (let ((process-connection-type
301 (command (file-local-name (expand-file-name command)))) 301 (unless (eshell-needs-pipe-p command)
302 (apply #'start-file-process 302 process-connection-type))
303 (file-name-nondirectory command) nil command args))) 303 (command (file-local-name (expand-file-name command))))
304 (eshell-record-process-object proc) 304 (apply #'start-file-process
305 (set-process-buffer proc (current-buffer)) 305 (file-name-nondirectory command) nil command args)))
306 (set-process-filter proc (if (eshell-interactive-output-p) 306 (eshell-record-process-object proc)
307 #'eshell-output-filter 307 (set-process-buffer proc (current-buffer))
308 #'eshell-insertion-filter)) 308 (set-process-filter proc (if (eshell-interactive-output-p)
309 (set-process-sentinel proc #'eshell-sentinel) 309 #'eshell-output-filter
310 (run-hook-with-args 'eshell-exec-hook proc) 310 #'eshell-insertion-filter))
311 (when (fboundp 'process-coding-system) 311 (set-process-sentinel proc #'eshell-sentinel)
312 (let ((coding-systems (process-coding-system proc))) 312 (run-hook-with-args 'eshell-exec-hook proc)
313 (setq decoding (car coding-systems) 313 (when (fboundp 'process-coding-system)
314 encoding (cdr coding-systems))) 314 (let ((coding-systems (process-coding-system proc)))
315 ;; If start-process decided to use some coding system for 315 (setq decoding (car coding-systems)
316 ;; decoding data sent from the process and the coding system 316 encoding (cdr coding-systems)))
317 ;; doesn't specify EOL conversion, we had better convert CRLF 317 ;; If start-process decided to use some coding system for
318 ;; to LF. 318 ;; decoding data sent from the process and the coding system
319 (if (vectorp (coding-system-eol-type decoding)) 319 ;; doesn't specify EOL conversion, we had better convert CRLF
320 (setq decoding (coding-system-change-eol-conversion decoding 'dos) 320 ;; to LF.
321 changed t)) 321 (if (vectorp (coding-system-eol-type decoding))
322 ;; Even if start-process left the coding system for encoding 322 (setq decoding (coding-system-change-eol-conversion decoding 'dos)
323 ;; data sent from the process undecided, we had better use the 323 changed t))
324 ;; same one as what we use for decoding. But, we should 324 ;; Even if start-process left the coding system for encoding
325 ;; suppress EOL conversion. 325 ;; data sent from the process undecided, we had better use the
326 (if (and decoding (not encoding)) 326 ;; same one as what we use for decoding. But, we should
327 (setq encoding (coding-system-change-eol-conversion decoding 'unix) 327 ;; suppress EOL conversion.
328 changed t)) 328 (if (and decoding (not encoding))
329 (if changed 329 (setq encoding (coding-system-change-eol-conversion decoding 'unix)
330 (set-process-coding-system proc decoding encoding))) 330 changed t))
331 (if changed
332 (set-process-coding-system proc decoding encoding))))
333 (t
334 ;; No async subprocesses...
335 (let ((oldbuf (current-buffer))
336 (interact-p (eshell-interactive-output-p))
337 lbeg lend line proc-buf exit-status)
338 (and (not (markerp eshell-last-sync-output-start))
339 (setq eshell-last-sync-output-start (point-marker)))
340 (setq proc-buf
341 (set-buffer (get-buffer-create eshell-scratch-buffer)))
342 (erase-buffer)
343 (set-buffer oldbuf)
344 (run-hook-with-args 'eshell-exec-hook command)
345 (setq exit-status
346 (apply #'call-process-region
347 (append (list eshell-last-sync-output-start (point)
348 command t
349 eshell-scratch-buffer nil)
350 args)))
351 ;; When in a pipeline, record the place where the output of
352 ;; this process will begin.
353 (and (bound-and-true-p eshell-in-pipeline-p)
354 (set-marker eshell-last-sync-output-start (point)))
355 ;; Simulate the effect of the process filter.
356 (when (numberp exit-status)
357 (set-buffer proc-buf)
358 (goto-char (point-min))
359 (setq lbeg (point))
360 (while (eq 0 (forward-line 1))
361 (setq lend (point)
362 line (buffer-substring-no-properties lbeg lend))
363 (set-buffer oldbuf)
364 (if interact-p
365 (eshell-output-filter nil line)
366 (eshell-output-object line))
367 (setq lbeg lend)
368 (set-buffer proc-buf))
369 (set-buffer oldbuf))
370 (require 'esh-mode)
371 (declare-function eshell-update-markers "esh-mode" (pmark))
372 (defvar eshell-last-output-end) ;Defined in esh-mode.el.
373 (eshell-update-markers eshell-last-output-end)
374 ;; Simulate the effect of eshell-sentinel.
375 (eshell-close-handles (if (numberp exit-status) exit-status -1))
376 (eshell-kill-process-function command exit-status)
377 (or (bound-and-true-p eshell-in-pipeline-p)
378 (setq eshell-last-sync-output-start nil))
379 (if (not (numberp exit-status))
380 (error "%s: external command failed: %s" command exit-status))
381 (setq proc t))))
331 proc)) 382 proc))
332 383
333(defun eshell-insertion-filter (proc string) 384(defun eshell-insertion-filter (proc string)