unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46151: 28.0.50; Set revert-buffer-function in shell command output buffers
@ 2021-01-28  6:22 Sean Whitton
  2021-01-29  5:52 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 40+ messages in thread
From: Sean Whitton @ 2021-01-28  6:22 UTC (permalink / raw)
  To: 46151

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

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Set-revert-buffer-function-in-shell-command-output-b.patch --]
[-- Type: text/x-diff, Size: 1545 bytes --]

From 2f121e3d540bd18bd39829545ef3b07178501958 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
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


^ permalink raw reply related	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2021-02-04  7:51 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28  6:22 bug#46151: 28.0.50; Set revert-buffer-function in shell command output buffers Sean Whitton
2021-01-29  5:52 ` Lars Ingebrigtsen
2021-01-29  7:05   ` Sean Whitton
2021-01-29  7:21     ` Lars Ingebrigtsen
2021-01-29 18:32       ` Sean Whitton
2021-01-30  6:18         ` Lars Ingebrigtsen
2021-01-31 18:50           ` Sean Whitton
2021-02-01  8:49             ` Lars Ingebrigtsen
2021-02-01 16:14               ` bug#46151: [External] : " Drew Adams
2021-02-01 18:00               ` Sean Whitton
2021-02-01 19:43                 ` bug#46151: [External] : " Drew Adams
2021-02-02  8:44                 ` Lars Ingebrigtsen
2021-02-01 20:13               ` Dmitry Gutov
2021-02-02  8:49                 ` Lars Ingebrigtsen
2021-02-02 12:38                   ` Dmitry Gutov
2021-02-03 18:36                     ` Lars Ingebrigtsen
2021-02-03 22:46                       ` Dmitry Gutov
2021-02-04  7:51                         ` Lars Ingebrigtsen
2021-01-30 18:36         ` Juri Linkov
2021-01-30 21:01           ` bug#46151: [External] : " Drew Adams
2021-01-31  4:02           ` Michael Welsh Duggan
2021-01-31  7:37             ` Lars Ingebrigtsen
2021-01-31  9:20               ` Juri Linkov
2021-01-31 18:03                 ` bug#46151: [External] : " Drew Adams
2021-01-31  9:46               ` Kévin Le Gouguec
2021-01-31  9:54                 ` Lars Ingebrigtsen
2021-01-31 10:48                   ` Tomas Nordin
2021-01-31 13:06                     ` Kévin Le Gouguec
2021-01-31 21:35                     ` Juri Linkov
2021-01-31 18:20                   ` bug#46151: [External] : " Drew Adams
2021-01-31 16:07               ` Michael Welsh Duggan
2021-01-31 17:57               ` bug#46151: [External] : " Drew Adams
2021-01-31 18:47               ` Sean Whitton
2021-01-31 23:31       ` Dmitry Gutov
2021-02-01  0:08         ` Sean Whitton
2021-02-01  2:08           ` Dmitry Gutov
2021-02-01  5:44             ` Sean Whitton
2021-02-01 20:04               ` Dmitry Gutov
2021-02-01 20:49                 ` Sean Whitton
2021-02-01 21:30                   ` Dmitry Gutov

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).