unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* isearch and region ?
@ 2017-11-07  7:39 Jean-Christophe Helary
  2017-11-07  8:31 ` Yuri Khan
  2017-11-07  9:13 ` Damien Wyart
  0 siblings, 2 replies; 6+ messages in thread
From: Jean-Christophe Helary @ 2017-11-07  7:39 UTC (permalink / raw)
  To: emacs-devel

I would like to know why isearch has been designed so that it does not create a region with the matching string. The thing that appears in the buffer looks like a region, but it is not, and that keeps the user from immediately interacting with the matching string (deleting, overwriting, killing or yanking, etc.)

Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: isearch and region ?
  2017-11-07  7:39 isearch and region ? Jean-Christophe Helary
@ 2017-11-07  8:31 ` Yuri Khan
  2017-11-07  9:08   ` Jean-Christophe Helary
  2017-11-07  9:13 ` Damien Wyart
  1 sibling, 1 reply; 6+ messages in thread
From: Yuri Khan @ 2017-11-07  8:31 UTC (permalink / raw)
  To: Jean-Christophe Helary; +Cc: emacs-devel

On Tue, Nov 7, 2017 at 2:39 PM, Jean-Christophe Helary
<jean.christophe.helary@gmail.com> wrote:
> I would like to know why isearch has been designed so that it does not create a region with the matching string. The thing that appears in the buffer looks like a region, but it is not, and that keeps the user from immediately interacting with the matching string (deleting, overwriting, killing or yanking, etc.)

isearch is incremental, so most of the region-affecting actions would
conflict with it.

* Deleting with Backspace deletes the last character of the pattern
(conflicts with deleting the region).
* Typing text adds to the pattern (conflicts with overwriting the region).
* Pasting (yanking) adds to the pattern, too.

You would need an isearch command that (1) marks the current
occurrence as a region, and (2) exits isearch mode so you can affect
the region with your next command.

On the other hand, some commands could work right out of isearch mode,
if suitably implemented:

* Deleting with Delete.
* Cutting (killing) and copying.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: isearch and region ?
  2017-11-07  8:31 ` Yuri Khan
@ 2017-11-07  9:08   ` Jean-Christophe Helary
  2017-11-07 15:26     ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe Helary @ 2017-11-07  9:08 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2210 bytes --]

Thank you Yuri.

> On Nov 7, 2017, at 17:31, Yuri Khan <yuri.v.khan@gmail.com> wrote:
> 
> On Tue, Nov 7, 2017 at 2:39 PM, Jean-Christophe Helary
> <jean.christophe.helary@gmail.com> wrote:
>> I would like to know why isearch has been designed so that it does not create a region with the matching string. The thing that appears in the buffer looks like a region, but it is not, and that keeps the user from immediately interacting with the matching string (deleting, overwriting, killing or yanking, etc.)
> 
> isearch is incremental, so most of the region-affecting actions would
> conflict with it.

But search is not incremental and does not return a region either. It just puts point at the end of the match. I guess that's useful when you are trying to create a region from the original point (where you'd put the mark) to the end of the matching string, but that's quite a limited use. Or is search designed only for navigation in the document? What's the point having a search that does not *find*?

Is there a search that returns the matching string as a region?

> * Deleting with Backspace deletes the last character of the pattern
> (conflicts with deleting the region).
> * Typing text adds to the pattern (conflicts with overwriting the region).
> * Pasting (yanking) adds to the pattern, too.

I see that there are lots of isearch-yank commands, but no isearch-kill...

On the help list, I was suggested to use C-backspace after an isearch since the point is at the end of the match, but that only deletes a "word" and not the full match.

By the way, what is the status of the beginning of the match as highlighted by isearch? It is not a mark, and it is not point...

> You would need an isearch command that (1) marks the current
> occurrence as a region, and (2) exits isearch mode so you can affect
> the region with your next command.

I understand that.

> On the other hand, some commands could work right out of isearch mode,
> if suitably implemented:
> 
> * Deleting with Delete.
> * Cutting (killing) and copying.



Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



[-- Attachment #2: Type: text/html, Size: 4148 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: isearch and region ?
  2017-11-07  7:39 isearch and region ? Jean-Christophe Helary
  2017-11-07  8:31 ` Yuri Khan
@ 2017-11-07  9:13 ` Damien Wyart
  1 sibling, 0 replies; 6+ messages in thread
From: Damien Wyart @ 2017-11-07  9:13 UTC (permalink / raw)
  To: emacs-devel

Hi,

Even if it is true from a design perspective, there are alternative
solutions, as you can read here:
https://emacs.stackexchange.com/questions/31320/selecting-i-e-as-the-region-the-current-match-in-incremental-search


Regards

Damien


On Tue, Nov 7, 2017 at 8:39 AM, Jean-Christophe Helary
<jean.christophe.helary@gmail.com> wrote:
> I would like to know why isearch has been designed so that it does not create a region with the matching string. The thing that appears in the buffer looks like a region, but it is not, and that keeps the user from immediately interacting with the matching string (deleting, overwriting, killing or yanking, etc.)
>
> Jean-Christophe Helary
> -----------------------------------------------
> @brandelune http://mac4translators.blogspot.com
>
>
>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: isearch and region ?
  2017-11-07  9:08   ` Jean-Christophe Helary
@ 2017-11-07 15:26     ` Drew Adams
  2017-11-07 15:54       ` Jean-Christophe Helary
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2017-11-07 15:26 UTC (permalink / raw)
  To: Jean-Christophe Helary, emacs-devel

>> isearch is incremental, so most of the region-affecting 
>> actions would conflict with it.
> 
> But search is not incremental and does not return a region either.
> It just puts point at the end of the match. I guess that's useful
> when you are trying to create a region from the original point
> (where you'd put the mark) to the end of the matching string,
> but that's quite a limited use. Or is search designed only for
> navigation in the document? What's the point having a search that
> does not *find*?
>
> Is there a search that returns the matching string as a region?
...
> I see that there are lots of isearch-yank commands, but no
> isearch-kill...

I responded to this already on help-gnu-emacs.  You have that
possibility with Isearch+, using `C-M-RET'.

> On the help list, I was suggested to use C-backspace after
> an isearch since the point is at the end of the match, but
> that only deletes a "word" and not the full match.
>
> By the way, what is the status of the beginning of the
> match as highlighted by isearch? It is not a mark, and
> it is not point...
>
> You would need an isearch command that (1) marks the current
> occurrence as a region, and (2) exits isearch mode so you
> can affect the region with your next command. I understand that.
>
> On the other hand, some commands could work right out of
> isearch mode, if suitably implemented:
> * Deleting with Delete.
> * Cutting (killing) and copying.

The behavior of `isearchp-act-on-demand' (`C-M-RET', by
default) in Isearch+ is arbitrary - configurable, bindable.
You can have it do anything you want to the current search
hit.

You can also define any number of different commands that
use it as their base, let-binding different actions for
their purposes.  Bind those commands to different keys in
Isearch.  End of story.

You don't need to have the search hit be selected as the
active region; you just need to act on it.

But if, for some reason, you really wanted to activate it
as the region temporarily, e.g., to leverage an existing
function that acts on the region, that too is trivial to
do in a function that you use as the value of
`isearchp-on-demand-action-function' (which is what is
used by `isearchp-act-on-demand').

As for other uses of the region wrt Isearch: Isearch+
offers these possibilities:

* Set the region around the last search hit visited:
  option `isearchp-set-region-flag', toggle with
  `M-s M-SPC'.  (_After_ searching you can also use
  command `isearchp-set-region-around-search-target'
  to set the region.)

* Restrict search to the active region: option
  `isearchp-restrict-to-region-flag', toggle with
  `C-x n'.  Vanilla Emacs has this for query-replace
  but not for Isearch.

  Restriction of searching to the active region works
  also for a rectangular region.

* Option `isearchp-deactivate-region-flag': whether to
  deactivate the region during searching (e.g. for
  better visibility)

If you use also library `isearch-prop.el' then you
can use command `isearchp-put-prop-on-region' to add
any text property to the region.  This gives you an
easy way to set up contexts for text-property search
(which is provided by that library).  For property
`face', empty input to `isearchp-put-prop-on-region'
removes all faces from the region.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: isearch and region ?
  2017-11-07 15:26     ` Drew Adams
@ 2017-11-07 15:54       ` Jean-Christophe Helary
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe Helary @ 2017-11-07 15:54 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]



> On Nov 8, 2017, at 0:26, Drew Adams <drew.adams@oracle.com> wrote:
> 
> You don't need to have the search hit be selected as the
> active region; you just need to act on it.

That's correct. I am just confused by the fact that the hit looks like a region and does not behave like one.
But then I don't know what kind of object a hit must be to be able to be acted upon. I just don't know enough about emacs.


Jean-Christophe Helary
-----------------------------------------------
@brandelune http://mac4translators.blogspot.com



[-- Attachment #2: Type: text/html, Size: 2993 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-07 15:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-07  7:39 isearch and region ? Jean-Christophe Helary
2017-11-07  8:31 ` Yuri Khan
2017-11-07  9:08   ` Jean-Christophe Helary
2017-11-07 15:26     ` Drew Adams
2017-11-07 15:54       ` Jean-Christophe Helary
2017-11-07  9:13 ` Damien Wyart

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).