From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: isearch hooks Date: Tue, 22 Jun 2004 00:56:08 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <873c4o60ef.fsf@mail.jurta.org> References: <20040528.181649.25475113.wl@gnu.org> <200405291737.i4THbPJ06689@raven.dms.auburn.edu> <878yeyczec.fsf@mail.jurta.org> <87n03aa4jk.fsf@mail.jurta.org> <87d63wy6ux.fsf_-_@mail.jurta.org> <87smcro0nx.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1087855461 22047 80.91.224.253 (21 Jun 2004 22:04:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 21 Jun 2004 22:04:21 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jun 22 00:04:06 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BcWta-0005F9-00 for ; Tue, 22 Jun 2004 00:04:06 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BcWta-0000kY-00 for ; Tue, 22 Jun 2004 00:04:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BcWuq-0000zG-Tj for emacs-devel@quimby.gnus.org; Mon, 21 Jun 2004 18:05:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BcWui-0000yH-96 for emacs-devel@gnu.org; Mon, 21 Jun 2004 18:05:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BcWug-0000wd-Ew for emacs-devel@gnu.org; Mon, 21 Jun 2004 18:05:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BcWug-0000wW-Bt for emacs-devel@gnu.org; Mon, 21 Jun 2004 18:05:14 -0400 Original-Received: from [66.33.219.19] (helo=spoon.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BcWtA-0005aj-8i; Mon, 21 Jun 2004 18:03:40 -0400 Original-Received: from mail.jurta.org (80-235-41-86-dsl.mus.estpak.ee [80.235.41.86]) by spoon.dreamhost.com (Postfix) with ESMTP id 27B9613D95E; Mon, 21 Jun 2004 15:03:33 -0700 (PDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sun, 20 Jun 2004 15:18:49 -0400") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25163 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25163 Richard Stallman 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 result. 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: (progn (set (make-local-variable 'isearch-search-fun-function) (lambda () (lambda (regexp bound noerror) (condition-case nil (progn (Info-search regexp bound noerror nil (unless isearch-forward 'backward)) (setq isearch-cmds nil isearch-opoint (point)) (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 http://www.jurta.org/emacs/