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: Todays exercise of sanity (or does "see" really match "not"?) Date: Tue, 22 Mar 2005 19:29:05 +0200 Organization: JURTA Message-ID: <87br9begh1.fsf@jurta.org> References: <002301c52e18$c9b014a0$0200a8c0@sedrcw11488> <200503211349.j2LDnxX12741@raven.dms.auburn.edu> <003401c52e20$d6f79c70$0200a8c0@sedrcw11488> <87hdj4vppf.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 1111513563 28903 80.91.229.2 (22 Mar 2005 17:46:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2005 17:46:03 +0000 (UTC) Cc: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 22 18:46:02 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DDnRt-0001Uj-0b for ged-emacs-devel@m.gmane.org; Tue, 22 Mar 2005 18:45:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DDnjD-0002zl-PT for ged-emacs-devel@m.gmane.org; Tue, 22 Mar 2005 13:03:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DDnbq-0004hh-En for emacs-devel@gnu.org; Tue, 22 Mar 2005 12:56:06 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DDnbm-0004fr-NB for emacs-devel@gnu.org; Tue, 22 Mar 2005 12:56:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DDnbm-0004ae-1Q for emacs-devel@gnu.org; Tue, 22 Mar 2005 12:56:02 -0500 Original-Received: from [194.126.101.98] (helo=MXR-4.estpak.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DDnHq-0000cs-K6; Tue, 22 Mar 2005 12:35:27 -0500 Original-Received: from mail.neti.ee (80-235-35-161-dsl.mus.estpak.ee [80.235.35.161]) by MXR-4.estpak.ee (Postfix) with ESMTP id F19ACC2B24; Tue, 22 Mar 2005 19:35:24 +0200 (EET) Original-To: David Kastrup In-Reply-To: (David Kastrup's message of "Tue, 22 Mar 2005 15:46:51 +0100") 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:34977 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:34977 David Kastrup writes: > Please don't. I can't see any advantage of breaking working packages > right now for no currently apparent significant practical advantage. I agree that handling the `display' property in a way similar to the `invisible' property could break existing packages. The rules for handling invisible text are quite complex and include invisibility specifications in `buffer-invisibility-spec'. Changing them to support the `display' property would be too drastic change. With the current code one of the following methods can be used to make isearch to skip text under the `display' property: 1. Set both `invisible' and `display' properties. It seems the display engine ignores the `invisible' property when the `display' property is present. But isearch still respects it. 2. Override the default `isearch-range-invisible' function with a new proposed variable `isearch-success-function'. In the patch below the second method is used. The default `Info-search-success-function' skips "*note" text under point. Everyone who wants to include "*note" to search results can override `isearch-success-function'. There are also two new variables `isearch-message-prefix-add' and `isearch-message-suffix-add' to allow adding arbitrary text to the isearch message's prefix and suffix (e.g. "X-Node"). Lazy highlighting code ignores both `invisible' and `display' properties, since I see no reason to lazy-highlight invisible text. Index: lisp/isearch.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/isearch.el,v retrieving revision 1.261 diff -u -r1.261 isearch.el --- lisp/isearch.el 18 Mar 2005 09:59:31 -0000 1.261 +++ lisp/isearch.el 22 Mar 2005 17:20:14 -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 @@ -445,6 +450,9 @@ (defvar isearch-just-started nil) (defvar isearch-start-hscroll 0) ; hscroll when starting the search. +(defvar isearch-message-prefix-add nil) +(defvar isearch-message-suffix-add nil) + ; case-fold-search while searching. ; either nil, t, or 'yes. 'yes means the same as t except that mixed ; case in the search string is ignored. @@ -640,6 +648,8 @@ isearch-adjusted nil isearch-yank-flag nil isearch-error nil + isearch-message-prefix-add nil + isearch-message-suffix-add nil isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed) (> (window-height) (* 4 @@ -1993,6 +2003,7 @@ (< (point) isearch-opoint))) "over") (if isearch-wrapped "wrapped ") + (or isearch-message-prefix-add "") (if isearch-word "word " "") (if isearch-regexp "regexp " "") (if nonincremental "search" "I-search") @@ -2008,7 +2019,8 @@ (concat (if c-q-hack "^Q" "") (if isearch-error (concat " [" isearch-error "]") - ""))) + "") + (or isearch-message-suffix-add ""))) ;; Searching @@ -2039,7 +2051,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 +2065,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)) - (not (isearch-range-invisible - (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)))))) (setq retry nil))) (setq isearch-just-started nil) (if isearch-success @@ -2393,18 +2409,35 @@ (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 - (min (or isearch-lazy-highlight-end-limit (point-max)) - (if isearch-lazy-highlight-wrapped - isearch-lazy-highlight-start - (window-end))) - (max (or isearch-lazy-highlight-start-limit (point-min)) - (if isearch-lazy-highlight-wrapped - isearch-lazy-highlight-end - (window-start)))) - t) + (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 + (window-end))) + (max (or isearch-lazy-highlight-start-limit (point-min)) + (if isearch-lazy-highlight-wrapped + isearch-lazy-highlight-end + (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)) + (and (text-property-any + (match-beginning 0) (match-end 0) + 'invisible nil) + (text-property-any + (match-beginning 0) (match-end 0) + 'display nil)))) + (setq retry nil))) + success) (error nil)))) (defun isearch-lazy-highlight-update () Index: lisp/info.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/info.el,v retrieving revision 1.421 diff -u -r1.421 info.el --- lisp/info.el 16 Mar 2005 07:32:43 -0000 1.421 +++ lisp/info.el 22 Mar 2005 17:22:26 -0000 @@ -1503,19 +1503,10 @@ (1- (point))) (point-max))) (while (and (not give-up) - (save-match-data - (or (null found) - (if backward - (isearch-range-invisible found beg-found) - (isearch-range-invisible beg-found found)) - ;; Skip node header line - (and (save-excursion (forward-line -1) - (looking-at "\^_")) - (forward-line (if backward -1 1))) - ;; Skip Tag Table node - (save-excursion - (and (search-backward "\^_" nil t) - (looking-at "\^_\nTag Table")))))) + (or (null found) + (not (if isearch-success-function + (funcall isearch-success-function beg-found found) + (Info-search-success-function beg-found found))))) (let ((search-spaces-regexp Info-search-whitespace-regexp)) (if (if backward (re-search-backward regexp bound t) @@ -1529,7 +1520,7 @@ (not bound) (or give-up (and found (not (and (> found opoint-min) (< found opoint-max)))))) - (signal 'search-failed (list regexp "initial node"))) + (signal 'search-failed (list regexp))) ;; If no subfiles, give error now. (if give-up @@ -1591,19 +1582,10 @@ (setq list (cdr list)) (setq give-up nil found nil) (while (and (not give-up) - (save-match-data - (or (null found) - (if backward - (isearch-range-invisible found beg-found) - (isearch-range-invisible beg-found found)) - ;; Skip node header line - (and (save-excursion (forward-line -1) - (looking-at "\^_")) - (forward-line (if backward -1 1))) - ;; Skip Tag Table node - (save-excursion - (and (search-backward "\^_" nil t) - (looking-at "\^_\nTag Table")))))) + (or (null found) + (not (if isearch-success-function + (funcall isearch-success-function beg-found found) + (Info-search-success-function beg-found found))))) (let ((search-spaces-regexp Info-search-whitespace-regexp)) (if (if backward (re-search-backward regexp nil t) @@ -1667,9 +1649,27 @@ nil 'Info-search-history))) (Info-search regexp bound noerror count 'backward)) +(defun Info-search-success-function (beg-found found) + (save-match-data + (let ((backward (< found beg-found))) + (not + (or + ;; Skip `*Note' + (Info-get-token (point) "\\*note[ \n\t]+" "\\(\\*note[ \n\t]+\\)") + ;; Skip node header line + (and (save-excursion (forward-line -1) + (looking-at "\^_")) + (forward-line (if backward -1 1))) + ;; Skip Tag Table node + (save-excursion + (and (search-backward "\^_" nil t) + (looking-at "\^_\nTag Table")))))))) + (defun Info-isearch-search () (if Info-isearch-search (lambda (string &optional bound noerror count) + (setq isearch-message-prefix-add + (if Info-isearch-initial-node "X-node " "")) (if isearch-word (Info-search (concat "\\b" (replace-regexp-in-string "\\W+" "\\\\W+" -- Juri Linkov http://www.jurta.org/emacs/