From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: isearch-forward and Info-search Date: Sat, 12 Mar 2005 04:23:19 +0200 Organization: JURTA Message-ID: <87vf7xr1gm.fsf@jurta.org> References: <16942.42643.503788.488893@farnswood.snap.net.nz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110600296 30226 80.91.229.2 (12 Mar 2005 04:04:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 12 Mar 2005 04:04:56 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 12 05:04:55 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D9xrt-0002NN-Ld for ged-emacs-devel@m.gmane.org; Sat, 12 Mar 2005 05:04:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9y76-00043p-AX for ged-emacs-devel@m.gmane.org; Fri, 11 Mar 2005 23:20:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D9y4V-0002AN-Ir for emacs-devel@gnu.org; Fri, 11 Mar 2005 23:17:51 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D9y4J-00024s-N8 for emacs-devel@gnu.org; Fri, 11 Mar 2005 23:17:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9y4I-0001vw-IO for emacs-devel@gnu.org; Fri, 11 Mar 2005 23:17:38 -0500 Original-Received: from [194.126.101.111] (helo=MXR-3.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1D9xWB-0007jG-K1 for emacs-devel@gnu.org; Fri, 11 Mar 2005 22:42:24 -0500 Original-Received: from mail.neti.ee (80-235-33-80-dsl.mus.estpak.ee [80.235.33.80]) by MXR-3.estpak.ee (Postfix) with ESMTP id A021713D725; Sat, 12 Mar 2005 05:42:20 +0200 (EET) Original-To: Nick Roberts In-Reply-To: <16942.42643.503788.488893@farnswood.snap.net.nz> (Nick Roberts's message of "Wed, 9 Mar 2005 20:32:35 +1300") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org X-MailScanner-To: ged-emacs-devel@m.gmane.org Xref: news.gmane.org gmane.emacs.devel:34503 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34503 Below is an implementation that works as follows: after an attempt to leave the first Info node, isearch fails with the following message: Failing I-search: search string [failed in current node] After leaving the first Info node with subsequent C-s or C-r, isearch doesn't fail more in other Info nodes. In the end/beginning of the manual isearch fails with the usual message: Failing I-search: search string After the next C-s/C-r it wraps to the top/final node. In the implementation below it would be possible to reuse `isearch-invalid-regexp' to hold the error message, but this is not a clean solution. Adding a new special variable `isearch-error' looks better. When set to a string value it adds the error message in square brackets to the end of the echo area. `isearch-error' is set in `isearch-search' via the second argument of the `search-failed' signal (its first argument is the failed search string). Index: lisp/isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.256 diff -u -r1.256 isearch.el --- lisp/isearch.el 19 Feb 2005 20:52:47 -0000 1.256 +++ lisp/isearch.el 12 Mar 2005 02:22:55 -0000 @@ -438,6 +438,7 @@ (defvar isearch-message "") ; text-char-description version of isearch-string (defvar isearch-success t) ; Searching is currently successful. +(defvar isearch-error nil) ; Error message for failed search. (defvar isearch-invalid-regexp nil) ; Regexp not well formed. (defvar isearch-within-brackets nil) ; Regexp has unclosed [. (defvar isearch-other-end nil) ; Start (end) of match if forward (backward). @@ -1146,10 +1147,11 @@ ;; If already have what to search for, repeat it. (or isearch-success (progn + ;; Set isearch-wrapped before calling isearch-wrap-function + (setq isearch-wrapped t) (if isearch-wrap-function (funcall isearch-wrap-function) - (goto-char (if isearch-forward (point-min) (point-max)))) - (setq isearch-wrapped t)))) + (goto-char (if isearch-forward (point-min) (point-max))))))) ;; C-s in reverse or C-r in forward, change direction. (setq isearch-forward (not isearch-forward))) @@ -1384,6 +1386,7 @@ (min isearch-opoint isearch-barrier)))) (progn (setq isearch-success t + isearch-error nil isearch-invalid-regexp nil isearch-within-brackets nil isearch-other-end (match-end 0)) @@ -2013,6 +2016,9 @@ (concat (if c-q-hack "^Q" "") (if isearch-invalid-regexp (concat " [" isearch-invalid-regexp "]") + "") + (if (and (not isearch-success) isearch-error) + (concat " [" isearch-error "]") ""))) @@ -2050,7 +2056,7 @@ (search-spaces-regexp search-whitespace-regexp) (retry t)) (if isearch-regexp (setq isearch-invalid-regexp nil)) - (setq isearch-within-brackets nil) + (setq isearch-within-brackets nil isearch-error nil) (while retry (setq isearch-success (funcall @@ -2081,6 +2087,11 @@ "\\`Premature \\|\\`Unmatched \\|\\`Invalid " isearch-invalid-regexp) (setq isearch-invalid-regexp "incomplete input"))) + + (search-failed + (setq isearch-success nil) + (setq isearch-error (nth 2 lossage))) + (error ;; stack overflow in regexp search. (setq isearch-invalid-regexp (format "%s" lossage)))) Index: lisp/info.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/info.el,v retrieving revision 1.419 diff -u -r1.419 info.el --- lisp/info.el 12 Mar 2005 02:18:32 -0000 1.419 +++ lisp/info.el 12 Mar 2005 02:22:18 -0000 @@ -1514,6 +1514,13 @@ (setq found (point) beg-found (if backward (match-end 0) (match-beginning 0))) (setq give-up t)))))) + + (when (and Info-isearch-search isearch-mode + (not Info-isearch-first-node) + (or give-up (and found (not (and (> found opoint-min) + (< found opoint-max)))))) + (signal 'search-failed (list regexp "failed in current node"))) + ;; If no subfiles, give error now. (if give-up (if (null Info-current-subfile) @@ -1650,25 +1657,28 @@ (defun Info-isearch-search () (if Info-isearch-search (lambda (string &optional bound noerror count) - (condition-case nil - (if isearch-word - (Info-search (concat "\\b" (replace-regexp-in-string - "\\W+" "\\\\W+" - (replace-regexp-in-string - "^\\W+\\|\\W+$" "" string)) "\\b") - bound noerror count - (unless isearch-forward 'backward)) - (Info-search (if isearch-regexp string (regexp-quote string)) - bound noerror count - (unless isearch-forward 'backward)) - (point)) - (error nil))) + (if isearch-word + (Info-search (concat "\\b" (replace-regexp-in-string + "\\W+" "\\\\W+" + (replace-regexp-in-string + "^\\W+\\|\\W+$" "" string)) "\\b") + bound noerror count + (unless isearch-forward 'backward)) + (Info-search (if isearch-regexp string (regexp-quote string)) + bound noerror count + (unless isearch-forward 'backward)) + (point))) (let ((isearch-search-fun-function nil)) (isearch-search-fun)))) (defun Info-isearch-wrap () - (when Info-isearch-search - (if isearch-forward (Info-top-node) (Info-final-node)) + (if Info-isearch-search + (if Info-isearch-first-node + (progn + (if isearch-forward (Info-top-node) (Info-final-node)) + (goto-char (if isearch-forward (point-min) (point-max)))) + (setq Info-isearch-first-node Info-current-node) + (setq isearch-wrapped nil)) (goto-char (if isearch-forward (point-min) (point-max))))) (defun Info-isearch-push-state () @@ -1680,6 +1690,9 @@ (string= Info-current-node node)) (progn (Info-find-node file node) (sit-for 0)))) +(defvar Info-isearch-first-node nil) +(defun Info-isearch-start () + (setq Info-isearch-first-node nil)) (defun Info-extract-pointer (name &optional errorname) "Extract the value of the node-pointer named NAME. @@ -3217,6 +3230,7 @@ (setq desktop-save-buffer 'Info-desktop-buffer-misc-data) (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t) (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) + (add-hook 'isearch-mode-hook 'Info-isearch-start nil t) (set (make-local-variable 'isearch-search-fun-function) 'Info-isearch-search) (set (make-local-variable 'isearch-wrap-function) -- Juri Linkov http://www.jurta.org/emacs/