Function: shell-command@shell-command-with-editor-mode
shell-command@shell-command-with-editor-mode is a byte-compiled
function defined in with-editor.el.
Signature
(shell-command@shell-command-with-editor-mode FN COMMAND &optional OUTPUT-BUFFER ERROR-BUFFER)
Documentation
Set editor envvar, if shell-command-with-editor-mode(var)/shell-command-with-editor-mode(fun) is enabled.
Also take care of that for with-editor-[async-]shell-command.
Source Code
;; Defined in ~/.emacs.d/elpa/with-editor-20260301.1317/with-editor.el
(define-advice shell-command
(:around (fn command &optional output-buffer error-buffer)
shell-command-with-editor-mode)
"Set editor envvar, if `shell-command-with-editor-mode' is enabled.
Also take care of that for `with-editor-[async-]shell-command'."
;; `shell-mode' and its hook are intended for buffers in which an
;; interactive shell is running, but `shell-command' also turns on
;; that mode, even though it only runs the shell to run a single
;; command. The `with-editor-export-editor' hook function is only
;; 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
;; If `with-editor-async-shell-command' was used, then `with-editor'
;; was used, and `with-editor--envvar'. `with-editor-shell-command'
;; only goes down that path if the command ends with "&". We might
;; still have to use `with-editor' here, for `async-shell-command'
;; or `shell-command', if the mode is enabled.
((and (string-suffix-p "&" command)
(or with-editor--envvar
shell-command-with-editor-mode))
(if with-editor--envvar
(funcall fn command output-buffer error-buffer)
(with-editor (funcall fn command output-buffer error-buffer)))
;; The comint filter was overridden with our filter. Use both.
(and-let* ((process (get-buffer-process
(or output-buffer
(get-buffer "*Async Shell Command*")))))
(prog1 process
(set-process-filter process
(lambda (proc str)
(comint-output-filter proc str)
(with-editor-process-filter proc str t))))))
((funcall fn command output-buffer error-buffer)))))