Don't intercept background processes in Eshell
* eat.el (eat--eshell-adjust-make-process-args): Don't do any change to the environment if 'eshell-current-subjob-p' is non-nil.
This commit is contained in:
parent
6756e72d88
commit
f76c27cd93
1 changed files with 49 additions and 45 deletions
94
eat.el
94
eat.el
|
@ -5474,6 +5474,8 @@ PROGRAM can be a shell command."
|
||||||
(eat--eshell-cleanup))))
|
(eat--eshell-cleanup))))
|
||||||
(eshell-sentinel process message))
|
(eshell-sentinel process message))
|
||||||
|
|
||||||
|
(defvar eshell-current-subjob-p) ; In `esh-proc'.
|
||||||
|
|
||||||
;; HACK: This is a dirty hack, it can break easily.
|
;; HACK: This is a dirty hack, it can break easily.
|
||||||
(defun eat--eshell-adjust-make-process-args (fn command args)
|
(defun eat--eshell-adjust-make-process-args (fn command args)
|
||||||
"Setup an environment to adjust `make-process' arguments.
|
"Setup an environment to adjust `make-process' arguments.
|
||||||
|
@ -5481,53 +5483,55 @@ PROGRAM can be a shell command."
|
||||||
Call FN with COMMAND and ARGS, and whenever `make-process' is called,
|
Call FN with COMMAND and ARGS, and whenever `make-process' is called,
|
||||||
modify its argument to change the filter, the sentinel and invoke
|
modify its argument to change the filter, the sentinel and invoke
|
||||||
`stty' from the new process."
|
`stty' from the new process."
|
||||||
(cl-letf*
|
(if eshell-current-subjob-p
|
||||||
(;; For Emacs 29 and above.
|
(funcall fn command args)
|
||||||
(make-process (symbol-function #'make-process))
|
(cl-letf*
|
||||||
((symbol-function #'make-process)
|
(;; For Emacs 29 and above.
|
||||||
(if (< emacs-major-version 29)
|
(make-process (symbol-function #'make-process))
|
||||||
make-process
|
((symbol-function #'make-process)
|
||||||
(lambda (&rest plist)
|
(if (< emacs-major-version 29)
|
||||||
;; Make sure we don't attack wrong process.
|
make-process
|
||||||
(if (not (equal (plist-get plist :command)
|
(lambda (&rest plist)
|
||||||
(cons (file-local-name
|
;; Make sure we don't attack wrong process.
|
||||||
(expand-file-name command))
|
(if (not (equal (plist-get plist :command)
|
||||||
args)))
|
(cons (file-local-name
|
||||||
(apply make-process plist)
|
(expand-file-name command))
|
||||||
(setf (plist-get plist :command)
|
args)))
|
||||||
`("/usr/bin/env" "sh" "-c"
|
(apply make-process plist)
|
||||||
,(format "stty -nl echo rows %d columns %d \
|
(setf (plist-get plist :command)
|
||||||
|
`("/usr/bin/env" "sh" "-c"
|
||||||
|
,(format "stty -nl echo rows %d columns %d \
|
||||||
sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
||||||
(floor (window-screen-lines))
|
(floor (window-screen-lines))
|
||||||
(window-max-chars-per-line)
|
(window-max-chars-per-line)
|
||||||
null-device)
|
null-device)
|
||||||
".." ,@(plist-get plist :command)))
|
".." ,@(plist-get plist :command)))
|
||||||
(apply make-process plist)))))
|
(apply make-process plist)))))
|
||||||
;; For Emacs 28.
|
;; For Emacs 28.
|
||||||
(start-file-process (symbol-function #'start-file-process))
|
(start-file-process (symbol-function #'start-file-process))
|
||||||
((symbol-function #'start-file-process)
|
((symbol-function #'start-file-process)
|
||||||
(if (< emacs-major-version 29)
|
(if (< emacs-major-version 29)
|
||||||
(lambda (name buffer &rest command)
|
(lambda (name buffer &rest command)
|
||||||
(apply start-file-process name buffer
|
(apply start-file-process name buffer
|
||||||
`("/usr/bin/env" "sh" "-c"
|
`("/usr/bin/env" "sh" "-c"
|
||||||
,(format "stty -nl echo rows %d columns %d \
|
,(format "stty -nl echo rows %d columns %d \
|
||||||
sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
||||||
(floor (window-screen-lines))
|
(floor (window-screen-lines))
|
||||||
(window-max-chars-per-line)
|
(window-max-chars-per-line)
|
||||||
null-device)
|
null-device)
|
||||||
".." ,@command)))
|
".." ,@command)))
|
||||||
;; Don't override on Emacs 28.
|
;; Don't override on Emacs 28.
|
||||||
start-file-process)))
|
start-file-process)))
|
||||||
(let ((hook
|
(let ((hook
|
||||||
(lambda (proc)
|
(lambda (proc)
|
||||||
(set-process-filter proc #'eat--eshell-filter)
|
(set-process-filter proc #'eat--eshell-filter)
|
||||||
(set-process-sentinel proc #'eat--eshell-sentinel)
|
(set-process-sentinel proc #'eat--eshell-sentinel)
|
||||||
(eat--eshell-setup-proc-and-term proc))))
|
(eat--eshell-setup-proc-and-term proc))))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(add-hook 'eshell-exec-hook hook 99)
|
(add-hook 'eshell-exec-hook hook 99)
|
||||||
(funcall fn command args))
|
(funcall fn command args))
|
||||||
(remove-hook 'eshell-exec-hook hook)))))
|
(remove-hook 'eshell-exec-hook hook))))))
|
||||||
|
|
||||||
|
|
||||||
;;;;; Minor Modes.
|
;;;;; Minor Modes.
|
||||||
|
|
Loading…
Add table
Reference in a new issue