aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/isearch.el
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1997-02-10 09:41:31 +0000
committerRichard M. Stallman <[email protected]>1997-02-10 09:41:31 +0000
commit86bfaffe409c6f7398bcf2144fa8d9f436bd4002 (patch)
treeb68ea5827e31eb5fb397e53f6c52dff53dc31c15 /lisp/isearch.el
parent284a88a3183fd7f05b31845f61bc8ad869acc35a (diff)
(isearch-search): Refuse to match invisible text.
(isearch-range-invisible): New function. (search-invisible): New user option.
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el61
1 files changed, 49 insertions, 12 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 28fe63335d..9e5ad7d4a2 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -138,6 +138,10 @@ You might want to use something like \"[ \\t\\r\\n]+\" instead.")
(defvar search-highlight nil
"*Non-nil means incremental search highlights the current match.")
+(defvar search-invisible nil
+ "*Non-nil means incremental search can match text hidden by an overlay.
+\(This applies when using `noutline.el'.)")
+
(defvar isearch-mode-hook nil
"Function(s) to call after starting up an incremental search.")
@@ -1350,20 +1354,31 @@ If there is no completion possible, say so and continue searching."
(isearch-no-upper-case-p isearch-string isearch-regexp)))
(condition-case lossage
(let ((inhibit-quit nil)
- (case-fold-search isearch-case-fold-search))
+ (case-fold-search isearch-case-fold-search)
+ (retry t))
(if isearch-regexp (setq isearch-invalid-regexp nil))
(setq isearch-within-brackets nil)
- (setq isearch-success
- (funcall
- (cond (isearch-word
- (if isearch-forward
- 'word-search-forward 'word-search-backward))
- (isearch-regexp
- (if isearch-forward
- 're-search-forward 're-search-backward))
- (t
- (if isearch-forward 'search-forward 'search-backward)))
- isearch-string nil t))
+ (while retry
+ (setq isearch-success
+ (funcall
+ (cond (isearch-word
+ (if isearch-forward
+ 'word-search-forward 'word-search-backward))
+ (isearch-regexp
+ (if isearch-forward
+ 're-search-forward 're-search-backward))
+ (t
+ (if isearch-forward 'search-forward 'search-backward)))
+ isearch-string nil t))
+ ;; Clear RETRY unless we matched some invisible text
+ ;; and we aren't supposed to do that.
+ (if (or search-invisible
+ (not isearch-success)
+ (bobp) (eobp)
+ (= (match-beginning 0) (match-end 0))
+ (not (isearch-range-invisible
+ (match-beginning 0) (match-end 0))))
+ (setq retry nil)))
(setq isearch-just-started nil)
(if isearch-success
(setq isearch-other-end
@@ -1391,6 +1406,28 @@ If there is no completion possible, say so and continue searching."
(ding))
(goto-char (nth 2 (car isearch-cmds)))))
+(defun isearch-range-invisible (beg end)
+ "Return t if all the bext from BEG to END is invisible."
+ (and (/= beg end)
+ ;; Check that invisibility runs up to END.
+ (save-excursion
+ (goto-char beg)
+ ;; If the following character is currently invisible,
+ ;; skip all characters with that same `invisible' property value.
+ ;; Do that over and over.
+ (while (and (< (point) end)
+ (let ((prop
+ (get-char-property (point) 'invisible)))
+ (if (eq buffer-invisibility-spec t)
+ prop
+ (or (memq prop buffer-invisibility-spec)
+ (assq prop buffer-invisibility-spec)))))
+ (if (get-text-property (point) 'invisible)
+ (goto-char (next-single-property-change (point) 'invisible
+ nil end))
+ (goto-char (next-overlay-change (point)))))
+ ;; See if invisibility reaches up thru END.
+ (>= (point) end))))
;;; Highlighting