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: Stefan Monnier
Subject: Re: [External] : Re: Adding refactoring capabilities to Emacs
Date: Fri, 29 Sep 2023 11:20:15 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

>> > We should "merge" `C-x C-q` and `e`, indeed, like we do for Dired.
>> Yes, and isn't a buffer-local value for read-only-mode-hook the
>> suitable way to fix that?

I must admit I haven't looked at what the implementation
would/should/could look like.

> For context, I'm asking because I don't think rebinding `C-x C-q`
> to a different command (like in the case of Dired) is as good
> as using the existing hook.  It should be much more consistent
> to use the standard facilities of the existing minor mode.

In general, I agree.  There are degrees, tho.
E.g. Dired doesn't touch `C-x C-q`, strictly speaking, instead it remaps
`read-only-mode` which is much cleaner already.

But admittedly, looking at the code of `dired-toggle-read-only` I can't
see an obvious technical reason why it couldn't use
`read-only-mode-hook` instead (tho maybe the interaction with
`view-read-only` could be a problem [I'd argue the problem is in
`view-read-only`, tho]).  Yet, at the same time changing the minor mode
from within `read-only-mode-hook` doesn't sound super healthy (from
a purely philosophical standpoint, at least), so I think such a change
would probably make more sense if we were to change wdired so it's not
a wholly separate major mode.

> Likewise, I don't think having "-read-only" or "-edit" variations
> of each major mode is a good idea.  We can activate and deactivate
> keymaps on the fly right?

Again, I'd tend to agree but I'd have to see the details to be sure.
In the case of Dired the two states are very different (completely
different key-bindings and sets of operations), so while I think the use
of a separate major mode is a historical accident, it's not too bad of
a choice.

In contrast in `diff-mode` I originally didn't even use
a `read-only-mode-hook`; instead I used
`minor-mode-overriding-map-alist` to dynamically activate/deactivate the
key bindings according to the value of `buffer-read-only`.


        Stefan




reply via email to

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