[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: isearch region or thing at point.
From: |
Drew Adams |
Subject: |
RE: isearch region or thing at point. |
Date: |
Tue, 30 Apr 2019 08:39:56 -0700 (PDT) |
> Thanks, such addition is welcome. Currently searching the
> active region requires invocation of several commands: M-w C-s M-y
> with a bad side-effect of leaving the region in the kill-ring.
>
> However, adding a new option is not a satisfactory solution
> because often isearch is used to extend the boundaries of the
> active region, e.g. by setting the region's beginning with C-SPC,
> then searching the region's end and exiting isearch there.
>
> Fortunately, like Basil mentioned the command isearch-forward-symbol-at-point
> bound to 'M-s .' you could create a similar command bound to e.g. 'M-s r'
> that would start isearch with the text from the active region.
My own take on this:
1. A user option is helpful (only) for users who really
want this behavior all the time. Unless, that is,
Emacs decides to let users toggle the option with a
(search-map) key. Vanilla Emacs doesn't like to do
that, opting instead for using a non-option variable
(letting you toggle that).
2. It's already simple to search for the region text, as
Juri points out: `M-w C-s M-y'. And as he says, you
can easily define a command that does that from the
outset.
FWIW, as one user, I don't have a problem with `M-w'
adding the region text to the kill-ring. I don't see
that as a "bad side-effect" but rather as something
often useful. But sure, you can make searching for
selected text be independent from adding that text to
the kill-ring.
If you set option `mouse-drag-copy-region' to non-nil
then text selected with the mouse is automatically
added to the kill-ring, so you can just use `M-y'
during search to yank it.
3. There are several different ways the active region
can be useful for Isearch. Juri mentioned one:
extend the region end to a searched position. Each
way to use the region should be optional, and
sometimes some of them can be combined. Whatever you
provide, please make it optional.
By way of example, here are some ways the region can
be used for Isearch that are offered by library
Isearch+ as optional behaviors:
a. Search only within the active region: option
`isearchp-restrict-to-region-flag' - toggle with
`C-x n' while searching.
b. Show match numbers only for search hits within
the region (has an effect only when search is
limited to the region): option
`isearchp-limit-match-numbers-to-region-flag' -
toggle with `M-s %' while searching.
c. Deactivate the region for Isearch: option
`isearchp-deactivate-region-flag' - toggle with
`C-SPC C-SPC' while searching.
d. Select the last search or query-replace target,
that is, make it the active region. Do this
either per option `isearchp-set-region-flag'
(toggle with `M-s M-SPC' while searching) or on
demand: `isearchp-set-region-around-search-target'.
e. Create a noncontiguous region from the
lazy-highlighted text (search hits): `M-s z r'
while searching.
f. Add/remove a text property to/from the region.
Search only areas that have that property with
particular values. Works also for overlays.
g. Search outside the area that would normally be
searched (e.g. the region or a set of zones).
That is, complement the search space. Toggle
with `M-= ~' while searching.
There are no doubt other ways the region can be
used for Isearch. We should not assume that
there's only one thing users might want to do
with it. Keep their, and our, options open.
[https://www.emacswiki.org/emacs/IsearchPlus]
- isearch region or thing at point., Ergus, 2019/04/26
- Re: isearch region or thing at point., Basil L. Contovounesios, 2019/04/26
- Re: isearch region or thing at point., Ergus, 2019/04/28
- Re: isearch region or thing at point., Ergus, 2019/04/28
- Re: isearch region or thing at point., Ergus, 2019/04/28
- Re: isearch region or thing at point., Juri Linkov, 2019/04/29
- Re: isearch region or thing at point., Ergus, 2019/04/29
- RE: isearch region or thing at point.,
Drew Adams <=
- Re: isearch region or thing at point., Ergus, 2019/04/30
- Re: isearch region or thing at point., Juri Linkov, 2019/04/30
- Re: isearch region or thing at point., Ergus, 2019/04/30
- Re: isearch region or thing at point., Noam Postavsky, 2019/04/30
- Re: isearch region or thing at point., Ergus, 2019/04/30
- Re: isearch region or thing at point., Noam Postavsky, 2019/04/30
- Re: isearch region or thing at point., Ergus, 2019/04/30
- Re: isearch region or thing at point., Noam Postavsky, 2019/04/30
- Re: isearch region or thing at point., Basil L. Contovounesios, 2019/04/30
- Re: isearch region or thing at point., Ergus, 2019/04/30