aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-04-22 19:56:17 +0000
committerJuri Linkov2008-04-22 19:56:17 +0000
commit5e189f398c737704f37979cff6cd2c768e9a7c36 (patch)
tree677861acce3c144134a6336e834ac41236f060f1
parenta300181f28e20018ea42f6c21fb2e1fefa713116 (diff)
downloademacs-5e189f398c737704f37979cff6cd2c768e9a7c36.tar.gz
emacs-5e189f398c737704f37979cff6cd2c768e9a7c36.zip
(isearch-success-function): New variable with default
to `isearch-success-function-default'. (isearch-search): Call a function from `isearch-success-function' instead of calling the hard-coded `isearch-range-invisible'. (isearch-success-function-default): New function that calls `isearch-range-invisible' and inverts its return value.
-rw-r--r--lisp/isearch.el24
1 files changed, 19 insertions, 5 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 675fc7a0f08..92176236d5c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -178,6 +178,12 @@ or to the end of the buffer for a backward search.")
178 "Function to save a function restoring the mode-specific isearch state 178 "Function to save a function restoring the mode-specific isearch state
179to the search status stack.") 179to the search status stack.")
180 180
181(defvar isearch-success-function 'isearch-success-function-default
182 "Function to report whether the new search match is considered successful.
183The function has two arguments: the positions of start and end of text
184matched by the search. It this function returns nil, continue
185searching without stopping at this match.")
186
181;; Search ring. 187;; Search ring.
182 188
183(defvar search-ring nil 189(defvar search-ring nil
@@ -2104,7 +2110,9 @@ Can be changed via `isearch-search-fun-function' for special needs."
2104 (setq isearch-case-fold-search 2110 (setq isearch-case-fold-search
2105 (isearch-no-upper-case-p isearch-string isearch-regexp))) 2111 (isearch-no-upper-case-p isearch-string isearch-regexp)))
2106 (condition-case lossage 2112 (condition-case lossage
2107 (let ((inhibit-point-motion-hooks search-invisible) 2113 (let ((inhibit-point-motion-hooks
2114 (and (eq isearch-success-function 'isearch-success-function-default)
2115 search-invisible))
2108 (inhibit-quit nil) 2116 (inhibit-quit nil)
2109 (case-fold-search isearch-case-fold-search) 2117 (case-fold-search isearch-case-fold-search)
2110 (search-spaces-regexp search-whitespace-regexp) 2118 (search-spaces-regexp search-whitespace-regexp)
@@ -2115,12 +2123,11 @@ Can be changed via `isearch-search-fun-function' for special needs."
2115 (isearch-search-string isearch-string nil t)) 2123 (isearch-search-string isearch-string nil t))
2116 ;; Clear RETRY unless we matched some invisible text 2124 ;; Clear RETRY unless we matched some invisible text
2117 ;; and we aren't supposed to do that. 2125 ;; and we aren't supposed to do that.
2118 (if (or (eq search-invisible t) 2126 (if (or (not isearch-success)
2119 (not isearch-success)
2120 (bobp) (eobp) 2127 (bobp) (eobp)
2121 (= (match-beginning 0) (match-end 0)) 2128 (= (match-beginning 0) (match-end 0))
2122 (not (isearch-range-invisible 2129 (funcall isearch-success-function
2123 (match-beginning 0) (match-end 0)))) 2130 (match-beginning 0) (match-end 0)))
2124 (setq retry nil))) 2131 (setq retry nil)))
2125 (setq isearch-just-started nil) 2132 (setq isearch-just-started nil)
2126 (if isearch-success 2133 (if isearch-success
@@ -2298,6 +2305,13 @@ Can be changed via `isearch-search-fun-function' for special needs."
2298 nil) 2305 nil)
2299 (setq isearch-hidden t))))))) 2306 (setq isearch-hidden t)))))))
2300 2307
2308(defun isearch-success-function-default (beg end)
2309 "Default function to report if the new search match is successful.
2310Returns t if search can match hidden text, or otherwise checks if some
2311text from BEG to END is visible."
2312 (or (eq search-invisible t)
2313 (not (isearch-range-invisible beg end))))
2314
2301 2315
2302;; General utilities 2316;; General utilities
2303 2317