unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thievol@posteo.net>
To: Jim Porter <jporterbugs@gmail.com>
Cc: Thierry Volpiatto <thievol@posteo.net>,
	christopher@librehacker.com, Eli Zaretskii <eliz@gnu.org>,
	71554@debbugs.gnu.org
Subject: bug#71554: 29.3; eshell-command async buffer behavior
Date: Sat, 15 Jun 2024 05:13:17 +0000	[thread overview]
Message-ID: <87a5jm94b6.fsf@posteo.net> (raw)
In-Reply-To: <e08a0bda-d971-8dfc-d49f-2eee9d2296b0@gmail.com> (Jim Porter's message of "Fri, 14 Jun 2024 15:49:01 -0700")

[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]

Jim Porter <jporterbugs@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



-- 
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  reply	other threads:[~2024-06-15  5:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 13:57 bug#71554: 29.3; eshell-command async buffer behavior Christopher Howard
2024-06-14 18:53 ` Thierry Volpiatto
2024-06-14 18:56   ` Eli Zaretskii
2024-06-14 20:32     ` Thierry Volpiatto
2024-06-14 22:49       ` Jim Porter
2024-06-15  5:13         ` Thierry Volpiatto [this message]
2024-06-20  7:30           ` Thierry Volpiatto
2024-06-24  5:36             ` Jim Porter
2024-06-24  6:23               ` Thierry Volpiatto
2024-06-24 12:33               ` Eli Zaretskii
2024-06-24 14:15 ` Christopher Howard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5jm94b6.fsf@posteo.net \
    --to=thievol@posteo.net \
    --cc=71554@debbugs.gnu.org \
    --cc=christopher@librehacker.com \
    --cc=eliz@gnu.org \
    --cc=jporterbugs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).