GNU bug report logs - #81181
[PATCH] Refine the revert-buffer-function of shell-command

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Augusto Stoffel <arstoffel@HIDDEN>; Keywords: patch; dated Thu, 4 Jun 2026 06:09:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 81181 <at> debbugs.gnu.org:


Received: (at 81181) by debbugs.gnu.org; 4 Jun 2026 14:44:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 10:44:39 2026
Received: from localhost ([127.0.0.1]:35891 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV9JE-0004hZ-Iw
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 10:44:37 -0400
Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]:34327)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1wV9JB-0004h4-I6
 for 81181 <at> debbugs.gnu.org; Thu, 04 Jun 2026 10:44:35 -0400
Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45])
 by mailfhigh.stl.internal (Postfix) with ESMTP id AF9D47A0108;
 Thu,  4 Jun 2026 10:44:27 -0400 (EDT)
Received: from phl-frontend-03 ([10.202.2.162])
 by phl-compute-05.internal (MEProxy); Thu, 04 Jun 2026 10:44:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name;
 h=cc:cc:content-type:content-type:date:date:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:subject:subject:to:to; s=fm3; t=1780584267; x=
 1780670667; bh=hAyFM42cev8MhF6N6POlBI6FRmWdl4D40K52C16HFLA=; b=G
 XwGn1w3CQEvxDcSZuiwA9OVRfmnPu843AKzAVcW3X2pSpGMoSnLlmN4bBhIr+5/q
 EyAfjFt4fUuAiu5+vvbcv60WqePnL8pxxMnEZcUxitUUVpAPYpuSfOLzmCJCMmg0
 +PZGiZjT50BU/vYK/DVlmg6BuahH+AUQPxf7qJUCuPtkXDfN/5OiPDgutiuA8sdZ
 NOyOZNpcOXapeEadVeCsYU2tXNQwYutzR2e3swzQoC9+a8uRvaBsEg55fFdmUzRS
 fWRmSruYkp2SdFJaDIEkdREqIZofdhdyOmrvNUBXgfOWpQU/k8OpGGMwN4oFuIl0
 H/YU7LoGd+5g713TzhlgQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-type:content-type:date:date
 :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:subject:subject:to
 :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1780584267; x=1780670667; bh=hAyFM42cev8MhF6N6POlBI6FRmWdl4D40K5
 2C16HFLA=; b=UqJIBsgMfaqhuFnAFajSZ3D3fg6YlYNPcQbvKuwGjh7n+wbNCJv
 K0sJRIDxaxpvuPPbLM3e08yenubRP/sAdev+KpHJUkiWKcuwhdUFSNHpU8LSaJJb
 Uq1UwM8YHbooMyElhephhGIgyofPe5mt/naFAnErxAs+JNTQItP0nvenClt5ddL4
 DA0aGt2hgp6G0GhS0MjyJM1JLDZZ/TM4NmSKeQY5dbBR71Z2cISxKtKAqYbIY82v
 2vjCc3HHNsTJ2JbCZp8azZaircgcdQx134x6zQ7g91w9nXufhs9QlJ7FJz2nY1V/
 /4UlVJ+p/gmmXwbJnVKRtPfw8cyVKkE6v5w==
X-ME-Sender: <xms:S48hagbvh619Jk60-dFos1lrbclKHbwBWx_imn8w_EXfYuMx0SACiw>
 <xme:S48hai0h-kKmPhAFiXiR2UIfHJIOi9II-BLbtaCG87OD3uCHoCPz67ttlZ92k3OxX
 MTlwuWE8whoMSMlHplW-EZ31WWp_5qtnHwwvg7WlBrgpsW4AjEhOw>
X-ME-Received: <xmr:S48haoWWSA5_ZlhKuRQW97F03u4tMwQVdFQhqc09jVom2vgH4TTbhmbK_CWWmAtqQGHqDqTgKWs2>
X-ME-Proxy-Cause: dmFkZTEKTRvXVB/Z/G70kQxKJx1OB3APbKCIWKxQjvTxMdaDRmsBdD+8LSPbvfxfDtIQjy
 yd9fZe6ek3vRSWO8Jlo3B8GbvmBeKgXC6uTaeh6ukI0EFHLbVU0MmOdjPXIyGzr1br2TZl
 SnAy97PMn/BNma7NJfkvBdOstq71LXq+BLsm3/bxvbOhvibE9Xq5weZpgCmoX8gBEJ6iru
 W+6raerZPyVEQw6pes9Z3vHOtn9NA1VVOmabYhqczFjtKefukLgyqY7NH2Ibf1daPbLbUp
 koehGUeckSVPipI47mIv8yyZjlmtXr0nPpaTGmBlvDYD5XoZM23jyJBNYlLoo1x1gQ3vmX
 IEYoTvOKAERtzeVyb4WaGNdbAB9j1tMSreVtmKJG7g/IUyqwiHINDZsP7VgnraGjWoZfNb
 Jc6yycSOvZQKERFOtFKmyDCh5E6NC1WT8LKUaYFBX4YLtDCM+gknPnflkwn7FKDKoF8S6m
 P3gumK6SeOBcT20YD6WjZ2AJAuY/0CkEH5qYj/v13WCJvtj9MTM8ZeUqBTPxh6ucRRdxAh
 7ZUpjHwCtmgCLGfWN8AEfC6AIjSp8JjRuw28wSlhOsWPVngw7LYv1sK0fHuJUKg0AHwvgQ
 v/e2yrL9BrUuNldgAyW8v9N3EnmpU/+aAI8AHmtBhpgd3N2CXZROmC2AFZuw
X-ME-Proxy: <xmx:S48hakUYik1A4aVYqCIF5HQKnaNnoWgZG13m8Edq2kvQoANN7YrGRQ>
 <xmx:S48havfOl7WJ7Iv6xow9Dn9YGq0Z7GKhfqQxReUG8YyxZHmkIliPmw>
 <xmx:S48halWK2r23Pjh4IBWdZcG1cDcUltOoAZvrsbjl7tkgbdQGXKj9BQ>
 <xmx:S48hagdOhNjtnNqtX6vcKUfTcLVDNQfpLyWbELP9Ggh5tubnLG22QA>
 <xmx:S48hamhz-KKzTYPVlLoAI5edyXdD5EiQjmvj-HfvZ820_zl-WQvn9Xnp>
Feedback-ID: i62564b17:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 4 Jun 2026 10:44:26 -0400 (EDT)
Received: by melete.silentflame.com (Postfix, from userid 1000)
 id 286777E6FB4; Thu, 04 Jun 2026 15:44:26 +0100 (BST)
From: Sean Whitton <spwhitton@HIDDEN>
To: Augusto Stoffel <arstoffel@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#81181: [PATCH] Refine the revert-buffer-function of
 shell-command
In-Reply-To: <871pem8puu.fsf@HIDDEN>
References: <87ecim96to.fsf@HIDDEN> <86h5niu7aq.fsf@HIDDEN>
 <874iji8v21.fsf@HIDDEN> <865x3ytu6t.fsf@HIDDEN>
 <871pem8puu.fsf@HIDDEN>
Date: Thu, 04 Jun 2026 15:44:26 +0100
Message-ID: <87zf1anz5h.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 81181
Cc: 81181 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

How about moving the majority of the code out into a defun and then just
adding a small lambda which passes COMMAND to that function?

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.

Message received at 81181 <at> debbugs.gnu.org:


Received: (at 81181) by debbugs.gnu.org; 4 Jun 2026 12:14:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 08:14:24 2026
Received: from localhost ([127.0.0.1]:60898 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV6xr-000740-DA
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 08:14:24 -0400
Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:49524)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <arstoffel@HIDDEN>)
 id 1wV6xp-00073c-11
 for 81181 <at> debbugs.gnu.org; Thu, 04 Jun 2026 08:14:22 -0400
Received: by mail-ej1-x632.google.com with SMTP id
 a640c23a62f3a-bec2ddee9bbso125714466b.3
 for <81181 <at> debbugs.gnu.org>; Thu, 04 Jun 2026 05:14:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1780575259; x=1781180059; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=0/0H3VYbqoOQkgmqWWnuhyg1TxC/WYx/ewfTX5VzItc=;
 b=WJtvFRZTwaGz6XhsLCy1mWsl42Zrxs6xmvF359nuk11uS/iXbavc5KD25Xpvhl7fKa
 CMJIV+sl9/KFywFICkvVlEbxV2NVj050/X6b/eROisPAmTwPVMf6n1Ikp/PIQ4HC5BH+
 khQHiiihrp0wl4YnZRGLtOcc4ET/rmIyeQwL2HC7DtibDKfHNk650LNauVYRaFefSMzW
 sfiR3o3RuTvcslNJIjYCJHp9yEXfZJbrYa7q8eoFg/jdmjwwghdMct9FgFN3d5ZCYagc
 +Lj2x/x2k4Xna0j4H/UkM+IRal+50aKAjvI3cYQkDpskZB+ki/bgCfmtY3F7KNwKLshO
 g4kg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20251104; t=1780575259; x=1781180059;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=0/0H3VYbqoOQkgmqWWnuhyg1TxC/WYx/ewfTX5VzItc=;
 b=cqzg7NRtRwDp8iD2182b44yfJfOZPLv8ZPjco/inAPCxS41tvfgMVRHQJh04lyy5ww
 J98QOr1b8dc7dq3C81/+biRR8xJonitsVBaruZPGUOnxF1wy3qcVcX33U7PONTk0mygy
 OzqLM+vvfR+v4mVk4h/X3s5SgRPrTVkE9krZJvCI4UKrtI0sNIr+uscQ6ZG5MI0PRQnM
 33IWDaAnVSluv4g0JqQTqwbPJiJakPv6OyYG9Jna9W8Ji4hR+yqWBrVCvDYvhmMpsbOO
 +I5ay1r1hMWiS++dEub8VRVOtqWfI6C3kDXeTHAmuHLTyDjSLsFHWDr0CSfty0x/e8X6
 nDuw==
X-Gm-Message-State: AOJu0Yz+DPtoflPzPvPialeHfRda7Sy/aYk1ujfL1sN9kxRr5Jn7pGOK
 VWDEyYNE0tuSGsOOjiHY1p8+WWGa+Ly8MEGKfsuJ8st8tqM7poWZPA0v
X-Gm-Gg: Acq92OHnzK/tv7BTMjDc3i7rfNRYpDfLZgUNo6Jf36pMfKyQYDqLvKJ9ugghUYskNfq
 7s55SLvyv6WbZD+KIqOVkw784CXVZ7cJLCwYICUz8OE41K40S032qclJPyq1S+zND7W2pPpU3/8
 EelhuEi0XxMN8qabRqfzgVk0hQ7C8ecUTJ6Ge5mZ7ed7dNJhGalvjn5qFB1n1ENyhyULD6lXjTk
 96WaByJ84CBANb6Un3LQEDF6UsOH8XCgnemwHFeXxZKNR4kpOUQ/ZqJ23+ezl2+wlYX9ygXwwku
 m6c0JexfB+J9GqAmfs5bG+hrLLPv3XQJ6+abp8qs0DplYh6LGt3eACKQZx0v757t6gG6kHV6CiF
 kVoJtqQeTAkoGjCYIxUZdrDiF1/Xse76O+NgM4iyXjU6yOhIXDg9Vlm50ur0kRVvVwYi8iZeqXY
 fwo1bDkg13epwGxzc5yUAzlOaSB8wL
X-Received: by 2002:a17:907:a0d6:b0:bed:7707:a244 with SMTP id
 a640c23a62f3a-bf0a8e1e3aemr429303066b.13.1780575259142; 
 Thu, 04 Jun 2026 05:14:19 -0700 (PDT)
Received: from ars3 ([2a02:8109:8a95:9a00:a174:43ce:14f5:df5e])
 by smtp.gmail.com with ESMTPSA id
 a640c23a62f3a-bf051e9aa33sm297580366b.24.2026.06.04.05.14.18
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 04 Jun 2026 05:14:18 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#81181: [PATCH] Refine the revert-buffer-function of
 shell-command
In-Reply-To: <865x3ytu6t.fsf@HIDDEN>
References: <87ecim96to.fsf@HIDDEN> <86h5niu7aq.fsf@HIDDEN>
 <874iji8v21.fsf@HIDDEN> <865x3ytu6t.fsf@HIDDEN>
Date: Thu, 04 Jun 2026 14:14:17 +0200
Message-ID: <871pem8puu.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 81181
Cc: 81181 <at> debbugs.gnu.org, spwhitton@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

--=-=-=
Content-Type: text/plain


On Thu,  4 Jun 2026, Eli Zaretskii wrote:

>> From: Augusto Stoffel <arstoffel@HIDDEN>
>> Cc: 81181 <at> debbugs.gnu.org,  spwhitton@HIDDEN
>> Date: Thu, 04 Jun 2026 12:21:58 +0200
>> 
>> 
>> On Thu,  4 Jun 2026, Eli Zaretskii wrote:
>> 
>> > Thanks.  This changes user-facing behavior, so it needs to be called
>> > out in NEWS.
>> 
>> I don't mind, but this is much closer to a bug fix than a new feature.
>> IMO mentioning this would just help making NEWS unnecessarily long.
>
> What is bug for you is new behavior for others, who don't necessarily
> perceive this as a bug.  So I think we do need a NEWS entry, if only
> to be ready for those who'd come up wondering why the command suddenly
> asks them a question.

Here's a new patch:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Refine-the-revert-buffer-function-of-shell-command.patch

From 5317569d478abad398a83f11621e4d119a9d631f Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@HIDDEN>
Date: Thu, 4 Jun 2026 14:04:00 +0200
Subject: [PATCH] Refine the revert-buffer-function of shell-command

Ask to kill the shell command first if it's live.  This is consistent
with how 'compile' behaves.

* lisp/simple.el (shell-command): Do it.
---
 etc/NEWS       |  6 ++++++
 lisp/simple.el | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 2ee0df5650d..62c1df80734 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -49,6 +49,12 @@ behavior.
 If this variable is nil, 'tty-cursor-movement-use-TAB-BS' has no effect,
 and Emacs will never use TABs for any cursor-movement sequences.
 
+---
+** Reverting an 'async-shell-command' buffer restarts the process.
+If the shell command is still running, you will be asked if you wish to
+kill the process first.  This behavior is consistent with the 'compile'
+command.
+
 
 * Editing Changes in Emacs 32.1
 
diff --git a/lisp/simple.el b/lisp/simple.el
index fd9ba28c762..1a24975000a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4780,8 +4780,16 @@ shell-command
 		(setq mode-line-process '(":%s"))
                 (funcall async-shell-command-mode)
                 (setq-local revert-buffer-function
-                            (lambda (&rest _)
-                              (async-shell-command command buffer)))
+                            (lambda (_ noconfirm)
+                              (let ((proc (get-buffer-process buffer)))
+                                (when (or noconfirm
+                                          (not (process-live-p proc))
+                                          (yes-or-no-p "\
+A shell command is running; kill it?"))
+                                  (when proc
+                                    (kill-process proc)
+                                    (while (accept-process-output proc)))
+                                  (async-shell-command command buffer)))))
                 (set-process-sentinel proc #'shell-command-sentinel)
 		;; Use the comint filter for proper handling of
 		;; carriage motion (see comint-inhibit-carriage-motion).
-- 
2.54.0


--=-=-=
Content-Type: text/plain



>> >> @@ -4780,8 +4780,16 @@ shell-command
>> >>  		(setq mode-line-process '(":%s"))
>> >>                  (funcall async-shell-command-mode)
>> >>                  (setq-local revert-buffer-function
>> >> -                            (lambda (&rest _)
>> >> -                              (async-shell-command command buffer)))
>> >> +                            (lambda (_ noconfirm)
>> >> +                              (let ((proc (get-buffer-process buffer)))
>> >> +                                (when (or noconfirm
>> >> +                                          (not (process-live-p proc))
>> >> +                                          (yes-or-no-p "\
>> >> +A shell command is running; kill it?"))
>> >> +                                  (when proc
>> >> +                                    (kill-process proc)
>> >> +                                    (while (accept-process-output proc)))
>> >> +                                  (async-shell-command command buffer)))))
>> >
>> > I think I'd prefer to have a normal named function instead of an
>> > in-line lambda, as the latter has documentation-related difficulties
>> > and shows to the user as a bunch of bytecodes.  (Shouldn't such a
>> > function be defined in shell.el?)
>> 
>> Okay, but that's independent of the refinement I'm suggesting here.
>> Should we leave that for another occasion?  It's not an entirely trivial
>> refactoring since one would have to define a buffer-local var to store
>> COMMAND, which currently lives in the closure.
>
> Sorry, I don't understand: revert-buffer-function is already a
> buffer-local variable.

The change you suggest will require still another buffer-local variable
to store the data currently held by the closure -- more specifically,
the lexical variable `command'.

>> (If you ask me, I actually prefer the lambda.  There only reason Emacs
>> can't take you to the place a lambda is defined is, it hasn't been
>> implemented yet.  This missing ELisp feature is important and would help
>> a lot with debugging in general.)
>
> Try "C-h v revert-buffer-function" in a buffer where you've set that,
> and tell me how you like the results.

I know exactly what you mean, and, as I said, this is not an intrinsic
problem with lambdas.  It's a missing feature in ELisp.  The
byte-compiler _could_ remember the location where the lambda was defined
to make not only "C-h v revert-buffer-function" more helpful, but also
the backtraces and more.

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.

Message received at 81181 <at> debbugs.gnu.org:


Received: (at 81181) by debbugs.gnu.org; 4 Jun 2026 11:35:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 07:35:18 2026
Received: from localhost ([127.0.0.1]:60413 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV6M2-0003uX-61
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 07:35:18 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:39252)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wV6Lz-0003rI-6q
 for 81181 <at> debbugs.gnu.org; Thu, 04 Jun 2026 07:35:16 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1wV6Lt-0007nB-FS; Thu, 04 Jun 2026 07:35:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=QhQn0xq/JU7Sc15UrN9hOtJuwUh7qDsDaLgSOSA+7ZA=; b=B9PwtFvy64TT
 y4bViNMx1h23H8ZRgVRqC0oYcO6t6gsbq34wIGWt2LHYjv00LmmZP7hVXNcCCv0DXB73X1UkkHSD2
 Ff4TDQ5eAQipFXhVVZnbevPOmJT5ei9JunS27fQ2aNPHrUx1h1VogGSyjXrnOGTyjZDDQbyOPDlJ5
 wA76VgxQKAfzhQjp2BsYSNHwpSHh1lwJQ4/h0NMPVjW9qyA+1t214P0Y7ss/3ATJ1Hb7zyuOemddB
 1dArUeo0XbWPMffje1bKJ3aeGYD+sDndw+CODjnkM8X75r0HK1uYsap93MC1wzeauow6yzjdjghig
 BwXXu7ubXuMtheX+9PkKFw==;
Date: Thu, 04 Jun 2026 14:35:06 +0300
Message-Id: <865x3ytu6t.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Augusto Stoffel <arstoffel@HIDDEN>
In-Reply-To: <874iji8v21.fsf@HIDDEN> (message from Augusto Stoffel on Thu, 
 04 Jun 2026 12:21:58 +0200)
Subject: Re: bug#81181: [PATCH] Refine the revert-buffer-function of
 shell-command
References: <87ecim96to.fsf@HIDDEN> <86h5niu7aq.fsf@HIDDEN>
 <874iji8v21.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81181
Cc: 81181 <at> debbugs.gnu.org, spwhitton@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Augusto Stoffel <arstoffel@HIDDEN>
> Cc: 81181 <at> debbugs.gnu.org,  spwhitton@HIDDEN
> Date: Thu, 04 Jun 2026 12:21:58 +0200
> 
> 
> On Thu,  4 Jun 2026, Eli Zaretskii wrote:
> 
> > Thanks.  This changes user-facing behavior, so it needs to be called
> > out in NEWS.
> 
> I don't mind, but this is much closer to a bug fix than a new feature.
> IMO mentioning this would just help making NEWS unnecessarily long.

What is bug for you is new behavior for others, who don't necessarily
perceive this as a bug.  So I think we do need a NEWS entry, if only
to be ready for those who'd come up wondering why the command suddenly
asks them a question.

> >> @@ -4780,8 +4780,16 @@ shell-command
> >>  		(setq mode-line-process '(":%s"))
> >>                  (funcall async-shell-command-mode)
> >>                  (setq-local revert-buffer-function
> >> -                            (lambda (&rest _)
> >> -                              (async-shell-command command buffer)))
> >> +                            (lambda (_ noconfirm)
> >> +                              (let ((proc (get-buffer-process buffer)))
> >> +                                (when (or noconfirm
> >> +                                          (not (process-live-p proc))
> >> +                                          (yes-or-no-p "\
> >> +A shell command is running; kill it?"))
> >> +                                  (when proc
> >> +                                    (kill-process proc)
> >> +                                    (while (accept-process-output proc)))
> >> +                                  (async-shell-command command buffer)))))
> >
> > I think I'd prefer to have a normal named function instead of an
> > in-line lambda, as the latter has documentation-related difficulties
> > and shows to the user as a bunch of bytecodes.  (Shouldn't such a
> > function be defined in shell.el?)
> 
> Okay, but that's independent of the refinement I'm suggesting here.
> Should we leave that for another occasion?  It's not an entirely trivial
> refactoring since one would have to define a buffer-local var to store
> COMMAND, which currently lives in the closure.

Sorry, I don't understand: revert-buffer-function is already a
buffer-local variable.

> (If you ask me, I actually prefer the lambda.  There only reason Emacs
> can't take you to the place a lambda is defined is, it hasn't been
> implemented yet.  This missing ELisp feature is important and would help
> a lot with debugging in general.)

Try "C-h v revert-buffer-function" in a buffer where you've set that,
and tell me how you like the results.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.

Message received at 81181 <at> debbugs.gnu.org:


Received: (at 81181) by debbugs.gnu.org; 4 Jun 2026 10:22:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 06:22:07 2026
Received: from localhost ([127.0.0.1]:59275 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV5DC-00035Q-Nl
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 06:22:07 -0400
Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:55511)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <arstoffel@HIDDEN>)
 id 1wV5D8-00034T-0L
 for 81181 <at> debbugs.gnu.org; Thu, 04 Jun 2026 06:22:05 -0400
Received: by mail-wm1-x32f.google.com with SMTP id
 5b1f17b1804b1-490b9318997so3780065e9.2
 for <81181 <at> debbugs.gnu.org>; Thu, 04 Jun 2026 03:22:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1780568521; x=1781173321; darn=debbugs.gnu.org;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=qqDiZpoxlMuLjHJ8ey6zv3WETTUvDhxSl5jG4IrGBLE=;
 b=pawfYOJXvZqB0YxrgglmHq5s7w78J/BT4oiCmoy7nIi6IBg/KF4FLtZj9zNb33wsC4
 Cyy98hXOV4CeujE/DcgxuP6ci53Ob99NAWJp4SCvtSQ4CXmfa5fuBraxNBasB1vVpXwK
 7d/+uL+IbNmRycAMPDO0SDWwmV4x4rJiAUdR0B+gow+blrDCrQvzjgCSk9Ar2i5P/5gM
 MhZUnVH2D48S+3PoYKqQIbk2mGyhThUbDw4T8ZNuIljj4GZlB6fKft+io6QFZQw9hBnY
 j5ZYZuz3BNdHwsykmrcSauTRj5dfDFwbiQgm/sKQWeuLy6zhAvghF4rCgn9ZdPxwge0f
 rWTg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20251104; t=1780568521; x=1781173321;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=qqDiZpoxlMuLjHJ8ey6zv3WETTUvDhxSl5jG4IrGBLE=;
 b=fbyrN6CKH9PdTQk/xqJXBvcC1UHUZtme8WD0BxFFSTOtXmyfy1ObY1TzF2HDHcPxmd
 j1B3F2KiATnIvF34hqyNsIYfp+Lwbcxe4Ou5bOkqg9i5ncgmx5UgykWfEjOf9hqf2aAr
 9pJpShj4C8NvWLDEi1v4huF/+3h2OayolxHGrkaDbJ4xzUrl/rDLirjOsFpICiT8BJTb
 G6uKahA9M2i3f5AQXwfGeVgV39Rlw2ytjasSikVMoihd2jr2KqWB9tlttSse5Mzwx2Tc
 c7G3Lw++sYx0HE+Yyi+2C6VfC5f/0LF1tu0CowRBLuKS1LhwufBO1o8DTnsNzBf0Gjcn
 wE1A==
X-Gm-Message-State: AOJu0YwPcVkDTSkTImhWJAITY6wT71ohwYDdz09YtX4fEuMDr5T8C6X/
 JpKmhCLAOIJ7/UbZ6aXkOnPU+nvQA4hNBEy8jOH9GEt+jJV1gOsEqjER
X-Gm-Gg: Acq92OFelIG5bWfOs9Hsl8HrNOdGYDfH+t5FsbVI+q5XeVWsgsjgQsjQ+yU6n4rSLr8
 G/pdSiw/96zryjrAXHPkIz51ulLGXvoDu44CY0IUuh7MDpDQSQ10uAfABH0vkZQHw7DCA5+HF8n
 qbU5uh2X8HML/t48rlL01vXLuzxY1zEPXmF04PPd5VM1+f0M2iqCD5rhNYNTz9ejx6C+LPu4IXy
 PRNeXe7D7HhZOlwu8ShFQYucZZwhDgZo/5kPjy7AX022NNVwgtGs0QrXQAh/fJm21tIDOAkqTTp
 oqqPtBaaM8886hGkOQj1RdOz7JJ5NJS4sACCJUIlZidm+kebc6mPJl6lwZBRF1jucAZxJA6QRm5
 a6NsBGWOPxqzDaVsPcrgf83/URUlfc+f/2KB9xCdsiC1gy+xVC1QWvcId5vioeejrA9miogBcBQ
 g53lVnLXVo4Rzxeq5ySgzTqqwFa1BG
X-Received: by 2002:a05:600c:8b01:b0:48f:f7cc:f6f5 with SMTP id
 5b1f17b1804b1-490b60e4886mr118437185e9.31.1780568520315; 
 Thu, 04 Jun 2026 03:22:00 -0700 (PDT)
Received: from ars3 ([2a02:8109:8a95:9a00:a174:43ce:14f5:df5e])
 by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-4601f2dcae2sm15864871f8f.6.2026.06.04.03.21.59
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 04 Jun 2026 03:21:59 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#81181: [PATCH] Refine the revert-buffer-function of
 shell-command
In-Reply-To: <86h5niu7aq.fsf@HIDDEN>
References: <87ecim96to.fsf@HIDDEN> <86h5niu7aq.fsf@HIDDEN>
Date: Thu, 04 Jun 2026 12:21:58 +0200
Message-ID: <874iji8v21.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 81181
Cc: 81181 <at> debbugs.gnu.org, spwhitton@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)


On Thu,  4 Jun 2026, Eli Zaretskii wrote:

>> Cc: Sean Whitton <spwhitton@HIDDEN>
>> From: Augusto Stoffel <arstoffel@HIDDEN>
>> Date: Thu, 04 Jun 2026 08:07:47 +0200
>> 
>> Ask to kill the shell command first if it's live.  This is consistent to
>> how 'compile' behaves.
>
> Thanks.  This changes user-facing behavior, so it needs to be called
> out in NEWS.

I don't mind, but this is much closer to a bug fix than a new feature.
IMO mentioning this would just help making NEWS unnecessarily long.

>> @@ -4780,8 +4780,16 @@ shell-command
>>  		(setq mode-line-process '(":%s"))
>>                  (funcall async-shell-command-mode)
>>                  (setq-local revert-buffer-function
>> -                            (lambda (&rest _)
>> -                              (async-shell-command command buffer)))
>> +                            (lambda (_ noconfirm)
>> +                              (let ((proc (get-buffer-process buffer)))
>> +                                (when (or noconfirm
>> +                                          (not (process-live-p proc))
>> +                                          (yes-or-no-p "\
>> +A shell command is running; kill it?"))
>> +                                  (when proc
>> +                                    (kill-process proc)
>> +                                    (while (accept-process-output proc)))
>> +                                  (async-shell-command command buffer)))))
>
> I think I'd prefer to have a normal named function instead of an
> in-line lambda, as the latter has documentation-related difficulties
> and shows to the user as a bunch of bytecodes.  (Shouldn't such a
> function be defined in shell.el?)

Okay, but that's independent of the refinement I'm suggesting here.
Should we leave that for another occasion?  It's not an entirely trivial
refactoring since one would have to define a buffer-local var to store
COMMAND, which currently lives in the closure.

(If you ask me, I actually prefer the lambda.  There only reason Emacs
can't take you to the place a lambda is defined is, it hasn't been
implemented yet.  This missing ELisp feature is important and would help
a lot with debugging in general.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.

Message received at 81181 <at> debbugs.gnu.org:


Received: (at 81181) by debbugs.gnu.org; 4 Jun 2026 06:52:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 02:52:11 2026
Received: from localhost ([127.0.0.1]:55634 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV1w2-0000kH-CC
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 02:52:11 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:49318)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wV1vy-0000iA-4p
 for 81181 <at> debbugs.gnu.org; Thu, 04 Jun 2026 02:52:07 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1wV1vs-0002ei-Jn; Thu, 04 Jun 2026 02:52:00 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=0LZwc+blq3fIySgVwCVuYCt6Cn+mXttkNNeXbSn5T6w=; b=TDwm3c6/kAxJ
 5tFmCQ/yse44yL/cHQE6Gvlrpyfges2Xcm9+AZUQ+PnPYjwdongHx9yywgKkFyWO6cJ3wau2pfs0u
 54GpMBNMzmQmROSGuXRoRo7VQXpaWtJM3lJRPCpUz4C5KlKYTiCf9RGQyuzPKr6Wf5cCq1g4S2cdE
 XtHOglwLzeukxkogy+vu6GuvWTvwRwxovVgg1qWRdlA+Tj4uWELD/+j63ZysU3GsO57hSW+45UA6Y
 5tS8zrx546xPtWlSB7lbYHKWFfK8m+eUBMaBMWPoLmLQSKGFdag4PewrW/4hpUf+esGQ16I/1uZQX
 o0gAbKDtALE5dOkk56qDoA==;
Date: Thu, 04 Jun 2026 09:51:57 +0300
Message-Id: <86h5niu7aq.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Augusto Stoffel <arstoffel@HIDDEN>
In-Reply-To: <87ecim96to.fsf@HIDDEN> (message from Augusto Stoffel on Thu, 
 04 Jun 2026 08:07:47 +0200)
Subject: Re: bug#81181: [PATCH] Refine the revert-buffer-function of
 shell-command
References: <87ecim96to.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 81181
Cc: 81181 <at> debbugs.gnu.org, spwhitton@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Sean Whitton <spwhitton@HIDDEN>
> From: Augusto Stoffel <arstoffel@HIDDEN>
> Date: Thu, 04 Jun 2026 08:07:47 +0200
> 
> Ask to kill the shell command first if it's live.  This is consistent to
> how 'compile' behaves.

Thanks.  This changes user-facing behavior, so it needs to be called
out in NEWS.

> @@ -4780,8 +4780,16 @@ shell-command
>  		(setq mode-line-process '(":%s"))
>                  (funcall async-shell-command-mode)
>                  (setq-local revert-buffer-function
> -                            (lambda (&rest _)
> -                              (async-shell-command command buffer)))
> +                            (lambda (_ noconfirm)
> +                              (let ((proc (get-buffer-process buffer)))
> +                                (when (or noconfirm
> +                                          (not (process-live-p proc))
> +                                          (yes-or-no-p "\
> +A shell command is running; kill it?"))
> +                                  (when proc
> +                                    (kill-process proc)
> +                                    (while (accept-process-output proc)))
> +                                  (async-shell-command command buffer)))))

I think I'd prefer to have a normal named function instead of an
in-line lambda, as the latter has documentation-related difficulties
and shows to the user as a bunch of bytecodes.  (Shouldn't such a
function be defined in shell.el?)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Jun 2026 06:08:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 04 02:08:05 2026
Received: from localhost ([127.0.0.1]:54923 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wV1FM-0004VU-MM
	for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 02:08:04 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:57544)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <arstoffel@HIDDEN>)
 id 1wV1FH-0004UJ-3G
 for submit <at> debbugs.gnu.org; Thu, 04 Jun 2026 02:08:02 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1wV1FB-0003MC-Fq
 for bug-gnu-emacs@HIDDEN; Thu, 04 Jun 2026 02:07:53 -0400
Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <arstoffel@HIDDEN>)
 id 1wV1F9-00040k-Sj
 for bug-gnu-emacs@HIDDEN; Thu, 04 Jun 2026 02:07:53 -0400
Received: by mail-ed1-x531.google.com with SMTP id
 4fb4d7f45d1cf-68f1e28f258so501344a12.3
 for <bug-gnu-emacs@HIDDEN>; Wed, 03 Jun 2026 23:07:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20251104; t=1780553269; x=1781158069; darn=gnu.org;
 h=mime-version:message-id:date:subject:to:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=HLZRGUz5E7RaK+k/udAIsVL6/FXWX4K2axsv4Z3P7f8=;
 b=q5/iNzPQ1Ys3wTHUbT3o/kLV/r8bCgtj9INJOYcAeH4mlSKy+WsdEhO6dwn2U6oYAG
 RtB+INRIqJMLCXsNuPdwIUEwTKmTcOGYMDH37YzeoVDIad4sKjdbDia57qoqxWln+E6Z
 A8SxPC66Tf+ReAqcg4RqB/3gRPu+45fQaNfqnV9XskNAc1vrx0VLgw9TSuhmOPQk67qT
 SKgy9SQ9cpU0QH1TVSfnczFI5JH9UY89mvMiP2NrmZK+tuITOt2VkwAeOrrWMHrLhwJK
 P1MxoVh0lCGqJ5ob1RD34bRSEXK77nEqrmHlNBoI5ByhXNP20lRGrhEJLino2WrRDyjw
 Rvqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20251104; t=1780553269; x=1781158069;
 h=mime-version:message-id:date:subject:to:from:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=HLZRGUz5E7RaK+k/udAIsVL6/FXWX4K2axsv4Z3P7f8=;
 b=jqartJlf+C45GQppMyPiUOZQ4PkHQt94eHAXi6IsT4h9lfIUnibsBL1ulp/o4FraIH
 VHvy5z4BFFqh3PgBSrcnYWB7g8imu+CPJm75sw7i6T69JtSxQa2VJWImNBoRMum27Ncw
 9HZVcTIqx1KozYq1UsKk1epBR1gXNnMJ3VanlWrxdf7g3os6mcRDchgLTK7F2iAHZP13
 LEILiJBkh6lnx3Xbp+kXmTW9Ptkd5wfdDRP/IreyjfejIYfa2bipIKF/sxAN0SQLtln5
 gowc/ip0ACy2FydY8H45jpDR81pI1GicVRuK6jmLxW5dC8LtZ9qj4+vW83CsqGL2hhTO
 15IQ==
X-Gm-Message-State: AOJu0Yyfyp0krEcWgpbRh6IKGn4+C9Ih84tUtO1dOArvAK33J6Ifik4M
 bWwOLgpUuOzuu0NAlVDrNNuO7FFyPy91+k+da27tAK9mgq2LotNRgLhAKbrDpAK2
X-Gm-Gg: Acq92OFH8FwWOz9AlcvuZv6TVdDaOF5km12LdB5eYYEfw1MOd2J8tE0qWsrc0asOakS
 iKKaHYTltgoI6wcicpHNIcUdfHPjv8kwsWF3qWX+dDn25WM+SUpc4F2YU9X1vsq1GYUV3utkCYB
 7u0xSASE9L0iGpm2KtgcXF5iWlufqp8m1MBhBAs3InLQwoVlUDCkzriDltmfTozdF5qPvz2o7Ff
 KjZKvVp0ug46/jY6avLJF5cY+GphJXIexWhCHCwE+6biMP1MJHmPzltERrkpBhJUAvqmpLqTXsv
 sv4jnQgtwu5O0wHBzpIMYHQ+CJEBxBAPxIDdU1uQYPr68NviMrzN8y/8WDM6IyPyAhQsQqe+JJa
 ofFf8ZrBAmM4gIiZG+CGlIUw/86v+1vC/OOX64WvReFB8Y/l97XAMOX2c7VmeLwP00OYV/6s0OP
 v9ZY+l9GQx6iDDBm44wkVY8vohig4g
X-Received: by 2002:a05:6402:518c:b0:68b:5e48:750f with SMTP id
 4fb4d7f45d1cf-68e72e0ac98mr3299925a12.25.1780553268981; 
 Wed, 03 Jun 2026 23:07:48 -0700 (PDT)
Received: from ars3 ([2a02:8109:8a95:9a00:a174:43ce:14f5:df5e])
 by smtp.gmail.com with ESMTPSA id
 4fb4d7f45d1cf-68e64e29c0esm2064806a12.7.2026.06.03.23.07.48
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 03 Jun 2026 23:07:48 -0700 (PDT)
From: Augusto Stoffel <arstoffel@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Refine the revert-buffer-function of shell-command
X-Debbugs-Cc: Sean Whitton <spwhitton@HIDDEN>
Date: Thu, 04 Jun 2026 08:07:47 +0200
Message-ID: <87ecim96to.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::531;
 envelope-from=arstoffel@HIDDEN; helo=mail-ed1-x531.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Tags: patch Ask to kill the shell command first if it's live.
 This is consistent to how 'compile' behaves. From
 8d501294de93591fa418a45cf6effe1eaa32355c
 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Thu, 4 Jun 2026 07:59:41
 +0200 Subject: [PATCH] Refine the revert-buffer-function of shell-command
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (arstoffel[at]gmail.com)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 FORGED_GMAIL_RCVD      'From' gmail.com does not match 'Received'
 headers
 1.0 SPF_SOFTFAIL           SPF: sender does not match SPF record (softfail)
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [2001:470:142:0:0:0:0:17 listed in] [list.dnswl.org]
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

--=-=-=
Content-Type: text/plain

Tags: patch

Ask to kill the shell command first if it's live.  This is consistent to
how 'compile' behaves.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Refine-the-revert-buffer-function-of-shell-command.patch

From 8d501294de93591fa418a45cf6effe1eaa32355c Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@HIDDEN>
Date: Thu, 4 Jun 2026 07:59:41 +0200
Subject: [PATCH] Refine the revert-buffer-function of shell-command

Ask to kill the shell command first if it's live.  This is consistent to
how 'compile' behaves.

* lisp/simple.el (shell-command): Do it.
---
 lisp/simple.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index fd9ba28c762..1a24975000a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4780,8 +4780,16 @@ shell-command
 		(setq mode-line-process '(":%s"))
                 (funcall async-shell-command-mode)
                 (setq-local revert-buffer-function
-                            (lambda (&rest _)
-                              (async-shell-command command buffer)))
+                            (lambda (_ noconfirm)
+                              (let ((proc (get-buffer-process buffer)))
+                                (when (or noconfirm
+                                          (not (process-live-p proc))
+                                          (yes-or-no-p "\
+A shell command is running; kill it?"))
+                                  (when proc
+                                    (kill-process proc)
+                                    (while (accept-process-output proc)))
+                                  (async-shell-command command buffer)))))
                 (set-process-sentinel proc #'shell-command-sentinel)
 		;; Use the comint filter for proper handling of
 		;; carriage motion (see comint-inhibit-carriage-motion).
-- 
2.54.0


--=-=-=--




Acknowledgement sent to Augusto Stoffel <arstoffel@HIDDEN>:
New bug report received and forwarded. Copy sent to spwhitton@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to spwhitton@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#81181; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 4 Jun 2026 15:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.