unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: lennart.borgman.073@student.lu.se, emacs-devel@gnu.org
Subject: Re: Todays exercise of sanity (or does "see" really match "not"?)
Date: Tue, 22 Mar 2005 19:29:05 +0200	[thread overview]
Message-ID: <87br9begh1.fsf@jurta.org> (raw)
In-Reply-To: <x5y8cflov8.fsf@lola.goethe.zz> (David Kastrup's message of "Tue, 22 Mar 2005 15:46:51 +0100")

David Kastrup <dak@gnu.org> 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 "")))
 
 \f
 ;; 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/

  reply	other threads:[~2005-03-22 17:29 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-21 13:20 Todays exercise of sanity (or does "see" really match "not"?) Lennart Borgman
2005-03-21 13:49 ` Luc Teirlinck
2005-03-21 14:00   ` Lennart Borgman
2005-03-21 19:27     ` Juri Linkov
2005-03-21 20:18       ` David Kastrup
2005-03-22 13:57       ` Richard Stallman
2005-03-22 14:46         ` David Kastrup
2005-03-22 17:29           ` Juri Linkov [this message]
2005-03-22 22:22             ` David Kastrup
2005-03-23  6:21             ` Richard Stallman
2005-03-23 13:08               ` Juri Linkov
2005-03-23 14:19                 ` Luc Teirlinck
2005-03-23 15:19                   ` Juri Linkov
2005-03-23 17:03                     ` Luc Teirlinck
2005-03-23 20:21                       ` Juri Linkov
2005-03-23 20:33                         ` Stefan Monnier
2005-03-23 21:16                         ` Luc Teirlinck
2005-03-23 21:42                           ` Luc Teirlinck
2005-03-23 22:54                             ` Kim F. Storm
2005-03-24  1:18                               ` Luc Teirlinck
2005-03-25  6:42                               ` Richard Stallman
2005-03-23 21:44                           ` Drew Adams
2005-03-24  0:21                           ` Juri Linkov
2005-03-24  1:12                             ` Luc Teirlinck
2005-03-25  6:41                           ` Richard Stallman
2005-03-23 21:30                         ` Luc Teirlinck
2005-03-24  5:18                       ` Richard Stallman
2005-03-23 20:26                 ` Richard Stallman
2005-03-24  0:19                   ` Juri Linkov
2005-03-25  6:42                     ` Richard Stallman
2005-03-23  0:59           ` Richard Stallman
2005-03-23  1:10             ` David Kastrup
2005-03-23 10:07               ` Kim F. Storm
2005-03-23 11:01                 ` David Kastrup
2005-03-23 22:57                   ` Kim F. Storm
2005-03-23 23:00                   ` Kim F. Storm
2005-03-23 23:57                     ` David Kastrup
2005-03-25  6:42                     ` Richard Stallman
2005-03-23 12:59                 ` Juri Linkov
2005-08-10  0:19       ` Drew Adams
2005-08-10  3:42         ` Eli Zaretskii
2005-08-10  4:19           ` Drew Adams
2005-08-10  4:03         ` Juri Linkov
2005-03-21 23:20   ` Drew Adams
2005-03-22  4:57     ` Miles Bader
2005-03-22 10:51       ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87br9begh1.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman.073@student.lu.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).