unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* be able to replace during isearch
@ 2007-07-01  1:07 Drew Adams
  2007-07-01 13:37 ` Mathias Dahl
  2007-07-01 20:59 ` Juri Linkov
  0 siblings, 2 replies; 5+ messages in thread
From: Drew Adams @ 2007-07-01  1:07 UTC (permalink / raw)
  To: Emacs-Devel

I have this feature in Icicles search, but the idea is not dependent on
Icicles. I think that a feature like this would also be useful to add to
isearch.

The idea is that you would not need to leave isearch to perform
replacements. Whenever you wanted to replace the current search occurrence,
you would hit a certain key. The first time you do this, you would be asked
for the replacement string.

The main advantage, besides not needing to exit isearch, is that instead of
being queried for each potential replacement, one by one, you replace only
those you want upon demand. You might not even have the intention of
performing replacement until you happened to notice, while searching, that
you wanted to change something. A minor advantage is that you can also
search-and-replace backward.

Nice-to-haves: In Icicles search, you can use any replacement expression
that is accepted by `query-replace-regexp', and there are additional key
bindings during search to (1) replace all and (2) redefine the replacement
to use. These would also be useful additions for isearch.

I'm not suggesting this as a replacement(!) for query-replace, but as an
enhancement to isearch. Query-replace is a different UI, and each has its
advantages.

Here is a bit more explanation of this feature in Icicles, but, as I say,
the idea is not Icicles-specific:
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Search-And-Replace.

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

* Re: be able to replace during isearch
  2007-07-01  1:07 be able to replace during isearch Drew Adams
@ 2007-07-01 13:37 ` Mathias Dahl
  2007-07-01 14:02   ` Drew Adams
  2007-07-01 20:59 ` Juri Linkov
  1 sibling, 1 reply; 5+ messages in thread
From: Mathias Dahl @ 2007-07-01 13:37 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs-Devel

> The idea is that you would not need to leave isearch to perform
> replacements. Whenever you wanted to replace the current search occurrence,
> you would hit a certain key. The first time you do this, you would be asked
> for the replacement string.

I would like this, I remember thinking about this while iseaching some
time back. Would it also be possible to have a key that asks for
another replacement to be used for later replacements if I am not
happy with the previous one I entered? I might want to replace X with
Y in one place and with Z in another.

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

* RE: be able to replace during isearch
  2007-07-01 13:37 ` Mathias Dahl
@ 2007-07-01 14:02   ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2007-07-01 14:02 UTC (permalink / raw)
  To: Emacs-Devel; +Cc: Mathias Dahl

> > The idea is that you would not need to leave isearch to perform
> > replacements. Whenever you wanted to replace the current search
> > occurrence, you would hit a certain key. The first time you do
> > this, you would be asked for the replacement string.
>
> I would like this, I remember thinking about this while iseaching some
> time back. Would it also be possible to have a key that asks for
> another replacement to be used for later replacements if I am not
> happy with the previous one I entered? I might want to replace X with
> Y in one place and with Z in another.

That's just what I meant by one of the nice-to-haves (2): "redefine the
replacement":

> > Nice-to-haves: In Icicles search, you can use any replacement expression
> > that is accepted by `query-replace-regexp', and there are additional key
> > bindings during search to (1) replace all and (2) redefine the
> > replacement to use. These would also be useful additions for isearch.

In Icicles, for instance, there is a key to define the replacement string,
which you can hit at any time. It prompts you for the replacement to use.
Hitting it is implied the first time you hit the key to perform the
replacement.

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

* Re: be able to replace during isearch
  2007-07-01  1:07 be able to replace during isearch Drew Adams
  2007-07-01 13:37 ` Mathias Dahl
@ 2007-07-01 20:59 ` Juri Linkov
  2007-07-01 22:37   ` Drew Adams
  1 sibling, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2007-07-01 20:59 UTC (permalink / raw)
  To: Drew Adams; +Cc: emacs-devel

> The idea is that you would not need to leave isearch to perform
> replacements. Whenever you wanted to replace the current search occurrence,
> you would hit a certain key. The first time you do this, you would be asked
> for the replacement string.

I imagine this could be like typing `R' during ispell-checking.

-- 
Juri Linkov
http://www.jurta.org/emacs/

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

* RE: be able to replace during isearch
  2007-07-01 20:59 ` Juri Linkov
@ 2007-07-01 22:37   ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2007-07-01 22:37 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

> > The idea is that you would not need to leave isearch to perform
> > replacements. Whenever you wanted to replace the current search
> > occurrence, you would hit a certain key. The first time you do
> > this, you would be asked for the replacement string.
>
> I imagine this could be like typing `R' during ispell-checking.

Dunno, I've never used that. The Emacs manual, however, says this:

 `R NEW <RET>'
     Replace the word with NEW, and do a `query-replace' so you can
     replace it elsewhere in the buffer if you wish.  (The replacements
     will be rescanned for more spelling errors.)

If `R' does indeed activate `query-replace', then no, what I propose is very
different.

In my proposal, you never enter `query-replace', and you never leave
isearch. There are simply two additional isearch key bindings, one to prompt
for and read a replacement string (expression) and the other to replace the
current search hit with that replacement.

In Icicles, these two keys are `M-,' and `C-S-RET' (or `C-S-mouse-2' or
`C-S-next' etc., depending on what you want done after the replacement), but
in isearch they should be something more appropriate for isearch.

In my proposal, you are never queried to replace anything. Instead, you
replace a search hit only upon demand, by hitting the replace key (e.g.
`C-S-RET'). If you never hit that key, then there is no replacement. There
is never any querying for replacement.

You only use the `M-,' (or equivalent) binding if you want to change the
current replacement string during the same invocation of isearch. The first
time you hit the replace key (e.g. `C-S-RET'), there is an implicit call to
`M-,' to read the replacement string.

You can think of the correspondence to `query-replace' this way:

* Instead of `query-replace' automatically moving to the next match, you
must hit `C-s'.

* Instead of hitting `y' or `n', you hit the replace key (e.g. `C-S-RET') or
you do nothing (for `n').

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

end of thread, other threads:[~2007-07-01 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-01  1:07 be able to replace during isearch Drew Adams
2007-07-01 13:37 ` Mathias Dahl
2007-07-01 14:02   ` Drew Adams
2007-07-01 20:59 ` Juri Linkov
2007-07-01 22:37   ` Drew Adams

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).