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: Mon, 28 Jun 2004 01:34:59 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87y8m8mv6l.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> <873c4o60ef.fsf@mail.jurta.org> <87y8mba4us.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 1088380394 7311 80.91.224.253 (27 Jun 2004 23:53:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 27 Jun 2004 23:53:14 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Jun 28 01:53:04 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 1BejSK-0000T4-00 for ; Mon, 28 Jun 2004 01:53:04 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BejSK-0000lY-00 for ; Mon, 28 Jun 2004 01:53:04 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BejTu-0006KX-Ca for emacs-devel@quimby.gnus.org; Sun, 27 Jun 2004 19:54:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BejTm-0006KC-3a for emacs-devel@gnu.org; Sun, 27 Jun 2004 19:54:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BejTk-0006Jt-G2 for emacs-devel@gnu.org; Sun, 27 Jun 2004 19:54:33 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BejTk-0006Jq-CL for emacs-devel@gnu.org; Sun, 27 Jun 2004 19:54:32 -0400 Original-Received: from [66.33.219.19] (helo=spoon.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BejRV-0001SO-L9; Sun, 27 Jun 2004 19:52:14 -0400 Original-Received: from mail.jurta.org (80-235-35-74-dsl.mus.estpak.ee [80.235.35.74]) by spoon.dreamhost.com (Postfix) with ESMTP id D4EF013D8F1; Sun, 27 Jun 2004 16:51:59 -0700 (PDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sun, 27 Jun 2004 13:41:44 -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:25282 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25282 Richard Stallman writes: > I added two new hooks: `isearch-push-state-function' and > `isearch-pop-state-function' to save/restore the current Info file > and node names in the search status stack. > > I don't understand the motivation for these two hooks. > Would you please explain the idea of this design? > Why is this the right way to extend Isearch? The commands that move the point back to the previous search result restore the previous point by setting it by `goto-char' to the position saved in the search status stack `isearch-cmds'. But this doesn't work when the current search buffer switches during the search like with changing the current Info node. There is a need to save additional information to the search stack to be able to restore the current search buffer to its previous state. In case of Info this means going to the Info node where the previous search point was located. The hook `isearch-push-state-function' returns additional information appended to the element of the search status stack. And `isearch-pop-state-function' calls the function to restore the current buffer to its previous state. Perhaps even one hook that adds to the stack a function to restore the current search buffer would be enough. For example, (defun Info-isearch-push-state-function () `(lambda () (Info-find-node ,Info-current-file ,Info-current-node) (goto-char (car (cdr (cdr cmd)))))) will add a lambda expression as 12-th element of the list pushed to the stack and which can be called later to restore the previous Info node. I don't know what is more preferable: two hooks or one hook with lambda. -- Juri Linkov http://www.jurta.org/emacs/