summaryrefslogtreecommitdiff
path: root/lisp/isearch.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@jurta.org>2008-04-22 19:56:17 +0000
committerJuri Linkov <juri@jurta.org>2008-04-22 19:56:17 +0000
commit5e189f398c737704f37979cff6cd2c768e9a7c36 (patch)
tree677861acce3c144134a6336e834ac41236f060f1 /lisp/isearch.el
parenta300181f28e20018ea42f6c21fb2e1fefa713116 (diff)
downloademacs-5e189f398c737704f37979cff6cd2c768e9a7c36.tar.gz
emacs-5e189f398c737704f37979cff6cd2c768e9a7c36.tar.bz2
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.
Diffstat (limited to 'lisp/isearch.el')
-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.")
"Function to save a function restoring the mode-specific isearch state
to the search status stack.")
+(defvar isearch-success-function 'isearch-success-function-default
+ "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 the search. It this function returns nil, continue
+searching without stopping at this match.")
+
;; Search ring.
(defvar search-ring nil
@@ -2104,7 +2110,9 @@ Can be changed via `isearch-search-fun-function' for special needs."
(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 (eq isearch-success-function 'isearch-success-function-default)
+ search-invisible))
(inhibit-quit nil)
(case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp)
@@ -2115,12 +2123,11 @@ Can be changed via `isearch-search-fun-function' for special needs."
(isearch-search-string 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))))
+ (funcall isearch-success-function
+ (match-beginning 0) (match-end 0)))
(setq retry nil)))
(setq isearch-just-started nil)
(if isearch-success
@@ -2298,6 +2305,13 @@ Can be changed via `isearch-search-fun-function' for special needs."
nil)
(setq isearch-hidden t)))))))
+(defun isearch-success-function-default (beg end)
+ "Default function to report if the new search match is successful.
+Returns t if search can match hidden text, or otherwise checks if some
+text from BEG to END is visible."
+ (or (eq search-invisible t)
+ (not (isearch-range-invisible beg end))))
+
;; General utilities