[Top][All Lists]

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

RE: killing the result of isearch

From: Drew Adams
Subject: RE: killing the result of isearch
Date: Tue, 7 Nov 2017 08:46:45 -0800 (PST)

> > It does result in an object you can act upon, if you want
> > that.
> Would you mind being more specific ?

The code finds a match (over and over: successive matches).
Code (hence you) can act on the current match.  Or code/you
can act on only the last match that you visit.

Everything you need to code the feature you ask for is in the
Isearch source code.  If you don't want to dig into that code
yourself, you're lucky: Isearch+ already provides what you need:

1. A variable whose value can be any function you want,
   tailor-made to act on any current match when you hit a key.

   Write any number of commands, which bind that variable
   to different action functions.  Bind those commands to
   keys in `isearch-mode-map'.  Now you have N keys you can
   hit to perform N different actions on a search hit.
   Pretty good, no?

2. As for acting on the last-visited match, after searching:
   Isearch+ lets you automatically, or on-demand, select it
   as the active region.  You can then use any Emacs command
   that acts on the active region to act on it.  And you can
   define your own such commands, to act on it any way you like.

Be aware too that after you exit Isearch, you can always use
the many Emacs commands that act on text before point or that
move point backward.  There is a lot you can do to the text
before point, even without selecting the part that matches
your last search.  Emacs has commands for moving among and
killing sexps, for example.

> I have no problem using new libraries, but I want to understand why I am
> missing what I think I am missing. If I understood searches (isearches ?)
> better, maybe I would not have my questions.

You are missing what you think you are missing from vanilla
Emacs.  Why?  Because either (1) no one has considered them
important/useful enough to add or (2) no one has volunteered
to work on implementing them.

Emacs is developed by volunteers.  Features are added to it
when its core developers decide to do so.  There are tons
of wonderful Emacs features that have not been incorporated
into vanilla Emacs.  Sometimes that's good; sometimes it's
not so good.  What gets done in vanilla Emacs is a function
of those who contribute directly to its development.  They
do what they want (think is best), naturally.

I think that lots of features that Isearch+ provides, perhaps
all, would make sense in vanilla Emacs.  I've volunteered them.
But it's not for me to decide.

In any case, you can use them now - easily.  You don't need
them to be added to vanilla Emacs to take advantage of them.

Above is just my answer to your "Why not?" question.  What
you're looking for is not part of Emacs by default because
those who maintain Emacs haven't added it - nothing more.
That doesn't mean you're not understanding something, and
it doesn't imply that they're not understanding something.
People are different.

> > Q-r is nice, and it's good you can invoke it from Isearch,
> > but it is not the same thing as on-demand replacement
> > during search.
> Exactly.

reply via email to

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