Mercurial > emacs
changeset 16990:a2fc2ef460e3
(isearch-search): Refuse to match invisible text.
(isearch-range-invisible): New function.
(search-invisible): New user option.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 10 Feb 1997 09:41:31 +0000 |
parents | 4e31b0ff76a9 |
children | b33fd17a2873 |
files | lisp/isearch.el |
diffstat | 1 files changed, 49 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/isearch.el Mon Feb 10 00:10:16 1997 +0000 +++ b/lisp/isearch.el Mon Feb 10 09:41:31 1997 +0000 @@ -138,6 +138,10 @@ (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 @@ (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 @@ (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