diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9385b023392..f0c64a7a90f 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -5247,8 +5247,8 @@ tramp-handle-shell-command ;; Display output. (with-current-buffer output-buffer (setq mode-line-process '(":%s")) - (unless (eq major-mode 'shell-mode) - (shell-mode)) + (unless (eq major-mode 'shell-command-mode) + (shell-command-mode)) (set-process-filter p #'comint-output-filter) (set-process-sentinel p #'shell-command-sentinel) (when error-file diff --git a/lisp/shell.el b/lisp/shell.el index e6b315ee5c0..7fa84a37e83 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -838,6 +838,13 @@ shell-write-history-on-exit (with-current-buffer buf (insert (format "\nProcess %s %s\n" process event)))))) +(define-derived-mode shell-command-mode comint-mode "Shell" + "Major mode for the output of `async-shell-command'." + (setq-local font-lock-defaults '(shell-font-lock-keywords t)) + ;; See comments in `shell-mode'. + (setq-local ansi-color-apply-face-function #'shell-apply-ansi-color) + (setq list-buffers-directory (expand-file-name default-directory))) + ;;;###autoload (defun shell (&optional buffer file-name) "Run an inferior shell, with I/O through BUFFER (which defaults to `*shell*'). diff --git a/lisp/simple.el b/lisp/simple.el index ae8a824cb54..8618427f5c0 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -31,7 +31,7 @@ (eval-when-compile (require 'cl-lib)) (declare-function widget-convert "wid-edit" (type &rest args)) -(declare-function shell-mode "shell" ()) +(declare-function shell-command-mode "shell" ()) ;;; From compile.el (defvar compilation-current-error) @@ -4721,7 +4721,7 @@ shell-command (setq proc (start-process-shell-command "Shell" buffer command))) (setq mode-line-process '(":%s")) - (shell-mode) + (shell-command-mode) (setq-local revert-buffer-function (lambda (&rest _) (async-shell-command command buffer)))