diff options
| author | Richard M. Stallman | 1997-02-10 09:41:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-02-10 09:41:31 +0000 |
| commit | 86bfaffe409c6f7398bcf2144fa8d9f436bd4002 (patch) | |
| tree | b68ea5827e31eb5fb397e53f6c52dff53dc31c15 | |
| parent | 284a88a3183fd7f05b31845f61bc8ad869acc35a (diff) | |
| download | emacs-86bfaffe409c6f7398bcf2144fa8d9f436bd4002.tar.gz emacs-86bfaffe409c6f7398bcf2144fa8d9f436bd4002.zip | |
(isearch-search): Refuse to match invisible text.
(isearch-range-invisible): New function.
(search-invisible): New user option.
| -rw-r--r-- | lisp/isearch.el | 61 |
1 files changed, 49 insertions, 12 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 28fe63335d0..9e5ad7d4a2e 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -138,6 +138,10 @@ You might want to use something like \"[ \\t\\r\\n]+\" instead.") | |||
| 138 | (defvar search-highlight nil | 138 | (defvar search-highlight nil |
| 139 | "*Non-nil means incremental search highlights the current match.") | 139 | "*Non-nil means incremental search highlights the current match.") |
| 140 | 140 | ||
| 141 | (defvar search-invisible nil | ||
| 142 | "*Non-nil means incremental search can match text hidden by an overlay. | ||
| 143 | \(This applies when using `noutline.el'.)") | ||
| 144 | |||
| 141 | (defvar isearch-mode-hook nil | 145 | (defvar isearch-mode-hook nil |
| 142 | "Function(s) to call after starting up an incremental search.") | 146 | "Function(s) to call after starting up an incremental search.") |
| 143 | 147 | ||
| @@ -1350,20 +1354,31 @@ If there is no completion possible, say so and continue searching." | |||
| 1350 | (isearch-no-upper-case-p isearch-string isearch-regexp))) | 1354 | (isearch-no-upper-case-p isearch-string isearch-regexp))) |
| 1351 | (condition-case lossage | 1355 | (condition-case lossage |
| 1352 | (let ((inhibit-quit nil) | 1356 | (let ((inhibit-quit nil) |
| 1353 | (case-fold-search isearch-case-fold-search)) | 1357 | (case-fold-search isearch-case-fold-search) |
| 1358 | (retry t)) | ||
| 1354 | (if isearch-regexp (setq isearch-invalid-regexp nil)) | 1359 | (if isearch-regexp (setq isearch-invalid-regexp nil)) |
| 1355 | (setq isearch-within-brackets nil) | 1360 | (setq isearch-within-brackets nil) |
| 1356 | (setq isearch-success | 1361 | (while retry |
| 1357 | (funcall | 1362 | (setq isearch-success |
| 1358 | (cond (isearch-word | 1363 | (funcall |
| 1359 | (if isearch-forward | 1364 | (cond (isearch-word |
| 1360 | 'word-search-forward 'word-search-backward)) | 1365 | (if isearch-forward |
| 1361 | (isearch-regexp | 1366 | 'word-search-forward 'word-search-backward)) |
| 1362 | (if isearch-forward | 1367 | (isearch-regexp |
| 1363 | 're-search-forward 're-search-backward)) | 1368 | (if isearch-forward |
| 1364 | (t | 1369 | 're-search-forward 're-search-backward)) |
| 1365 | (if isearch-forward 'search-forward 'search-backward))) | 1370 | (t |
| 1366 | isearch-string nil t)) | 1371 | (if isearch-forward 'search-forward 'search-backward))) |
| 1372 | isearch-string nil t)) | ||
| 1373 | ;; Clear RETRY unless we matched some invisible text | ||
| 1374 | ;; and we aren't supposed to do that. | ||
| 1375 | (if (or search-invisible | ||
| 1376 | (not isearch-success) | ||
| 1377 | (bobp) (eobp) | ||
| 1378 | (= (match-beginning 0) (match-end 0)) | ||
| 1379 | (not (isearch-range-invisible | ||
| 1380 | (match-beginning 0) (match-end 0)))) | ||
| 1381 | (setq retry nil))) | ||
| 1367 | (setq isearch-just-started nil) | 1382 | (setq isearch-just-started nil) |
| 1368 | (if isearch-success | 1383 | (if isearch-success |
| 1369 | (setq isearch-other-end | 1384 | (setq isearch-other-end |
| @@ -1391,6 +1406,28 @@ If there is no completion possible, say so and continue searching." | |||
| 1391 | (ding)) | 1406 | (ding)) |
| 1392 | (goto-char (nth 2 (car isearch-cmds))))) | 1407 | (goto-char (nth 2 (car isearch-cmds))))) |
| 1393 | 1408 | ||
| 1409 | (defun isearch-range-invisible (beg end) | ||
| 1410 | "Return t if all the bext from BEG to END is invisible." | ||
| 1411 | (and (/= beg end) | ||
| 1412 | ;; Check that invisibility runs up to END. | ||
| 1413 | (save-excursion | ||
| 1414 | (goto-char beg) | ||
| 1415 | ;; If the following character is currently invisible, | ||
| 1416 | ;; skip all characters with that same `invisible' property value. | ||
| 1417 | ;; Do that over and over. | ||
| 1418 | (while (and (< (point) end) | ||
| 1419 | (let ((prop | ||
| 1420 | (get-char-property (point) 'invisible))) | ||
| 1421 | (if (eq buffer-invisibility-spec t) | ||
| 1422 | prop | ||
| 1423 | (or (memq prop buffer-invisibility-spec) | ||
| 1424 | (assq prop buffer-invisibility-spec))))) | ||
| 1425 | (if (get-text-property (point) 'invisible) | ||
| 1426 | (goto-char (next-single-property-change (point) 'invisible | ||
| 1427 | nil end)) | ||
| 1428 | (goto-char (next-overlay-change (point))))) | ||
| 1429 | ;; See if invisibility reaches up thru END. | ||
| 1430 | (>= (point) end)))) | ||
| 1394 | 1431 | ||
| 1395 | 1432 | ||
| 1396 | ;;; Highlighting | 1433 | ;;; Highlighting |