[Top][All Lists]

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

Re: isearch hooks

From: Juri Linkov
Subject: Re: isearch hooks
Date: Tue, 22 Jun 2004 00:56:08 +0300
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Richard Stallman <address@hidden> writes:
> The function that isearch-search-fun specifies can do all of those jobs.
> Do you see what I mean?

I see what you mean.  The difference basically boils down to two
questions: what is the scope of the search without failing, and
what is wrapping?

In the initial proposal the search scope is restricted to the current
Info node, and wrapping is going to the next Info node with the search

In the solution you suggested with `isearch-search-fun' the search
scope is the whole Info manual.  But even in this case a wrapping
hook is still needed: it should wrap the failed search to the
top/final Info node.

So basically settings for Info mode could look like this:

  (set (make-local-variable 'isearch-search-fun-function)
       (lambda ()
         (lambda (regexp bound noerror)
           (condition-case nil
                 (Info-search regexp bound noerror nil
                              (unless isearch-forward 'backward))
                 (setq isearch-cmds nil isearch-opoint (point))
             (error nil)))))
  (add-hook 'isearch-wrap-functions
            (lambda () (if isearch-forward (Info-top-node) (Info-final-node)))
            nil t))

There were some problems with this approach: lazy highlighting uses
the same function `isearch-search-fun' to highlight other matches.
I modified `Info-search' to accept the `bound' argument to restrict
the highlighting search to the window bounds, and made it faster by
not refontifying the current Info node if the next search result is
in the same node.

Other problems like with `Info-final-node' that returns the node which
is not quite final for `Info-search', could be fixed later if this
solution is ok.

There are some inconveniences: the user can't delete the last input
by DEL and can't return the point to the search beginning by cancelling
the search with C-g.  But that's not a big problem: the user can use
C-r to return to the previous search results.

Juri Linkov

reply via email to

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