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: Type Ahead Find Date: Sun, 20 Mar 2005 22:19:48 +0200 Organization: JURTA Message-ID: <87u0n6xenn.fsf@jurta.org> References: <87k6o4eo2u.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1111352800 8262 80.91.229.2 (20 Mar 2005 21:06:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 20 Mar 2005 21:06:40 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 20 22:06:40 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DD7d5-0004gr-EW for ged-emacs-devel@m.gmane.org; Sun, 20 Mar 2005 22:06:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DD7u3-0008Oq-0K for ged-emacs-devel@m.gmane.org; Sun, 20 Mar 2005 16:24:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DD7oG-0007uc-4g for emacs-devel@gnu.org; Sun, 20 Mar 2005 16:18:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DD7o7-0007qQ-Eb for emacs-devel@gnu.org; Sun, 20 Mar 2005 16:18:01 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DD7o2-0007kz-58 for emacs-devel@gnu.org; Sun, 20 Mar 2005 16:17:54 -0500 Original-Received: from [194.126.101.98] (helo=MXR-5.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DD7Fh-00052U-Jo; Sun, 20 Mar 2005 15:42:25 -0500 Original-Received: from mail.neti.ee (80-235-41-70-dsl.mus.estpak.ee [80.235.41.70]) by MXR-5.estpak.ee (Postfix) with ESMTP id D991912C9D8; Sun, 20 Mar 2005 22:42:23 +0200 (EET) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Sat, 19 Mar 2005 19:22:11 -0500") 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:34842 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34842 Richard Stallman writes: > But it allows to narrow the search only > to specific text part (such as e.g. in Firefox typing a ' before the > search string searches only links) which is currently not easily > implementable in Emacs. > > Making such a feature useful, and not intolerable, in the context > of Emacs is not a simple matter. I think I'd rather turn off any > feature that makes some printing characters special in isearch. The change I proposed has nothing to do with making some characters special in isearch. > Please let's not think about this now. If you'd like to work > on new features for after the release, how about implementing > some of the features listed in etc/TODO? This is not a new feature. This is the change very closely related to other recent fixes in isearch.el. I want to finish all fixes related to isearch.el before the next release. Essentially, my proposed change is to make configurable the currently hard-coded constraint imposed by `isearch-range-invisible' in `isearch-search'. The new variable `isearch-success-function' will allow to override it with a user-defined function. Also in the course of preparing this change I noticed some problems in isearch.el related to searching of invisible text: The lazy highlighting feature creates overlays even for matches inside invisible texts. A solution is to create a loop similar to the while-loop in `isearch-search', but instead of `isearch-range-invisible' (which also opens invisible overlays) to use the following condition in `isearch-lazy-highlight-search': (text-property-any (match-beginning 0) (match-end 0) 'invisible nil) This condition seems to be more correct even if it lazy-highlights partly hidden matches. An alternative condition (not (text-property-not-all (match-beginning 0) (match-end 0) 'invisible nil)) that lazy-highlights a match only if it is fully visible, doesn't follow the logic of `isearch-range-invisible' used in `isearch-search' which matches partly invisible text. The current version of a patch is below: Index: lisp/isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.261 diff -u -w -b -r1.261 isearch.el --- lisp/isearch.el 18 Mar 2005 09:59:31 -0000 1.261 +++ lisp/isearch.el 20 Mar 2005 20:03:07 -0000 @@ -165,6 +165,11 @@ "Function to save a function restoring the mode-specific isearch state to the search status stack.") +(defvar isearch-success-function nil + "Function to report whether the new search match is considered successful. +The function has two arguments: the positions of start and end of text +matched by search.") + ;; Search ring. (defvar search-ring nil @@ -2039,7 +2046,8 @@ (setq isearch-case-fold-search (isearch-no-upper-case-p isearch-string isearch-regexp))) (condition-case lossage - (let ((inhibit-point-motion-hooks search-invisible) + (let ((inhibit-point-motion-hooks + (and (not isearch-success-function) search-invisible)) (inhibit-quit nil) (case-fold-search isearch-case-fold-search) (search-spaces-regexp search-whitespace-regexp) @@ -2052,12 +2060,15 @@ isearch-string nil t)) ;; Clear RETRY unless we matched some invisible text ;; and we aren't supposed to do that. - (if (or (eq search-invisible t) - (not isearch-success) + (if (or (not isearch-success) (bobp) (eobp) (= (match-beginning 0) (match-end 0)) + (if isearch-success-function + (funcall isearch-success-function + (match-beginning 0) (match-end 0)) + (or (eq search-invisible t) (not (isearch-range-invisible - (match-beginning 0) (match-end 0)))) + (match-beginning 0) (match-end 0)))))) (setq retry nil))) (setq isearch-just-started nil) (if isearch-success @@ -2369,7 +2381,6 @@ isearch-lazy-highlight-window-end)))) ;; something important did indeed change (lazy-highlight-cleanup t) ;kill old loop & remove overlays - (when (not isearch-error) (setq isearch-lazy-highlight-start-limit beg isearch-lazy-highlight-end-limit end) (setq isearch-lazy-highlight-window (selected-window) @@ -2384,7 +2395,7 @@ (unless (equal isearch-string "") (setq isearch-lazy-highlight-timer (run-with-idle-timer lazy-highlight-initial-delay nil - 'isearch-lazy-highlight-update)))))) + 'isearch-lazy-highlight-update))))) (defun isearch-lazy-highlight-search () "Search ahead for the next or previous match, for lazy highlighting. @@ -2393,9 +2404,9 @@ (isearch-regexp isearch-lazy-highlight-regexp) (search-spaces-regexp search-whitespace-regexp)) (condition-case nil - (funcall (isearch-search-fun) - isearch-lazy-highlight-last-string - (if isearch-forward + (let ((retry t) + (success nil) + (bound (if isearch-forward (min (or isearch-lazy-highlight-end-limit (point-max)) (if isearch-lazy-highlight-wrapped isearch-lazy-highlight-start @@ -2403,8 +2414,22 @@ (max (or isearch-lazy-highlight-start-limit (point-min)) (if isearch-lazy-highlight-wrapped isearch-lazy-highlight-end - (window-start)))) - t) + (window-start)))))) + (while retry + (setq success + (funcall (isearch-search-fun) + isearch-lazy-highlight-last-string + bound t)) + (if (or (not success) + (eq (point) bound) + (if isearch-success-function + (funcall isearch-success-function + (match-beginning 0) (match-end 0)) + (text-property-any + (match-beginning 0) (match-end 0) + 'invisible nil))) + (setq retry nil))) + success) (error nil)))) (defun isearch-lazy-highlight-update () -- Juri Linkov http://www.jurta.org/emacs/