[Top][All Lists]

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

Re: visual-region-mode? (was: delete-selection-mode as default)

From: Charles A. Roelli
Subject: Re: visual-region-mode? (was: delete-selection-mode as default)
Date: Mon, 10 Sep 2018 22:02:07 +0200

> From: hw <address@hidden>
> Date: Mon, 10 Sep 2018 13:52:06 +0200
> >> How come it wasn't distinguished between the concept of a region being
> >> active and the visual aid of marking a region?
> >
> > Separating these two concepts could be useful,
> > but Emacs would then need some other way of showing the user that a
> > region is active,
> Whether regions can be active or not, and whether "active" means that
> they limit or extend operations to themselves, or both, might depend on
> settings and doesn't necessarily need to be shown all the time.

Yes.  Ultimately the choice should be left to the user.
> > like a mode line indicator.
> Such a mode line indicator would need to show which regions are active
> when there several and in which way each one of them is active because
> there are multiple ways of being active.

Can you say how there can be multiple regions active, and how there
can be "multiple ways of being active"?  The region is normally
defined as "the text between point and mark", for one, and whether the
mark is active depends on the value of the buffer-local variable

> Perhaps it could generally show if any region is active and change when
> point is within a region to show more of its details.

Point always delimits the region, so I'm not sure what more details we
could show about it.
> > We would then also need bindings for activating and deactivating the
> > region, and for turning the visual aid on and off.
> Another C-spc after starting to mark a region might do to end the
> marking.

C-SPC (without a prefix argument) always pushes a mark, so it always
alters the region (unless point is already at the mark).  C-u C-SPC
sets point where the mark is, and pops the mark ring, effectively
restoring the previous region.  We should keep this behavior.
> What would the advantage of hidden regions be?  When something is within
> a region, it should be highlighted, and when it is no longer
> highlighted, it should no longer be within a region.

Again, in Emacs, as long there is a mark in the current buffer, there
is always a "region".  The user might want it highlighted for various
reasons, possibly not covered by the current implementation, where
Emacs highlights the region only when 'mark-active' is non-nil.
> Are these hidden regions a remnant of technical limitations that made it
> advisable not to highlight the selection?

No, they stem from convenience.  For example, typing C-M-a in a source
code buffer moves point to the beginning of the current defun, pushing
a mark where point was.  Afterwards, typing C-u C-SPC restores point
and mark (i.e. the region) to where they were before you typed C-M-a.
During editing this is very helpful.  Highlighting the region at any
of these steps might be helpful for the user, but Emacs can't know
exactly when -- which is one argument for allowing to toggle the
highlighting dynamically as necessary, independently of whether the
mark is ever "active".

> Perhaps region selections could be remembered in registers to make it
> easier to re-create them once they were disabled to suppress the
> highlighting.

As seen above, use of C-u C-SPC effectively restores the region at
some previous point in editing.  Certainly, it would be nice to have
some register key to push (cons (point-marker) (mark-marker)) into a
register to come back to it later.  Until we have that, "C-x 4 c C-x n
n C-x r SPC <register>" also works, via an indirect buffer, though
it's a mouthful.

> >> I think for the strict-selection-mode I'd prefer, it would help to
> >> disable transient-mark-mode.  But how can I see what I have selected?
> >
> > The most common answer to that is to use "C-u C-x C-x", which
> > temporarily activates the region (thus highlighting it) and exchanges
> > the point and the mark.  But there is no command to turn on the
> > highlighting of the region directly.
> Doesn't that enable transient-mark-mode?  If I wanted t-m-m, I could
> just leave it enabled to begin with.

Yes, it is enabled temporarily.

> I tried with t-m-m disabled, and I don't see what the point of having it
> disabled is.  Regions are not protected any better, and I'd have to be
> stupid to select a region to do something I want to affect the whole
> buffer.

With t-m-m off, you can make use of the mark without randomly
activating it and causing certain commands to respond differently.
However, there are tradeoffs: commands like "query-replace" will do
their work on the region only when the mark is "active", so to use
that capability, you need "C-u C-x C-x" to temporarily activate the

> >> It would even be possible to leave the visual markers active while the
> >> user is doing something else if transient-mark-mode didn't insist on the
> >> region being active when it's visually highlighted.  
> >
> > I'd like this too.
> It could be accompanied by a region-mode in which nothing can be done to
> and with anything outside of the regions.

Working on a specific region can often be done conveniently from an
indirect buffer, as in the earlier example.

> >>                                                   It would only need
> >> a key binding to stop marking a region.  I'd appreciate it if I didn't
> >> need to always do something with a region immediately and could leave it
> >> highlighted, or leave several regions highlighted at the same time.
> >
> > For a second region, use the secondary selection.  We don't yet have
> > keyboard bindings for its commands, unfortunately, though Drew's
> > package "second-sel" suggests C-M-y:
> >
> > https://www.emacswiki.org/emacs/SecondarySelection#second-sel.el
> Isn't is easier to use registers instead?

It might be.  I use both, but for different purposes.

reply via email to

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