[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Todays exercise of sanity (or does "see" really match "not"?)
From: |
Juri Linkov |
Subject: |
Re: Todays exercise of sanity (or does "see" really match "not"?) |
Date: |
Tue, 22 Mar 2005 19:29:05 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/22.0.50 (gnu/linux) |
David Kastrup <address@hidden> 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/
- Todays exercise of sanity (or does "see" really match "not"?), Lennart Borgman, 2005/03/21
- Re: Todays exercise of sanity (or does "see" really match "not"?), Luc Teirlinck, 2005/03/21
- Re: Todays exercise of sanity (or does "see" really match "not"?), Lennart Borgman, 2005/03/21
- Re: Todays exercise of sanity (or does "see" really match "not"?), Juri Linkov, 2005/03/21
- Re: Todays exercise of sanity (or does "see" really match "not"?), David Kastrup, 2005/03/21
- Re: Todays exercise of sanity (or does "see" really match "not"?), Richard Stallman, 2005/03/22
- Re: Todays exercise of sanity (or does "see" really match "not"?), David Kastrup, 2005/03/22
- Re: Todays exercise of sanity (or does "see" really match "not"?),
Juri Linkov <=
- Re: Todays exercise of sanity (or does "see" really match "not"?), David Kastrup, 2005/03/22
- Re: Todays exercise of sanity (or does "see" really match "not"?), Richard Stallman, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Juri Linkov, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Luc Teirlinck, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Juri Linkov, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Luc Teirlinck, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Juri Linkov, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Stefan Monnier, 2005/03/23
- Re: Todays exercise of sanity (or does "see" really match "not"?), Luc Teirlinck, 2005/03/23
- RE: Todays exercise of sanity (or does "see" really match "not"?), Drew Adams, 2005/03/23