GNU bug report logs -
#71554
29.3; eshell-command async buffer behavior
Previous Next
Full log
Message #23 received at 71554 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thierry Volpiatto <thievol <at> posteo.net> writes:
> Jim Porter <jporterbugs <at> gmail.com> writes:
>
>> On 6/14/2024 1:32 PM, Thierry Volpiatto wrote:
>>> Because IMO what shell-command is doing is annoying, no need to duplicate
>>> this annoyance, after all when running such a command in a terminal
>>> already running a detached process, nothing is asked, so why doing this
>>> in emacs?
>>> Or at least make it optional?
>>
>> 'shell-command' has several possible options for this behavior. See
>> 'async-shell-command-buffer'.
>
> Ah, didn't know this one, thanks.
> What about something like this reusing async-shell-command-buffer (not
> fully tested)?
>
> diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
> index 18e05a371a4..774f25d71b0 100644
> --- a/lisp/eshell/eshell.el
> +++ b/lisp/eshell/eshell.el
> @@ -302,13 +302,25 @@ argument), then insert output into the current buffer at point."
> ,(eshell-parse-command command))
> command))
> intr
> + unique
> (bufname (if (eq (car-safe proc) :eshell-background)
> "*Eshell Async Command Output*"
> (setq intr t)
> "*Eshell Command Output*")))
> - (if (buffer-live-p (get-buffer bufname))
> - (kill-buffer bufname))
> - (rename-buffer bufname)
> + (when (buffer-live-p (get-buffer bufname))
> + (pcase async-shell-command-buffer
> + ('confirm-kill-process
> + (shell-command--same-buffer-confirm "Kill it")
> + (kill-buffer bufname))
> + ('confirm-new-buffer
> + (shell-command--same-buffer-confirm "Use a new buffer")
> + (setq unique t))
> + ('new-buffer (setq unique t))
> + ('confirm-rename-buffer
> + (shell-command--same-buffer-confirm "Rename it")
> + (kill-buffer bufname))
> + ('rename-buffer (kill-buffer bufname))))
> + (rename-buffer bufname unique)
> ;; things get a little coarse here, since the desire is to
> ;; make the output as attractive as possible, with no
> ;; extraneous newlines
This patch doesn't work if user kill for some reason the initial process
buffer, we have to check if other buffers are alive. Also having a new
variable eshell-command-async-buffer instead of reusing
async-shell-command-buffer is better IMO.
Here a patch that fix these issues.
--
Thierry
[0001-Use-async-shell-command-buffer-in-eshell-command-fix.patch (text/x-diff, attachment)]
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 319 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.