Subject: 28.0.50; Set revert-buffer-function in shell command output buffers

From: Sean Whitton <[email-masked]>
Date: Wed, 27 Jan 2021 23:22:53 -0700

Inspired by Stefan's comment at [1] I came up with this patch to set
revert-buffer-function in shell command buffers.

I have a binding for revert-buffer which is nicer to press than M-! M-p
RET or M-& M-p RET when repeatedly editing and re-running programs and
scripts.

[1]  https://emacs.stackexchange.com/questions/35421/refresh-async-shell-command-buffer

-- 
Sean Whitton
>From 2f121e3d540bd18bd39829545ef3b07178501958 Mon Sep 17 00:00:00 2001
From: Sean Whitton <[email-masked]>
Date: Wed, 27 Jan 2021 23:18:03 -0700
Subject: [PATCH] Set revert-buffer-function in shell command output buffers

* simple.el (shell-command, shell-command-on-region): Set
revert-buffer-function in shell command output buffers.
---
 lisp/simple.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/simple.el b/lisp/simple.el
index e82b138b0d..24e3b4a7f5 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3991,6 +3991,9 @@ impose the use of a shell (with its need to quote arguments)."
 			  (start-process-shell-command "Shell" buffer command)))
 		  (setq mode-line-process '(":%s"))
                   (shell-mode)
+                  (setq revert-buffer-function
+                        (lambda (&rest _)
+                            (async-shell-command command (current-buffer))))
                   (set-process-sentinel proc #'shell-command-sentinel)
 		  ;; Use the comint filter for proper handling of
 		  ;; carriage motion (see comint-inhibit-carriage-motion).
@@ -4257,6 +4260,9 @@ characters."
                                              buffer))))
             ;; Report the output.
             (with-current-buffer buffer
+              (setq revert-buffer-function
+                    (lambda (&rest _)
+                      (shell-command command)))
               (setq mode-line-process
                     (cond ((null exit-status)
                            " - Error")
-- 
2.29.2