emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [External] : Re: Adding refactoring capabilities to Emacs


From: Eli Zaretskii
Subject: Re: [External] : Re: Adding refactoring capabilities to Emacs
Date: Fri, 29 Sep 2023 13:36:22 +0300

> From: "Alfred M. Szmidt" <ams@gnu.org>
> Cc: dmitry@gutov.dev, joaotavora@gmail.com, philipk@posteo.net,
>       monnier@iro.umontreal.ca, eliz@gnu.org, emacs-devel@gnu.org
> Date: Tue, 26 Sep 2023 11:22:20 -0400
> 
> Occur and grep buffers are by default read-only (and there is a
> regression in that too

It is only a "regression" if you still have your muscle memory from 20
years ago, since it's when we started making the compilation-mode
buffers read-opnly.

> -- you can no longer edit a grep/occur buffer
> easily due to strange font lock or other properties).

Of course, you can: this is just one "C-x C-q" away (as in any other
read-only buffer).  Let's not look for problems where there are none.

> They are also not files, if you open a file (any file really) you will
> expect to be able to edit it using normal commands not specific to the
> mode (i.e. self-inser-command ...).  vc-diff etc, are more akin to
> occur and grep -- the user doesn't work against the file, but rather a
> buffer.

That depends on your workflows and preferences, of course.  I can
easily imagine someone working with *.diff and *.patrh files a lot.

>    We already have, and are used to, the universal idiom of `C-x C-q'
>    to toggle a buffer read-only.  I use that in grep and occur buffers
>    without a second thought.  Why isn't that "sufficient" for diff
>    buffers as well?
> 
> Because we are also talking about files on disk.  If you save a
> compilation buffer (essentially the same thing as M-x grep or M-x
> occur) to disk, and re-open it, it will not be read-only -- and it
> would make little sense for it to be so.  Where as M-x compile _will_
> be read-only.

I don't see how this is a problem.

There are kinds of files and buffers where sometimes it makes sense to
have them editable and sometimes not, sometimes it makes sense to
treat them as normal text files, and sometimes as specially-formatted
files supported by special modes.  Emacs lets you handle these cases
in all of the above possibilities, and I see no reason to argue about
what is The Only Right Thing here, because there isn't one.

>    I can see that some might want commands/keys that act on the buffer
>    content, including to change it in
>    structured/"legitimate"/refactoring ways, while keeping it
>    read-only.
> 
> One can have both, diff-mode already allows you to edit the file, and
> act on it in a structure manner -- much like any programming mode.

And "C-x C-q" or "M-x fundamental-mode" or "M-x text-mode" lets you
edit them if you need.

>    That way, by default, diff buffers would still be read-only by
>    default, quitable with `q', but also modifiable in all the usual
>    ways after `C-x C-q'.
> 
> But diff buffers aren't read-only -- it depends on their context.

The context depends on the use case and the workflow, and cannot be
reliably determined by Emacs.  So we picked one possibility, and the
others are just one command away.

So let's please stop this futile dispute, which once again is entirely
about personal preferences.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]