From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#11378: 24.1.50; Suggestion: Let M-i in isearch cycle `search-invisible' Date: Tue, 12 Jun 2012 02:44:17 +0300 Organization: JURTA Message-ID: <87lijtcx8m.fsf@mail.jurta.org> References: <87haw32hly.fsf@web.de> <87397m6oxf.fsf@mail.jurta.org> <87y5pcdzxx.fsf@mail.jurta.org> <874nqzgcuk.fsf@mail.jurta.org> <87vcjesccy.fsf@mail.jurta.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1339462001 25687 80.91.229.3 (12 Jun 2012 00:46:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 12 Jun 2012 00:46:41 +0000 (UTC) Cc: 11378@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 12 02:46:36 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SeFFd-0005BJ-Ai for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Jun 2012 02:46:29 +0200 Original-Received: from localhost ([::1]:46403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeFFd-00068P-57 for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Jun 2012 20:46:29 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeFFZ-000677-QG for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2012 20:46:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeFFX-0000ce-Hh for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2012 20:46:25 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeFFX-0000cZ-E0 for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2012 20:46:23 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SeFI6-0004lz-45 for bug-gnu-emacs@gnu.org; Mon, 11 Jun 2012 20:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 12 Jun 2012 00:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11378 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11378-submit@debbugs.gnu.org id=B11378.133946213018314 (code B ref 11378); Tue, 12 Jun 2012 00:49:02 +0000 Original-Received: (at 11378) by debbugs.gnu.org; 12 Jun 2012 00:48:50 +0000 Original-Received: from localhost ([127.0.0.1]:38518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeFHu-0004lL-68 for submit@debbugs.gnu.org; Mon, 11 Jun 2012 20:48:50 -0400 Original-Received: from ps18281.dreamhost.com ([69.163.218.105]:50552 helo=ps18281.dreamhostps.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SeFHr-0004lD-RM for 11378@debbugs.gnu.org; Mon, 11 Jun 2012 20:48:49 -0400 Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7F520451C9B1; Mon, 11 Jun 2012 17:46:06 -0700 (PDT) In-Reply-To: <87vcjesccy.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 30 May 2012 03:40:05 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60881 Archived-At: > Anyway I intend to rewrite the filter `isearch-filter-visible' to just > check if the text is visible. The code that opens overlays should be > moved to the main search loop to work independently from the filter. I believe the following patch implements the correct interaction of filter predicates with search-invisible. It also removes `isearch-filter-visible' from the default value of `isearch-filter-predicates' because in the current implementation `isearch-filter-visible' in the list of filters makes no sense since it can't be removed from the filter list. Removing it from the list with the intention to find hidden matches won't open overlays with hidden text ignoring the value of `search-invisible'. This requires moving the `isearch-range-invisible' call to the main search loop, just after running hook-with-args with `isearch-filter-predicates'. There is one remaining question: do we still need a filter for visible text? Such filter could just check if the match is visible, but it should not open overlays. This can be implemented like: (defun isearch-filter-visible (beg end) (let ((search-invisible nil)) (not (isearch-range-invisible beg end)))) Adding this filter to `isearch-filter-predicates' will skip hidden text, removing it will find matches in hidden text (and the main search loop will open overlays). But apparently this filter is not necessary, because handling of hidden text (depending on the customizable `search-invisible') will be moved to the main search loop. So the question is whether a new command to toggle searching hidden text should add/remove `isearch-filter-visible' from `isearch-filter-predicates', or just change the value of `search-invisible'. I guess to change the value of `search-invisible' (defined by `defcustom') with a new toggling command is not the right way to change the value of customizable variables (or maybe not). OTOH, `isearch-range-invisible' might be called twice: one call from `isearch-filter-visible' and another from the main search loop, and this is not optimal. Anyway below is the patch that should work for a list of filters other than `isearch-filter-visible': === modified file 'lisp/isearch.el' --- lisp/isearch.el 2012-05-29 09:46:06 +0000 +++ lisp/isearch.el 2012-06-11 23:34:18 +0000 @@ -179,12 +179,15 @@ (defvar isearch-push-state-function nil "Function to save a function restoring the mode-specific Isearch state to the search status stack.") -(defvar isearch-filter-predicate 'isearch-filter-visible - "Predicate that filters the search hits that would normally be available. -Search hits that dissatisfy the predicate are skipped. The function -has two arguments: the positions of start and end of text matched by -the search. If this function returns nil, continue searching without -stopping at this match.") +(defvar isearch-filter-predicates nil + "Predicates that filter the search hits that would normally be available. +Search hits that dissatisfy the list of predicates are skipped. +Each function in this list has two arguments: the positions of +start and end of text matched by the search. +If `run-hook-with-args-until-failure' returns nil for all predicates, +continue searching without stopping at this match. +The property `isearch-message-prefix' put on the predicate's symbol +specifies the prefix string displyed in the search message.") ;; Search ring. @@ -2509,8 +2553,15 @@ (defun isearch-search () (if (or (not isearch-success) (bobp) (eobp) (= (match-beginning 0) (match-end 0)) - (funcall isearch-filter-predicate - (match-beginning 0) (match-end 0))) + ;; When one of filter predicates returns nil, + ;; retry the search. Otherwise, act according + ;; to search-invisible (open overlays, etc.) + (and (run-hook-with-args-until-failure + 'isearch-filter-predicates + (match-beginning 0) (match-end 0)) + (or (eq search-invisible t) + (not (isearch-range-invisible + (match-beginning 0) (match-end 0)))))) (setq retry nil))) (setq isearch-just-started nil) (if isearch-success @@ -2873,7 +2964,6 @@ (defun isearch-lazy-highlight-search () (isearch-regexp isearch-lazy-highlight-regexp) (search-spaces-regexp isearch-lazy-highlight-space-regexp) (isearch-word isearch-lazy-highlight-word) - (search-invisible nil) ; don't match invisible text (retry t) (success nil) (isearch-forward isearch-lazy-highlight-forward) @@ -2895,8 +2985,13 @@ (defun isearch-lazy-highlight-search () (if (or (not success) (= (point) bound) ; like (bobp) (eobp) in `isearch-search'. (= (match-beginning 0) (match-end 0)) - (funcall isearch-filter-predicate - (match-beginning 0) (match-end 0))) + (and (run-hook-with-args-until-failure + 'isearch-filter-predicates + (match-beginning 0) (match-end 0)) + ;; Don't match invisible text. + (let ((search-invisible nil)) + (not (isearch-range-invisible + (match-beginning 0) (match-end 0)))))) (setq retry nil))) success) (error nil)))