[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/isearch.el
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/isearch.el |
Date: |
Tue, 15 Mar 2005 05:45:26 -0500 |
Index: emacs/lisp/isearch.el
diff -c emacs/lisp/isearch.el:1.256 emacs/lisp/isearch.el:1.257
*** emacs/lisp/isearch.el:1.256 Sat Feb 19 20:52:47 2005
--- emacs/lisp/isearch.el Tue Mar 15 10:45:25 2005
***************
*** 437,445 ****
(defvar isearch-string "") ; The current search string.
(defvar isearch-message "") ; text-char-description version of isearch-string
! (defvar isearch-success t) ; Searching is currently successful.
! (defvar isearch-invalid-regexp nil) ; Regexp not well formed.
! (defvar isearch-within-brackets nil) ; Regexp has unclosed [.
(defvar isearch-other-end nil) ; Start (end) of match if forward
(backward).
(defvar isearch-wrapped nil) ; Searching restarted from the top (bottom).
(defvar isearch-barrier 0)
--- 437,444 ----
(defvar isearch-string "") ; The current search string.
(defvar isearch-message "") ; text-char-description version of isearch-string
! (defvar isearch-success t) ; Searching is currently successful.
! (defvar isearch-error nil) ; Error message for failed search.
(defvar isearch-other-end nil) ; Start (end) of match if forward
(backward).
(defvar isearch-wrapped nil) ; Searching restarted from the top (bottom).
(defvar isearch-barrier 0)
***************
*** 640,647 ****
isearch-barrier (point)
isearch-adjusted nil
isearch-yank-flag nil
! isearch-invalid-regexp nil
! isearch-within-brackets nil
isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed)
(> (window-height)
(* 4
--- 639,645 ----
isearch-barrier (point)
isearch-adjusted nil
isearch-yank-flag nil
! isearch-error nil
isearch-slow-terminal-mode (and (<= baud-rate search-slow-speed)
(> (window-height)
(* 4
***************
*** 867,873 ****
(defsubst isearch-word-state (frame)
"Return the search-by-word flag in FRAME."
(aref frame 6))
! (defsubst isearch-invalid-regexp-state (frame)
"Return the regexp error message in FRAME, or nil if its regexp is valid."
(aref frame 7))
(defsubst isearch-wrapped-state (frame)
--- 865,871 ----
(defsubst isearch-word-state (frame)
"Return the search-by-word flag in FRAME."
(aref frame 6))
! (defsubst isearch-error-state (frame)
"Return the regexp error message in FRAME, or nil if its regexp is valid."
(aref frame 7))
(defsubst isearch-wrapped-state (frame)
***************
*** 876,890 ****
(defsubst isearch-barrier-state (frame)
"Return the barrier value in FRAME."
(aref frame 9))
- (defsubst isearch-within-brackets-state (frame)
- "Return the in-character-class flag in FRAME."
- (aref frame 10))
(defsubst isearch-case-fold-search-state (frame)
"Return the case-folding flag in FRAME."
! (aref frame 11))
(defsubst isearch-pop-fun-state (frame)
"Return the function restoring the mode-specific isearch state in FRAME."
! (aref frame 12))
(defun isearch-top-state ()
(let ((cmd (car isearch-cmds)))
--- 874,885 ----
(defsubst isearch-barrier-state (frame)
"Return the barrier value in FRAME."
(aref frame 9))
(defsubst isearch-case-fold-search-state (frame)
"Return the case-folding flag in FRAME."
! (aref frame 10))
(defsubst isearch-pop-fun-state (frame)
"Return the function restoring the mode-specific isearch state in FRAME."
! (aref frame 11))
(defun isearch-top-state ()
(let ((cmd (car isearch-cmds)))
***************
*** 894,903 ****
isearch-forward (isearch-forward-state cmd)
isearch-other-end (isearch-other-end-state cmd)
isearch-word (isearch-word-state cmd)
! isearch-invalid-regexp (isearch-invalid-regexp-state cmd)
isearch-wrapped (isearch-wrapped-state cmd)
isearch-barrier (isearch-barrier-state cmd)
- isearch-within-brackets (isearch-within-brackets-state cmd)
isearch-case-fold-search (isearch-case-fold-search-state cmd))
(if (functionp (isearch-pop-fun-state cmd))
(funcall (isearch-pop-fun-state cmd) cmd))
--- 889,897 ----
isearch-forward (isearch-forward-state cmd)
isearch-other-end (isearch-other-end-state cmd)
isearch-word (isearch-word-state cmd)
! isearch-error (isearch-error-state cmd)
isearch-wrapped (isearch-wrapped-state cmd)
isearch-barrier (isearch-barrier-state cmd)
isearch-case-fold-search (isearch-case-fold-search-state cmd))
(if (functionp (isearch-pop-fun-state cmd))
(funcall (isearch-pop-fun-state cmd) cmd))
***************
*** 912,919 ****
(cons (vector isearch-string isearch-message (point)
isearch-success isearch-forward isearch-other-end
isearch-word
! isearch-invalid-regexp isearch-wrapped isearch-barrier
! isearch-within-brackets isearch-case-fold-search
(if isearch-push-state-function
(funcall isearch-push-state-function)))
isearch-cmds)))
--- 906,913 ----
(cons (vector isearch-string isearch-message (point)
isearch-success isearch-forward isearch-other-end
isearch-word
! isearch-error isearch-wrapped isearch-barrier
! isearch-case-fold-search
(if isearch-push-state-function
(funcall isearch-push-state-function)))
isearch-cmds)))
***************
*** 976,983 ****
(isearch-barrier isearch-barrier)
(isearch-adjusted isearch-adjusted)
(isearch-yank-flag isearch-yank-flag)
! (isearch-invalid-regexp isearch-invalid-regexp)
! (isearch-within-brackets isearch-within-brackets)
;;; Don't bind this. We want isearch-search, below, to set it.
;;; And the old value won't matter after that.
;;; (isearch-other-end isearch-other-end)
--- 970,976 ----
(isearch-barrier isearch-barrier)
(isearch-adjusted isearch-adjusted)
(isearch-yank-flag isearch-yank-flag)
! (isearch-error isearch-error)
;;; Don't bind this. We want isearch-search, below, to set it.
;;; And the old value won't matter after that.
;;; (isearch-other-end isearch-other-end)
***************
*** 1124,1130 ****
(isearch-cancel))
;; If search is failing, or has an incomplete regexp,
;; rub out until it is once more successful.
! (while (or (not isearch-success) isearch-invalid-regexp)
(isearch-pop-state))
(isearch-update)))
--- 1117,1123 ----
(isearch-cancel))
;; If search is failing, or has an incomplete regexp,
;; rub out until it is once more successful.
! (while (or (not isearch-success) isearch-error)
(isearch-pop-state))
(isearch-update)))
***************
*** 1146,1155 ****
;; If already have what to search for, repeat it.
(or isearch-success
(progn
(if isearch-wrap-function
(funcall isearch-wrap-function)
! (goto-char (if isearch-forward (point-min) (point-max))))
! (setq isearch-wrapped t))))
;; C-s in reverse or C-r in forward, change direction.
(setq isearch-forward (not isearch-forward)))
--- 1139,1149 ----
;; If already have what to search for, repeat it.
(or isearch-success
(progn
+ ;; Set isearch-wrapped before calling isearch-wrap-function
+ (setq isearch-wrapped t)
(if isearch-wrap-function
(funcall isearch-wrap-function)
! (goto-char (if isearch-forward (point-min) (point-max)))))))
;; C-s in reverse or C-r in forward, change direction.
(setq isearch-forward (not isearch-forward)))
***************
*** 1384,1391 ****
(min isearch-opoint isearch-barrier))))
(progn
(setq isearch-success t
! isearch-invalid-regexp nil
! isearch-within-brackets nil
isearch-other-end (match-end 0))
(if (and (eq isearch-case-fold-search t) search-upper-case)
(setq isearch-case-fold-search
--- 1378,1384 ----
(min isearch-opoint isearch-barrier))))
(progn
(setq isearch-success t
! isearch-error nil
isearch-other-end (match-end 0))
(if (and (eq isearch-case-fold-search t) search-upper-case)
(setq isearch-case-fold-search
***************
*** 1432,1439 ****
(not want-backslash))
;; We have to check 2 stack frames because the last might be
;; invalid just because of a backslash.
! (or (not isearch-invalid-regexp)
! (not (isearch-invalid-regexp-state (cadr isearch-cmds)))
allow-invalid))
(if to-barrier
(progn (goto-char isearch-barrier)
--- 1425,1432 ----
(not want-backslash))
;; We have to check 2 stack frames because the last might be
;; invalid just because of a backslash.
! (or (not isearch-error)
! (not (isearch-error-state (cadr isearch-cmds)))
allow-invalid))
(if to-barrier
(progn (goto-char isearch-barrier)
***************
*** 1448,1454 ****
;; Also skip over postfix operators -- though horrid,
;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal.
(while (and previous
! (or (isearch-invalid-regexp-state frame)
(let* ((string (isearch-string-state frame))
(lchar (aref string (1- (length string)))))
;; The operators aren't always operators; check
--- 1441,1447 ----
;; Also skip over postfix operators -- though horrid,
;; 'ab?\{5,6\}+\{1,2\}*' is perfectly legal.
(while (and previous
! (or (isearch-error-state frame)
(let* ((string (isearch-string-state frame))
(lchar (aref string (1- (length string)))))
;; The operators aren't always operators; check
***************
*** 1981,1991 ****
;; If about to search, and previous search regexp was invalid,
;; check that it still is. If it is valid now,
;; let the message we display while searching say that it is valid.
! (and isearch-invalid-regexp ellipsis
(condition-case ()
(progn (re-search-forward isearch-string (point) t)
! (setq isearch-invalid-regexp nil
! isearch-within-brackets nil))
(error nil)))
;; If currently failing, display no ellipsis.
(or isearch-success (setq ellipsis nil))
--- 1974,1983 ----
;; If about to search, and previous search regexp was invalid,
;; check that it still is. If it is valid now,
;; let the message we display while searching say that it is valid.
! (and isearch-error ellipsis
(condition-case ()
(progn (re-search-forward isearch-string (point) t)
! (setq isearch-error nil))
(error nil)))
;; If currently failing, display no ellipsis.
(or isearch-success (setq ellipsis nil))
***************
*** 2011,2018 ****
(defun isearch-message-suffix (&optional c-q-hack ellipsis)
(concat (if c-q-hack "^Q" "")
! (if isearch-invalid-regexp
! (concat " [" isearch-invalid-regexp "]")
"")))
--- 2003,2010 ----
(defun isearch-message-suffix (&optional c-q-hack ellipsis)
(concat (if c-q-hack "^Q" "")
! (if isearch-error
! (concat " [" isearch-error "]")
"")))
***************
*** 2049,2056 ****
(case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp)
(retry t))
! (if isearch-regexp (setq isearch-invalid-regexp nil))
! (setq isearch-within-brackets nil)
(while retry
(setq isearch-success
(funcall
--- 2041,2047 ----
(case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp)
(retry t))
! (setq isearch-error nil)
(while retry
(setq isearch-success
(funcall
***************
*** 2074,2089 ****
(setq isearch-success nil))
(invalid-regexp
! (setq isearch-invalid-regexp (car (cdr lossage)))
! (setq isearch-within-brackets (string-match "\\`Unmatched \\["
! isearch-invalid-regexp))
(if (string-match
"\\`Premature \\|\\`Unmatched \\|\\`Invalid "
! isearch-invalid-regexp)
! (setq isearch-invalid-regexp "incomplete input")))
(error
;; stack overflow in regexp search.
! (setq isearch-invalid-regexp (format "%s" lossage))))
(if isearch-success
nil
--- 2065,2083 ----
(setq isearch-success nil))
(invalid-regexp
! (setq isearch-error (car (cdr lossage)))
(if (string-match
"\\`Premature \\|\\`Unmatched \\|\\`Invalid "
! isearch-error)
! (setq isearch-error "incomplete input")))
!
! (search-failed
! (setq isearch-success nil)
! (setq isearch-error (nth 2 lossage)))
!
(error
;; stack overflow in regexp search.
! (setq isearch-error (format "%s" lossage))))
(if isearch-success
nil
***************
*** 2315,2321 ****
;; `isearch-word' and `isearch-regexp';
;; - the direction of the current search is expected to be given by
;; `isearch-forward';
! ;; - the variable `isearch-invalid-regexp' is expected to be true
;; iff `isearch-string' is an invalid regexp.
(defvar isearch-lazy-highlight-overlays nil)
--- 2309,2315 ----
;; `isearch-word' and `isearch-regexp';
;; - the direction of the current search is expected to be given by
;; `isearch-forward';
! ;; - the variable `isearch-error' is expected to be true
;; iff `isearch-string' is an invalid regexp.
(defvar isearch-lazy-highlight-overlays nil)
***************
*** 2369,2375 ****
isearch-lazy-highlight-window-end))))
;; something important did indeed change
(isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays
! (when (not isearch-invalid-regexp)
(setq isearch-lazy-highlight-start-limit beg
isearch-lazy-highlight-end-limit end)
(setq isearch-lazy-highlight-window (selected-window)
--- 2363,2369 ----
isearch-lazy-highlight-window-end))))
;; something important did indeed change
(isearch-lazy-highlight-cleanup t) ;kill old loop & remove overlays
! (when (not isearch-error)
(setq isearch-lazy-highlight-start-limit beg
isearch-lazy-highlight-end-limit end)
(setq isearch-lazy-highlight-window (selected-window)
***************
*** 2391,2408 ****
Attempt to do the search exactly the way the pending isearch would."
(let ((case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp))
! (funcall (isearch-search-fun)
! isearch-string
! (if isearch-forward
! (min (or isearch-lazy-highlight-end-limit (point-max))
! (if isearch-lazy-highlight-wrapped
! isearch-lazy-highlight-start
! (window-end)))
! (max (or isearch-lazy-highlight-start-limit (point-min))
! (if isearch-lazy-highlight-wrapped
! isearch-lazy-highlight-end
! (window-start))))
! t)))
(defun isearch-lazy-highlight-update ()
"Update highlighting of other matches for current search."
--- 2385,2404 ----
Attempt to do the search exactly the way the pending isearch would."
(let ((case-fold-search isearch-case-fold-search)
(search-spaces-regexp search-whitespace-regexp))
! (condition-case nil
! (funcall (isearch-search-fun)
! isearch-string
! (if isearch-forward
! (min (or isearch-lazy-highlight-end-limit (point-max))
! (if isearch-lazy-highlight-wrapped
! isearch-lazy-highlight-start
! (window-end)))
! (max (or isearch-lazy-highlight-start-limit (point-min))
! (if isearch-lazy-highlight-wrapped
! isearch-lazy-highlight-end
! (window-start))))
! t)
! (error nil))))
(defun isearch-lazy-highlight-update ()
"Update highlighting of other matches for current search."
- [Emacs-diffs] Changes to emacs/lisp/isearch.el,
Juri Linkov <=