aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-08-11 20:57:10 +0200
committerLars Ingebrigtsen2020-08-11 21:04:12 +0200
commit97c4d941daffba1635bd738fae9c4ff36e5ad0cf (patch)
tree479020e994cbceb330709fdb327af3d1ade039d5 /lisp/eshell
parent958fa07879974721e86efe083840c2cb9f86d9d7 (diff)
downloademacs-97c4d941daffba1635bd738fae9c4ff36e5ad0cf.tar.gz
emacs-97c4d941daffba1635bd738fae9c4ff36e5ad0cf.zip
Remove compat code from esh-proc.el
* lisp/eshell/esh-proc.el (eshell-gather-process-output): `start-file-process' is always defined, so remove the code that deals with Emacs versions that doesn't have it.
Diffstat (limited to 'lisp/eshell')
-rw-r--r--lisp/eshell/esh-proc.el119
1 files changed, 34 insertions, 85 deletions
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index d2c17fe1f77..f612e875ffe 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -294,91 +294,40 @@ 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 (cond 297 (setq proc
298 ((fboundp 'start-file-process) 298 (let ((process-connection-type
299 (setq proc 299 (unless (eshell-needs-pipe-p command)
300 (let ((process-connection-type 300 process-connection-type))
301 (unless (eshell-needs-pipe-p command) 301 (command (file-local-name (expand-file-name command))))
302 process-connection-type)) 302 (apply #'start-file-process
303 (command (file-local-name (expand-file-name command)))) 303 (file-name-nondirectory command) nil command args)))
304 (apply #'start-file-process 304 (eshell-record-process-object proc)
305 (file-name-nondirectory command) nil command args))) 305 (set-process-buffer proc (current-buffer))
306 (eshell-record-process-object proc) 306 (set-process-filter proc (if (eshell-interactive-output-p)
307 (set-process-buffer proc (current-buffer)) 307 #'eshell-output-filter
308 (set-process-filter proc (if (eshell-interactive-output-p) 308 #'eshell-insertion-filter))
309 #'eshell-output-filter 309 (set-process-sentinel proc #'eshell-sentinel)
310 #'eshell-insertion-filter)) 310 (run-hook-with-args 'eshell-exec-hook proc)
311 (set-process-sentinel proc #'eshell-sentinel) 311 (when (fboundp 'process-coding-system)
312 (run-hook-with-args 'eshell-exec-hook proc) 312 (let ((coding-systems (process-coding-system proc)))
313 (when (fboundp 'process-coding-system) 313 (setq decoding (car coding-systems)
314 (let ((coding-systems (process-coding-system proc))) 314 encoding (cdr coding-systems)))
315 (setq decoding (car coding-systems) 315 ;; If start-process decided to use some coding system for
316 encoding (cdr coding-systems))) 316 ;; decoding data sent from the process and the coding system
317 ;; If start-process decided to use some coding system for 317 ;; doesn't specify EOL conversion, we had better convert CRLF
318 ;; decoding data sent from the process and the coding system 318 ;; to LF.
319 ;; doesn't specify EOL conversion, we had better convert CRLF 319 (if (vectorp (coding-system-eol-type decoding))
320 ;; to LF. 320 (setq decoding (coding-system-change-eol-conversion decoding 'dos)
321 (if (vectorp (coding-system-eol-type decoding)) 321 changed t))
322 (setq decoding (coding-system-change-eol-conversion decoding 'dos) 322 ;; Even if start-process left the coding system for encoding
323 changed t)) 323 ;; data sent from the process undecided, we had better use the
324 ;; Even if start-process left the coding system for encoding 324 ;; same one as what we use for decoding. But, we should
325 ;; data sent from the process undecided, we had better use the 325 ;; suppress EOL conversion.
326 ;; same one as what we use for decoding. But, we should 326 (if (and decoding (not encoding))
327 ;; suppress EOL conversion. 327 (setq encoding (coding-system-change-eol-conversion decoding 'unix)
328 (if (and decoding (not encoding)) 328 changed t))
329 (setq encoding (coding-system-change-eol-conversion decoding 'unix) 329 (if changed
330 changed t)) 330 (set-process-coding-system proc decoding encoding)))
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))))
382 proc)) 331 proc))
383 332
384(defun eshell-insertion-filter (proc string) 333(defun eshell-insertion-filter (proc string)