Fix invoking commands with eshell/sudo from Tramp
* eat.el (eat--eshell-adjust-make-process-args): Override 'start-file-process' on Emacs 28, used by Eshell on Emacs 28. Don't override 'make-process' on Emacs 28, Eshell doesn't use that on Emacs 28. Set process filter and sentinel in 'eshell-exec-hook' instead of 'make-process' advice.
This commit is contained in:
parent
714d9738cc
commit
f54af22d6a
1 changed files with 36 additions and 31 deletions
67
eat.el
67
eat.el
|
@ -5470,41 +5470,46 @@ 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*
|
(cl-letf*
|
||||||
((make-process (symbol-function #'make-process))
|
(;; For Emacs 29 and above.
|
||||||
|
(make-process (symbol-function #'make-process))
|
||||||
((symbol-function #'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 (and (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
|
||||||
;; Eshell on Emacs 28 uses
|
(expand-file-name command))
|
||||||
;; `start-file-process', so `:filter' and
|
args)))
|
||||||
;; `:sentinel' are nil now.
|
(apply make-process plist)
|
||||||
(or (< emacs-major-version 29)
|
(setf (plist-get plist :command)
|
||||||
(and (eq (plist-get plist :filter)
|
`("/usr/bin/env" "sh" "-c"
|
||||||
#'eshell-output-filter)
|
,(format "stty -nl echo rows %d columns %d \
|
||||||
(eq (plist-get plist :sentinel)
|
|
||||||
#'eshell-sentinel)))))
|
|
||||||
(apply make-process plist)
|
|
||||||
(unless (< emacs-major-version 29)
|
|
||||||
(setf (plist-get plist :filter) #'eat--eshell-filter)
|
|
||||||
(setf (plist-get plist :sentinel)
|
|
||||||
#'eat--eshell-sentinel))
|
|
||||||
(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) null-device)
|
(window-max-chars-per-line)
|
||||||
".."
|
null-device)
|
||||||
,@(plist-get plist :command)))
|
".." ,@(plist-get plist :command)))
|
||||||
(apply make-process plist)))))
|
(apply make-process plist)))))
|
||||||
|
;; For Emacs 28.
|
||||||
|
(start-file-process (symbol-function #'start-file-process))
|
||||||
|
((symbol-function #'start-file-process)
|
||||||
|
(if (< emacs-major-version 29)
|
||||||
|
(lambda (name buffer &rest command)
|
||||||
|
(apply start-file-process name buffer
|
||||||
|
`("/usr/bin/env" "sh" "-c"
|
||||||
|
,(format "stty -nl echo rows %d columns %d \
|
||||||
|
sane 2>%s ; if [ $1 = .. ]; then shift; fi; exec \"$@\""
|
||||||
|
(floor (window-screen-lines))
|
||||||
|
(window-max-chars-per-line)
|
||||||
|
null-device)
|
||||||
|
".." ,@command)))
|
||||||
|
;; Don't override on Emacs 28.
|
||||||
|
start-file-process)))
|
||||||
(let ((hook
|
(let ((hook
|
||||||
(lambda (proc)
|
(lambda (proc)
|
||||||
(when (< emacs-major-version 29)
|
(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
|
||||||
|
|
Loading…
Add table
Reference in a new issue