help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: killing the result of isearch


From: Jean-Christophe Helary
Subject: Re: killing the result of isearch
Date: Tue, 7 Nov 2017 15:01:19 +0900


> On Nov 7, 2017, at 14:34, Drew Adams <drew.adams@oracle.com> wrote:
> 
>> I must be missing something big...
> 
> No, you're not.

I'm not sure that makes me feel better... But that you very much for the 
thorough reply.

>> I have an isearch that highlights a string, and I just want to delete that 
>> string.
>> 
>> In other editors I'd just hit delete on that selection, but that won't work 
>> in emacs...
> 
> Not in vanilla Emacs, no; it won't work.

> If you use Isearch+

Is there a way to emulate that in vanilla emacs?
Well, I guess yes, by creating the adequate function, etc.

But, isn't it something emacs users do normally? Search for a string and just 
delete it? Doesn't it look like a function that could be useful in vanilla 
emacs?

Jean-Christophe 

> then you can hit `C-M-RET' to delete the
> search hit.  (The current search hit is not the "selection",
> BTW, in the sense of being the Emacs region.)
> 
> [If you prefer that the key for this be, say, the `<delete>'
> key, then just bind command `isearchp-act-on-demand' to
> `(kbd "<delete>")' in `isearch-mode-map'.]
> 
> With Isearch+, `C-M-RET' performs an action on the current
> search hit.  By default, the action is to replace it with
> some replacement text.  And by default that replacement
> text is empty (""), i.e., the search hit is deleted.
> 
> The value of option `isearchp-on-demand-action-function'
> is the function that acts on the current search hit, which
> it is passed when you hit `C-M-RET', along with the buffer
> start and end positions of the search hit.
> 
> After applying the action, search moves to the next hit in
> the same search direction, so just repeating `C-M-RET'
> carries out the action on subsequent hits.
> 
> With a prefix argument, `C-M-RET'  prompts for the
> replacement text, which is used thereafter until you again
> use a prefix arg.  (Again, no prefix arg means empty
> replacement text, i.e., deletion.)
> 
> Since you can use a prefix arg at any time, you can
> provide different replacements for different search hits
> corresponding to the same search pattern.
> 
> [To use a prefix arg within Isearch, you must set
> `isearch-allow-prefix' to non-`nil'.]
> 
> There's more you can do with it.  See here:
> 
> https://www.emacswiki.org/emacs/IsearchPlus#isearchp-act-on-demand
> 

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




reply via email to

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