emacs-devel
[Top][All Lists]
Advanced

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

RE: Tentative diagnosis of TMM's problem. [Re: Enabling TransientMarkMod


From: Drew Adams
Subject: RE: Tentative diagnosis of TMM's problem. [Re: Enabling TransientMarkMode by default]
Date: Thu, 21 Feb 2008 01:43:45 -0800

> Hi, Drew!

Hi Alan.

> > ....but the region is not active, so no highlighting.  ...., if you
> > have `mark-even-if-inactive' = t. 
> 
> Why the "so" in "so no highlighting"?
> I'm beginning to think that this is tautological (see below).

I'm no expert, but my understanding is no, it's not (see below).

> I'm beginning to think that people say "highlight a region" 
> (particularly in non-Emacs programs) when they really mean
> "create a region".  I think I've seen Lennart doing this
> (hi, Lennart!).  This lack of precision is unhelpful.

Lack of precision can be confusing, yes. Part of the difficulty about
speaking of this stuff without taking the extra words needed to clarify the
context is that different vocabulary is used in different contexts. In
particular, some of the discussion was about what people are used to doing
in other editors, where the terminology and behavior are different from
Emacs.

My understanding is the following. In Emacs:

1. As soon as you have set mark at least once, there is a region. The region
continues to exist for the rest of your Emacs session. It can be empty
(point = mark), but it is never destroyed.

2. Transient mark mode has a notion of active and inactive region (but the
region always exists - see #1). If you don't use t-m mode or one of its
derivatives such as delete-selection mode, then this distinction is not
important to you.

3. If you do use t-m mode: (a) You can activate and deactive the region.
This is, BTW, the same thing as activating and deactivating the mark. (b)
When the region is active, it is highlighted; when it is deactivated, it is
unhighlighted. (c) Commands such as C-SPC and C-x C-x activate the region.
Some other commands deactivate it. The command loop also deactivates it,
normally.

4. In t-m mode, some commands act differently, depending on whether the
region is active. For example, `query-replace' limits itself to the active
region; if the region is not active, then it acts on the whole buffer.

5. If you set option `mark-even-if-inactive' to non-nil, then you can always
use the region, even in t-m mode, and even when it is inactive. This option
has no effect unless you use t-m mode.

What's the point of #5, and isn't #5 confusing? Let me take the second part
first. Yes, it might confuse someone who doesn't know what to expect (which
is presumably why the default value is nil), because many commands that act
on the region will affect the region even if it is inactive and therefore
invisible. That could be disconcerting to a newbie, in particular. But it
can be handy for many Emacs users, I think. And it would become more
important with my suggestion - see below.

So what's the point of #5? Why have a notion of active/inactive, and why
make the region visible only some of the time, if you can still act on the
inactive, invisible region?

This is near the crux of what we've been debating, I think. IMO, there are
different use cases. Some people, I think, argue for one use case, and
others argue for the other use case. Both can be useful.

One use case is for operations that specifically are meant to act on the
active region. These are operations such as `query-replace' that offer
different actions depending on the active/inactive status, or they could be
operations (none comes to mind) for which it makes sense to show you (via
highlighting or bouncing the cursor) where the region is before you act on
it. Typically, these operations act on fairly large chunks of text, IMO.

The other use case is for all other region operations - operations for which
there is no special region vs buffer difference of behavior, and for which
you don't need or care to see the region before you whack it in some way.
These operations act on regions of all sizes, but on average they probably
act on smaller regions. If you want to delete a word or two, you just set
the region appropriately and then kill it.

Many Emacs users don't use t-m mode, so there is no distinction and only one
use case for them (the second one, above). In particular, they cannot take
advantage of the double-duty that commands such as `query-replace' offer.

Many other Emacs users do use t-m mode, but they leave
`mark-even-if-inactive' = nil, so they do not take advantage of the first
use case above. Even some t-m mode users who set `mark-even-if-inactive' = t
never or seldom, I suspect, take advantage of operations on the inactive
region.

And in fact, in t-m mode, the region is active a good part of the time, so
those users don't lose much. Each time you hit C-SPC, for instance, you
activate the region. Some people find it annoying that in cases like this
(C-SPC followed by simple cursor movement) the region is highlighted. Even
some people who choose to use t-m mode feel this way.

In particular, since C-SPC is often used to set multiple marks for
navigation, when you are doing that you are not really trying to redefine
the region (though that's what you are doing), and you are especially not
really intending to activate (and so highlight) the region.

Others might disagree with my summary, but I hope it helps.

What I threw out as a suggestion is to let users who choose so get rid of
some of the annoying highlighting for t-m mode by accepting to explicitly
activate the region whenever they want to use active-region operations. The
change would be to simply not let C-SPC activate the region. 

This would be, I think, for users who are midway between the two groups
mentioned - users who would like some of the advantages of each approach:

1. They would get the active/inactive distinction of today's t-m mode, for
things such as `query-replace'. But they would have to do something (e.g.
C-x C-x once or twice) to activate the region first for that.

2. They would not get the annoyance of so much highlighting, because the
region would not be activated automatically by C-SPC. They would get the
active region and its highlighting only on demand.

3. Such users would likely set `mark-even-if-inactive' = t, so they could
still use the region without activating it. They would not need or care to
see it highlighted for the simple operations. (And they could always
activate it whenever they did care.)

I didn't state it as part of my suggestion, but I think now that it would be
desirable for this behavior to be optional. You would set a new option
`set-mark-activates-region-flag' to nil, to stop C-SPC from activating the
mark.

> > FWIW, I have `mark-even-if-inactive' = t, which means I can 
> > always use the region, but I can see when it is active
> > (highlighting). 
> 
> I've now become thoroughly confused as to what an "active" 
> region is.  If `mark-even-if-inactive' is t, I think
> "active" has become equivalent to "highlit".
> Somebody please unconfuse me as appropriate!

They are not equivalent, but only the active region is highlighted, and it
is always highlighted. The important distinction for activation, IMO, is the
difference in behavior of some commands, such as `query-replace'. But yes,
highlighting is also an important attribute of the active region. 

HTH. But be prepared for another, counter opinion from some quarter. ;-)





reply via email to

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