Subject: Re: bug#70820: [PATCH] Editable grep buffers

From: Stefan Monnier <[email-masked]>
Date: Sat, 18 May 2024 09:34:25 -0400

>> > I don't think I understand this difficulty, either: with
>> > occur-edit-mode it is solved by making occur-edit-mode be derived from
>> > occur-mode.  Couldn't you do the same with your mode?
>> 
>> No because occur-mode makes occur-revert-arguments permanent-local so
>> `g' survives the major-mode changes.
>> 
>> For revert-buffer alone, compilation-arguments needs to be marked
>> permanent-local.  As it is a part of compile.el, I am not sure if
>> marking it as such is safe.  This is why I think having a minor-mode is
>> better.
>
> It sounds like a minor issue which shouldn't have such grave
> consequences.  Why do you think making compilation-arguments
> permanent-local would be a problem?  We could ask people who
> frequently contribute to compile.e land grep.el if they see any
> problem with doing that.

AFAICT it would be harmless to make it permanent-local.  Indeed, this
var belongs with the contents of the buffer rather than with its mode
(in a sense it is akin to `buffer-file-name` in that it says where the
contents comes from), so it makes a lot of sense to mark it
permanent-local.

Side note: I believe things become simpler&cleaner if you separate the
major mode function from the command that switches to it (just like
`wdired-change-to-wdired-mode` is separate from `wdired-mode`).

E.g. that lets you save&restore buffer-local vars like
`compilation-arguments`, and it let you remove or disable
`compilation--remove-properties` in a straightforward manner.

        Stefan