437 |
(defvar isearch-string "") ; The current search string. |
(defvar isearch-string "") ; The current search string. |
438 |
(defvar isearch-message "") ; text-char-description version of isearch-string |
(defvar isearch-message "") ; text-char-description version of isearch-string |
439 |
|
|
440 |
(defvar isearch-success t) ; Searching is currently successful. |
(defvar isearch-success t) ; Searching is currently successful. |
441 |
(defvar isearch-invalid-regexp nil) ; Regexp not well formed. |
(defvar isearch-error nil) ; Error message for failed search. |
|
(defvar isearch-within-brackets nil) ; Regexp has unclosed [. |
|
442 |
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward). |
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward). |
443 |
(defvar isearch-wrapped nil) ; Searching restarted from the top (bottom). |
(defvar isearch-wrapped nil) ; Searching restarted from the top (bottom). |
444 |
(defvar isearch-barrier 0) |
(defvar isearch-barrier 0) |
639 |
isearch-barrier (point) |
isearch-barrier (point) |
640 |
isearch-adjusted nil |
isearch-adjusted nil |
641 |
isearch-yank-flag nil |
isearch-yank-flag nil |
642 |
isearch-invalid-regexp nil |
isearch-error nil |
|
isearch-within-brackets nil |
|
643 |
isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed) |
isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed) |
644 |
(> (window-height) |
(> (window-height) |
645 |
(* 4 |
(* 4 |
865 |
(defsubst isearch-word-state (frame) |
(defsubst isearch-word-state (frame) |
866 |
"Return the search-by-word flag in FRAME." |
"Return the search-by-word flag in FRAME." |
867 |
(aref frame 6)) |
(aref frame 6)) |
868 |
(defsubst isearch-invalid-regexp-state (frame) |
(defsubst isearch-error-state (frame) |
869 |
"Return the regexp error message in FRAME, or nil if its regexp is valid." |
"Return the regexp error message in FRAME, or nil if its regexp is valid." |
870 |
(aref frame 7)) |
(aref frame 7)) |
871 |
(defsubst isearch-wrapped-state (frame) |
(defsubst isearch-wrapped-state (frame) |
874 |
(defsubst isearch-barrier-state (frame) |
(defsubst isearch-barrier-state (frame) |
875 |
"Return the barrier value in FRAME." |
"Return the barrier value in FRAME." |
876 |
(aref frame 9)) |
(aref frame 9)) |
|
(defsubst isearch-within-brackets-state (frame) |
|
|
"Return the in-character-class flag in FRAME." |
|
|
(aref frame 10)) |
|
877 |
(defsubst isearch-case-fold-search-state (frame) |
(defsubst isearch-case-fold-search-state (frame) |
878 |
"Return the case-folding flag in FRAME." |
"Return the case-folding flag in FRAME." |
879 |
(aref frame 11)) |
(aref frame 10)) |
880 |
(defsubst isearch-pop-fun-state (frame) |
(defsubst isearch-pop-fun-state (frame) |
881 |
"Return the function restoring the mode-specific isearch state in FRAME." |
"Return the function restoring the mode-specific isearch state in FRAME." |
882 |
(aref frame 12)) |
(aref frame 11)) |
883 |
|
|
884 |
(defun isearch-top-state () |
(defun isearch-top-state () |
885 |
(let ((cmd (car isearch-cmds))) |
(let ((cmd (car isearch-cmds))) |
889 |
isearch-forward (isearch-forward-state cmd) |
isearch-forward (isearch-forward-state cmd) |
890 |
isearch-other-end (isearch-other-end-state cmd) |
isearch-other-end (isearch-other-end-state cmd) |
891 |
isearch-word (isearch-word-state cmd) |
isearch-word (isearch-word-state cmd) |
892 |
isearch-invalid-regexp (isearch-invalid-regexp-state cmd) |
isearch-error (isearch-error-state cmd) |
893 |
isearch-wrapped (isearch-wrapped-state cmd) |
isearch-wrapped (isearch-wrapped-state cmd) |
894 |
isearch-barrier (isearch-barrier-state cmd) |
isearch-barrier (isearch-barrier-state cmd) |
|
isearch-within-brackets (isearch-within-brackets-state cmd) |
|
895 |
isearch-case-fold-search (isearch-case-fold-search-state cmd)) |
isearch-case-fold-search (isearch-case-fold-search-state cmd)) |
896 |
(if (functionp (isearch-pop-fun-state cmd)) |
(if (functionp (isearch-pop-fun-state cmd)) |
897 |
(funcall (isearch-pop-fun-state cmd) cmd)) |
(funcall (isearch-pop-fun-state cmd) cmd)) |
906 |
(cons (vector isearch-string isearch-message (point) |
(cons (vector isearch-string isearch-message (point) |
907 |
isearch-success isearch-forward isearch-other-end |
isearch-success isearch-forward isearch-other-end |
908 |
isearch-word |
isearch-word |
909 |
isearch-invalid-regexp isearch-wrapped isearch-barrier |
isearch-error isearch-wrapped isearch-barrier |
910 |
isearch-within-brackets isearch-case-fold-search |
isearch-case-fold-search |
911 |
(if isearch-push-state-function |
(if isearch-push-state-function |
912 |
(funcall isearch-push-state-function))) |
(funcall isearch-push-state-function))) |
913 |
isearch-cmds))) |
isearch-cmds))) |
970 |
(isearch-barrier isearch-barrier) |
(isearch-barrier isearch-barrier) |
971 |
(isearch-adjusted isearch-adjusted) |
(isearch-adjusted isearch-adjusted) |
972 |
(isearch-yank-flag isearch-yank-flag) |
(isearch-yank-flag isearch-yank-flag) |
973 |
(isearch-invalid-regexp isearch-invalid-regexp) |
(isearch-error isearch-error) |
|
(isearch-within-brackets isearch-within-brackets) |
|
974 |
;;; Don't bind this. We want isearch-search, below, to set it. |
;;; Don't bind this. We want isearch-search, below, to set it. |
975 |
;;; And the old value won't matter after that. |
;;; And the old value won't matter after that. |
976 |
;;; (isearch-other-end isearch-other-end) |
;;; (isearch-other-end isearch-other-end) |
1117 |
(isearch-cancel)) |
(isearch-cancel)) |
1118 |
;; If search is failing, or has an incomplete regexp, |
;; If search is failing, or has an incomplete regexp, |
1119 |
;; rub out until it is once more successful. |
;; rub out until it is once more successful. |
1120 |
(while (or (not isearch-success) isearch-invalid-regexp) |
(while (or (not isearch-success) isearch-error) |
1121 |
(isearch-pop-state)) |
(isearch-pop-state)) |
1122 |
(isearch-update))) |
(isearch-update))) |
1123 |
|
|
1139 |
;; If already have what to search for, repeat it. |
;; If already have what to search for, repeat it. |
1140 |
(or isearch-success |
(or isearch-success |
1141 |
(progn |
(progn |
1142 |
|
;; Set isearch-wrapped before calling isearch-wrap-function |
1143 |
|
(setq isearch-wrapped t) |
1144 |
(if isearch-wrap-function |
(if isearch-wrap-function |
1145 |
(funcall isearch-wrap-function) |
(funcall isearch-wrap-function) |
1146 |
(goto-char (if isearch-forward (point-min) (point-max)))) |
(goto-char (if isearch-forward (point-min) (point-max))))))) |
|
(setq isearch-wrapped t)))) |
|
1147 |
;; C-s in reverse or C-r in forward, change direction. |
;; C-s in reverse or C-r in forward, change direction. |
1148 |
(setq isearch-forward (not isearch-forward))) |
(setq isearch-forward (not isearch-forward))) |
1149 |
|
|
1378 |
(min isearch-opoint isearch-barrier)))) |
(min isearch-opoint isearch-barrier)))) |
1379 |
(progn |
(progn |
1380 |
(setq isearch-success t |
(setq isearch-success t |
1381 |
isearch-invalid-regexp nil |
isearch-error nil |
|
isearch-within-brackets nil |
|
1382 |
isearch-other-end (match-end 0)) |
isearch-other-end (match-end 0)) |
1383 |
(if (and (eq isearch-case-fold-search t) search-upper-case) |
(if (and (eq isearch-case-fold-search t) search-upper-case) |
1384 |
(setq isearch-case-fold-search |
(setq isearch-case-fold-search |
1425 |
(not want-backslash)) |
(not want-backslash)) |
1426 |
;; We have to check 2 stack frames because the last might be |
;; We have to check 2 stack frames because the last might be |
1427 |
;; invalid just because of a backslash. |
;; invalid just because of a backslash. |
1428 |
(or (not isearch-invalid-regexp) |
(or (not isearch-error) |
1429 |
(not (isearch-invalid-regexp-state (cadr isearch-cmds))) |
(not (isearch-error-state (cadr isearch-cmds))) |
1430 |
allow-invalid)) |
allow-invalid)) |
1431 |
(if to-barrier |
(if to-barrier |
1432 |
(progn (goto-char isearch-barrier) |
(progn (goto-char isearch-barrier) |
1441 |
;; Also skip over postfix operators -- though horrid, |
;; Also skip over postfix operators -- though horrid, |
1442 |
;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal. |
;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal. |
1443 |
(while (and previous |
(while (and previous |
1444 |
(or (isearch-invalid-regexp-state frame) |
(or (isearch-error-state frame) |
1445 |
(let* ((string (isearch-string-state frame)) |
(let* ((string (isearch-string-state frame)) |
1446 |
(lchar (aref string (1- (length string))))) |
(lchar (aref string (1- (length string))))) |
1447 |
;; The operators aren't always operators; check |
;; The operators aren't always operators; check |
1974 |
;; If about to search, and previous search regexp was invalid, |
;; If about to search, and previous search regexp was invalid, |
1975 |
;; check that it still is. If it is valid now, |
;; check that it still is. If it is valid now, |
1976 |
;; let the message we display while searching say that it is valid. |
;; let the message we display while searching say that it is valid. |
1977 |
(and isearch-invalid-regexp ellipsis |
(and isearch-error ellipsis |
1978 |
(condition-case () |
(condition-case () |
1979 |
(progn (re-search-forward isearch-string (point) t) |
(progn (re-search-forward isearch-string (point) t) |
1980 |
(setq isearch-invalid-regexp nil |
(setq isearch-error nil)) |
|
isearch-within-brackets nil)) |
|
1981 |
(error nil))) |
(error nil))) |
1982 |
;; If currently failing, display no ellipsis. |
;; If currently failing, display no ellipsis. |
1983 |
(or isearch-success (setq ellipsis nil)) |
(or isearch-success (setq ellipsis nil)) |
2003 |
|
|
2004 |
(defun isearch-message-suffix (&optional c-q-hack ellipsis) |
(defun isearch-message-suffix (&optional c-q-hack ellipsis) |
2005 |
(concat (if c-q-hack "^Q" "") |
(concat (if c-q-hack "^Q" "") |
2006 |
(if isearch-invalid-regexp |
(if isearch-error |
2007 |
(concat " [" isearch-invalid-regexp "]") |
(concat " [" isearch-error "]") |
2008 |
""))) |
""))) |
2009 |
|
|
2010 |
|
|
2041 |
(case-fold-search isearch-case-fold-search) |
(case-fold-search isearch-case-fold-search) |
2042 |
(search-spaces-regexp search-whitespace-regexp) |
(search-spaces-regexp search-whitespace-regexp) |
2043 |
(retry t)) |
(retry t)) |
2044 |
(if isearch-regexp (setq isearch-invalid-regexp nil)) |
(setq isearch-error nil) |
|
(setq isearch-within-brackets nil) |
|
2045 |
(while retry |
(while retry |
2046 |
(setq isearch-success |
(setq isearch-success |
2047 |
(funcall |
(funcall |
2065 |
(setq isearch-success nil)) |
(setq isearch-success nil)) |
2066 |
|
|
2067 |
(invalid-regexp |
(invalid-regexp |
2068 |
(setq isearch-invalid-regexp (car (cdr lossage))) |
(setq isearch-error (car (cdr lossage))) |
|
(setq isearch-within-brackets (string-match "\\`Unmatched \\[" |
|
|
isearch-invalid-regexp)) |
|
2069 |
(if (string-match |
(if (string-match |
2070 |
"\\`Premature \\|\\`Unmatched \\|\\`Invalid " |
"\\`Premature \\|\\`Unmatched \\|\\`Invalid " |
2071 |
isearch-invalid-regexp) |
isearch-error) |
2072 |
(setq isearch-invalid-regexp "incomplete input"))) |
(setq isearch-error "incomplete input"))) |
2073 |
|
|
2074 |
|
(search-failed |
2075 |
|
(setq isearch-success nil) |
2076 |
|
(setq isearch-error (nth 2 lossage))) |
2077 |
|
|
2078 |
(error |
(error |
2079 |
;; stack overflow in regexp search. |
;; stack overflow in regexp search. |
2080 |
(setq isearch-invalid-regexp (format "%s" lossage)))) |
(setq isearch-error (format "%s" lossage)))) |
2081 |
|
|
2082 |
(if isearch-success |
(if isearch-success |
2083 |
nil |
nil |
2309 |
;; `isearch-word' and `isearch-regexp'; |
;; `isearch-word' and `isearch-regexp'; |
2310 |
;; - the direction of the current search is expected to be given by |
;; - the direction of the current search is expected to be given by |
2311 |
;; `isearch-forward'; |
;; `isearch-forward'; |
2312 |
;; - the variable `isearch-invalid-regexp' is expected to be true |
;; - the variable `isearch-error' is expected to be true |
2313 |
;; iff `isearch-string' is an invalid regexp. |
;; iff `isearch-string' is an invalid regexp. |
2314 |
|
|
2315 |
(defvar isearch-lazy-highlight-overlays nil) |
(defvar isearch-lazy-highlight-overlays nil) |
2363 |
isearch-lazy-highlight-window-end)))) |
isearch-lazy-highlight-window-end)))) |
2364 |
;; something important did indeed change |
;; something important did indeed change |
2365 |
(isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays |
(isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays |
2366 |
(when (not isearch-invalid-regexp) |
(when (not isearch-error) |
2367 |
(setq isearch-lazy-highlight-start-limit beg |
(setq isearch-lazy-highlight-start-limit beg |
2368 |
isearch-lazy-highlight-end-limit end) |
isearch-lazy-highlight-end-limit end) |
2369 |
(setq isearch-lazy-highlight-window (selected-window) |
(setq isearch-lazy-highlight-window (selected-window) |
2385 |
Attempt to do the search exactly the way the pending isearch would." |
Attempt to do the search exactly the way the pending isearch would." |
2386 |
(let ((case-fold-search isearch-case-fold-search) |
(let ((case-fold-search isearch-case-fold-search) |
2387 |
(search-spaces-regexp search-whitespace-regexp)) |
(search-spaces-regexp search-whitespace-regexp)) |
2388 |
(funcall (isearch-search-fun) |
(condition-case nil |
2389 |
isearch-string |
(funcall (isearch-search-fun) |
2390 |
(if isearch-forward |
isearch-string |
2391 |
(min (or isearch-lazy-highlight-end-limit (point-max)) |
(if isearch-forward |
2392 |
(if isearch-lazy-highlight-wrapped |
(min (or isearch-lazy-highlight-end-limit (point-max)) |
2393 |
isearch-lazy-highlight-start |
(if isearch-lazy-highlight-wrapped |
2394 |
(window-end))) |
isearch-lazy-highlight-start |
2395 |
(max (or isearch-lazy-highlight-start-limit (point-min)) |
(window-end))) |
2396 |
(if isearch-lazy-highlight-wrapped |
(max (or isearch-lazy-highlight-start-limit (point-min)) |
2397 |
isearch-lazy-highlight-end |
(if isearch-lazy-highlight-wrapped |
2398 |
(window-start)))) |
isearch-lazy-highlight-end |
2399 |
t))) |
(window-start)))) |
2400 |
|
t) |
2401 |
|
(error nil)))) |
2402 |
|
|
2403 |
(defun isearch-lazy-highlight-update () |
(defun isearch-lazy-highlight-update () |
2404 |
"Update highlighting of other matches for current search." |
"Update highlighting of other matches for current search." |