[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: visual-region-mode?
From: |
Charles A. Roelli |
Subject: |
Re: visual-region-mode? |
Date: |
Thu, 27 Sep 2018 23:01:52 +0200 |
> From: hw <address@hidden>
> Cc: address@hidden
> Date: Thu, 27 Sep 2018 00:00:42 +0200
>
> > Yes, but since we have commands that offer behavior specific to active
> > regions, we have the so-called "temporary transient mark mode" --
> > which is a hack to get around this problem. I'd rather have a way to
> > explicitly activate/deactivate the region.
>
> I'm not sure this is a distinct mode; it seems more like the region is
> activated regardless of t-m-m being enabled or not and gets somehow
> disabled eventually.
For what it's worth, the doc of the variable "transient-mark-mode" says:
- The pair (only . OLDVAL) enables Transient Mark mode
temporarily. After any subsequent point motion command that is
not shift-translated, or any other action that would normally
deactivate the mark (e.g. buffer modification), the value of
‘transient-mark-mode’ is set to OLDVAL.
> Why would I disable it permanently? I wouldn't have highlighting, there
> would be no way to fortify the region --- which is a requirement because
> it can not really be disabled due to a fundamental design flaw --- and I
> would have to narrow the buffer all the time to do something with a
> region and to widen it afterwards.
You disable "t-m-m" if you don't want a "transient" mark -- as in,
activating and deactivating itself seemingly of its own volition.
> >> > and without the region randomly deactivating itself after certain
> >> > commands as it does with "t-m-m" switched on.
> >>
> >> [...]
> >>
> >> Are you referring to commands deactivating the region?
> >
> > Yes. See the doc of "t-m-m":
> >
> > The mark is "deactivated" by changing the buffer,
> > and after certain other operations that set the mark but whose
> > main purpose is something else--for example, incremental search,
> > M-<, and M->.
>
> So this doesn't happen randomly but intentionally --- and you could
> re-activate the region if you still want to do something with it.
Actually, the documentation lacks at least one other case: scrolling
that results in point moving, either with the keyboard or with the
mouse. That's one of several arbitrary decisions in the design of
t-m-m.
> > I'd like to be able to carry this behavior over to commands that
> > require an active region for certain things, like M-% does for
> > replacing inside a region.
>
> I guess the right, or consistent, way to do that might be to write more
> antagonistic functions that imply "region", like `query-replace-region'.
>
> Why don't you make a selection when you want to do something with one?
> With t-m-m enabled, that automatically activates the region, and it is
> much better than doing stuff with random parts of the buffer.
I'd rather tells Emacs when the region is active, than the other way
round.
> Other than that, I wonder what would go wrong if you made a key binding
> to a function that toggles `use-region-p' which you use before and
> perhaps after calling functions you want to have a different behaviour.
> Maybe `query-replace-region' could make use of that.
This would be a binding to activate or deactivate the region, I think.
No extra command ("query-replace-region") should be necessary.
> Of course, functions implying "region" don't make sense when t-m-m is
> enabled: t-m-m already implies "region" in the sense of "selection",
> somewhat overcoming the fundamental design flaw of "the region" and the
> idea of doing stuff randomly with parts of buffers. The functions
> implying "region" are merely children of this design flaw because they
> were only invented because nobody wants to narrow and widen their
> buffers to do something with parts of them.
Narrowing still has its place in everyday editing.
> (global-set-key "\C-x\C-x" 'my-exchange-point-and-mark)
> (global-set-key (kbd "<C-f1>")
> (lambda ()
> "Toggle the activeness of the region."
> (interactive)
> (if mark-active (deactivate-mark)
> (activate-mark t))))
> (global-set-key [C-f2] 'my-exchange-point-and-mark)
> (global-set-key [C-f3] 'previous-buffer)
> (global-set-key [C-f5] 'next-buffer)
>
> Those are actual keys, i. e. I press only one key for them. It's rather
> convenient. (The key caps are labeled Print, Help, Record and Play.)
>
> Unfortunately, it seems Unicomp is the only manufacturer still making
> really good keyboards, and the only one for 122 keys ... (The fine
> keyboard started working again the next day after I banged it a little,
> but I really like having more keys.)
Neat, let us know how this approach goes. I don't know what key we
could allocate to a command that activates or deactivates the region,
since there are not free ones left on average keyboards...
> On a side note, why is the function that activates the region called
> activate-mark and not activate-region? Is there some purpose or
> distinction involved we don't know about?
People use "active mark" and "active region" interchangeably, AFAIK.
(I know I do!)
> > [...]
> > Btw, I'm culling most of the CC list since it seems no longer relevant.
>
> I don't know who/what created this list; I suspect it might have been
> gnus.
Those people had responded to this thread earlier, so they ended up on
the list automatically.
- Re: visual-region-mode?, (continued)
- Re: visual-region-mode?, Charles A. Roelli, 2018/09/18
- Re: visual-region-mode?, hw, 2018/09/18
- Re: visual-region-mode?, Charles A. Roelli, 2018/09/19
- Re: visual-region-mode?, hw, 2018/09/19
- Re: visual-region-mode?, Charles A. Roelli, 2018/09/20
- Re: visual-region-mode?, hw, 2018/09/21
- Re: visual-region-mode?, Charles A. Roelli, 2018/09/24
- Re: visual-region-mode?, Yuri Khan, 2018/09/24
- RE: visual-region-mode?, Drew Adams, 2018/09/24
- Re: visual-region-mode?, hw, 2018/09/26
- Re: visual-region-mode?,
Charles A. Roelli <=
- Re: visual-region-mode?, Alan Mackenzie, 2018/09/24
- Re: visual-region-mode?, Charles A. Roelli, 2018/09/26
- Re: visual-region-mode?, hw, 2018/09/26
- Re: visual-region-mode?, Alan Mackenzie, 2018/09/27
- Re: visual-region-mode?, Juri Linkov, 2018/09/12
- Re: delete-selection-mode as default, Dmitry Gutov, 2018/09/08
- Re: delete-selection-mode as default, Elias Mårtenson, 2018/09/09
- Re: delete-selection-mode as default, Clément Pit-Claudel, 2018/09/09
Re: delete-selection-mode as default (WAS: Some developement questions), Phil Sainty, 2018/09/07