Closed iostapyshyn closed 2 months ago
I don't use Tramp myself and only do one round of tramp-related bug fixes every half a year or so. Could you please try yourself to figure out why this doesn't work?
Meanwhile, please try if this fixes the issue (and doesn't introduce other issues):
diff --git a/lisp/with-editor.el b/lisp/with-editor.el
index d1a5597775..0d9ee1b63b 100644
--- a/lisp/with-editor.el
+++ b/lisp/with-editor.el
@@ -886,28 +886,13 @@ (defun shell-command--shell-command-with-editor-mode
;; intended to be used in buffers in which an interactive shell is
;; running, so it has to be removed here.
(let ((shell-mode-hook (remove 'with-editor-export-editor shell-mode-hook)))
- (cond ((or (not (or with-editor--envvar shell-command-with-editor-mode))
- (not (string-suffix-p "&" command)))
- (funcall fn command output-buffer error-buffer))
- ((and with-editor-shell-command-use-emacsclient
- with-editor-emacsclient-executable
- (not (file-remote-p default-directory)))
- (with-editor (funcall fn command output-buffer error-buffer)))
- (t
- (funcall fn (format "%s=%s %s"
- (or with-editor--envvar "EDITOR")
- (shell-quote-argument with-editor-sleeping-editor)
- command)
- output-buffer error-buffer)
- (ignore-errors
- (let ((process (get-buffer-process
- (or output-buffer
- (get-buffer "*Async Shell Command*")))))
- (set-process-filter
- process (lambda (proc str)
- (comint-output-filter proc str)
- (with-editor-process-filter proc str t)))
- process))))))
+ (if (or (not (or with-editor--envvar shell-command-with-editor-mode))
+ (not (string-suffix-p "&" command)))
+ (funcall fn command output-buffer error-buffer)
+ (let ((with-editor-emacsclient-executable
+ (and with-editor-shell-command-use-emacsclient
+ with-editor-emacsclient-executable)))
+ (with-editor (funcall fn command output-buffer error-buffer))))))
(advice-add 'shell-command :around
#'shell-command--shell-command-with-editor-mode)
The
with-editor-async-shell-command
andwith-editor-shell-command
commands seem to work great with Tramp for remote buffers. However, enablingshell-command-with-editor-mode
and running(async-)shell-command
does not work this well: the running Emacs instance still tries to opens the file printed by the sleeping editor, but on a local machine instead of remotely.For example, with remote
default-directory
M-& sh -c 'eval $EDITOR /tmp/test' RET
withM-&
bound towith-editor-async-shell-command
opens/tmp/test
properly on the remote host.M-& sh -c 'eval $EDITOR /tmp/test' RET
withshell-command-with-editor-mode
openstest
in the local/tmp/
.