Subject: Re: bug#46151: 28.0.50; Set revert-buffer-function in shell command output buffers

From: Sean Whitton <[email-masked]>
Date: Fri, 29 Jan 2021 11:32:58 -0700

Hello,

On Fri 29 Jan 2021 at 08:21AM +01, Lars Ingebrigtsen wrote:

>>> 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.
>
> Since M-! and M-& use different modes (fundamental and shell), a minor
> mode is probably the best, I guess.

I was thinking about this some more and now I'm not so sure.  Do we
really want exactly one letter key not to be self-inserting in those
buffers?

Currently the command output is editable in ordinary ways, so it would
be reasonable to edit the command output by typing something, then kill
some text after you've edited it, and put it elsewhere.

This sort of thing could be pretty annoying if you happened to want to
type the letter 'g' and thereby reran the command ..

How about binding C-c C-r instead of g?  The mnemonic would be
Reexecute.  In *Async Shell Command* buffers this already has an
inherited binding but I don't believe it is one that does anything
useful in those buffers, so should be fine to override.

An alternative would be to put the whole buffer in special-mode, which
would bind 'g', and make shell command output more like M-x compile
buffers.  Could have a defcustom to turn this off.

-- 
Sean Whitton