[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: delete-selection-mode as default
From: |
Drew Adams |
Subject: |
RE: delete-selection-mode as default |
Date: |
Fri, 14 Sep 2018 08:23:31 -0700 (PDT) |
> The region is currently used for 3 purposes: navigation, invoking
> commands on a region of text, and delete-selection-mode. (If someone
> thinks that delete-selection-mode is a variant of "invoking commands
> on a region of text", they are mistaken, and this long discussion is
> one proof of that mistake.) It should be clear from this discussion
> that there are fundamental tensions between these 3 purposes. The
> first two can be reconciled by using the "active" vs "inactive"
> region, something we already have. This distinction is needed because
> an Emacs buffer will almost always have a region, and therefore users
> need some knob to control whether a command should act on the region
> or on the entire buffer. (It is possible that we need some new
> command to "activate" the region, because the current method are IMO
> unsatisfactory: they require navigation, which is totally gratuitous.)
>
> The third use of the region, the one needed for delete-selection-mode,
> is IMO impossible to reconcile with the other two. Instead of trying
> to reconcile them with some trick, we should consider introducing a
> new "state" of the region, which will be activated by a special
> command, or could be optionally activated by "C-x C-x" etc., given
> some optional setting. IOW, let the users "arm" the region for
> delete-selection type of commands, similarly to how they currently
> "activate" it for the other purpose. Then the user could decide what
> exactly they want the region to provide, and the basic conundrum is
> gone.
`delete-selection-mode' is 5 well-defined behaviors for the active
region, carried out when you invoke a command. It's nothing
more than that.
Which of those 5 behaviors to use depends on the command you
invoke when the region is active.
Users can trivially control which of the 5 behaviors to use for
a given command, just by putting a property on the command
symbol. These are the possible property values and associated
behaviors:
1. nil: Do nothing (no-op). Same as turning off d-s-m mode
for that command.
2. non-nil and not one of the symbols below (default):
Delete (do not kill) the active region (`delete-active-region').
Then invoke the command.
3. `kill': Kill the active region (`kill-region'). Then invoke
the command.
4. `supersede': Just delete the active region. Do not invoke
the command.
5. `yank': Delete the active region, and make sure that the
text deleted is not the same as the text that gets yanked.
(Used only for a command that yanks.)
There's no difficulty "reconciling" d-s-m with the "other
uses" of the region that you cite. None whatsoever.
You've shown none, AFAICT. No trick is needed. It just
works.
A user or code can turn d-s-m off anytime. Or turn it off
for any given command (#1 above).
> Other commands, which make sense both when there is and there
> isn't a region, need an indication of what the user wants them to
> do, and whether the region is active is that indication.
Yes.
> The problem is that we now want to introduce yet another, 3rd meaning
> of the region, which is not identical to either of the other two.
There is no 3rd meaning of the region. There is not even a
2nd meaning. There is one meaning of the region - the text
delimited by point and mark.
If t-m-m is on then the region can have two states: active or
inactive. If the region is active and d-s-m is on then it can be
automatically deleted when you invoke a command. That's all.
There is nothing complicated or mysterious about d-s-m. If
there were - if there were some crazy irreconcilability, then
the same would be true of `C-w' and `delete-active-region'.
There is also nothing complicated or mysterious about t-m-m.
There is also nothing complicated about Emacs behavior
when t-m-m and d-s-m are off.
Misunderstandings come from mistaken expectations and
the fact that different users use Emacs differently.
Confusion can come from the fact that there are multiple
knobs to control region behavior (and not just two modes,
t-m-m and d-s-m), and it's not obvious sometimes that a
given knob exists or how the various knobs interact.
I do think it would help to have a command that only
activates the region. Making `C-x C-x' do double duty is
truly one place where confusion can get sown. It should
be _able_ to do double duty, for convenience. But users
should also be able to only activate the region and only
swap point and mark - as separate operations.
- Re: delete-selection-mode as default, (continued)
- Re: delete-selection-mode as default, hw, 2018/09/13
- Re: delete-selection-mode as default, Alan Mackenzie, 2018/09/13
- Re: delete-selection-mode as default, hw, 2018/09/13
- Re: delete-selection-mode as default, Alan Mackenzie, 2018/09/14
- Re: delete-selection-mode as default, Yuri Khan, 2018/09/14
- Re: delete-selection-mode as default, Alan Mackenzie, 2018/09/14
- Re: delete-selection-mode as default, Yuri Khan, 2018/09/14
- Re: delete-selection-mode as default, Phil Sainty, 2018/09/14
- Re: delete-selection-mode as default, Phil Sainty, 2018/09/14
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/14
- RE: delete-selection-mode as default,
Drew Adams <=
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/14
- RE: delete-selection-mode as default, Drew Adams, 2018/09/14
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/15
- Re: delete-selection-mode as default, Alan Mackenzie, 2018/09/15
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/15
- Re: delete-selection-mode as default, Ergus, 2018/09/15
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/15
- Re: delete-selection-mode as default, Ergus, 2018/09/15
- Re: delete-selection-mode as default, Eli Zaretskii, 2018/09/16
- Re: delete-selection-mode as default, Alan Mackenzie, 2018/09/16