all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Sean Whitton <spwhitton@spwhitton.name>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 46151@debbugs.gnu.org
Subject: bug#46151: 28.0.50; Set revert-buffer-function in shell command output buffers
Date: Fri, 29 Jan 2021 00:05:37 -0700	[thread overview]
Message-ID: <87wnvwte7y.fsf@melete.silentflame.com> (raw)
In-Reply-To: <87im7gward.fsf@gnus.org>

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

On Fri 29 Jan 2021 at 06:52AM +01, Lars Ingebrigtsen wrote:

> Sean Whitton <spwhitton@spwhitton.name> writes:
>
>> Inspired by Stefan's comment at [1] I came up with this patch to set
>> revert-buffer-function in shell command buffers.
>
> Nice; I've applied your patch to Emacs 28.

Thanks for taking a look!

I realised that my patch needs to setq-local not just setq.  Indeed, my
previous patch breaks revert-buffer once you've run a shell command...

Attached is a fix.

>> 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.
>
> Would it make sense to just define a tiny mode that just defines the `g'
> command to revert and use that in these buffers?

For M-!, yes, that would be useful and simple.

For M-&, the mode would need to be activated only once the command had
finished running, as otherwise 'g' should be sent to the inferior
process.  Not hard to do that either.

I take it a minor mode is more appropriate than a major mode for this?
If so, I can come up with a patch adding that to simple.el.

-- 
Sean Whitton

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-previous-commit-regarding-revert-buffer-function.patch --]
[-- Type: text/x-diff, Size: 1973 bytes --]

From 21499b416759b77a5d0ef41cb4f68932d36b9b63 Mon Sep 17 00:00:00 2001
From: Sean Whitton <spwhitton@spwhitton.name>
Date: Fri, 29 Jan 2021 00:02:08 -0700
Subject: [PATCH] ; Fix previous commit regarding revert-buffer-function

* simple.el (shell-command, shell-command-on-region): Set
revert-buffer-function buffer-locally, not globally.  Also, avoid an
unnecessary call to (current-buffer) by taking advantage of the
closure.
---
 lisp/simple.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 64ee042135..742fc5004d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3991,9 +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))))
+                  (setq-local revert-buffer-function
+                              (lambda (&rest _)
+                                (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).
@@ -4260,9 +4260,9 @@ characters."
                                              buffer))))
             ;; Report the output.
             (with-current-buffer buffer
-              (setq revert-buffer-function
-                    (lambda (&rest _)
-                      (shell-command command)))
+              (setq-local revert-buffer-function
+                          (lambda (&rest _)
+                            (shell-command command)))
               (setq mode-line-process
                     (cond ((null exit-status)
                            " - Error")
-- 
2.29.2


  reply	other threads:[~2021-01-29  7:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

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

  git send-email \
    --in-reply-to=87wnvwte7y.fsf@melete.silentflame.com \
    --to=spwhitton@spwhitton.name \
    --cc=46151@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.