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: Loris Bennett
Subject: Re: killing the result of isearch
Date: Tue, 07 Nov 2017 08:07:54 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux)

Søren Pilgård <fiskomaten@gmail.com> writes:

> On Nov 7, 2017 7:04 AM, "Jean-Christophe Helary" <
> jean.christophe.helary@gmail.com> wrote:
>
>
>
>> 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?

I can sort of imagine that such a function might be useful, but in
several decades of using Emacs, both writing code and prose, I've
honestly never missed it.  What is your use case?  The closest I come is
search and replace, so you could just replace with an empty string.
However, searching and then doing 'C-backspace' deletes the word found
on my system.

Cheers,

Loris

> 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
>
>
> You could just use the query-replace functionality with an empty string.

-- 
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universität Berlin         Email loris.bennett@fu-berlin.de


reply via email to

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