]> code.delx.au - gnu-emacs/blobdiff - lisp/isearch.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / isearch.el
index 6e418fc11610c45988ecde9a67f45fcad06ae42d..4258c33f3d03c5ed68cf2a554d173522f9dccf94 100644 (file)
@@ -1,7 +1,7 @@
 ;;; isearch.el --- incremental search minor mode
 
 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <liberte@cs.uiuc.edu>
 ;; Maintainer: FSF
@@ -527,8 +527,7 @@ Type \\[isearch-yank-char] to yank char from buffer onto end of search\
  string and search for it.
 Type \\[isearch-yank-line] to yank rest of line onto end of search string\
  and search for it.
-Type \\[isearch-yank-kill] to yank last killed text onto end of search string\
- and search for it.
+Type \\[isearch-yank-kill] to yank the last string of killed text.
 Type \\[isearch-quote-char] to quote control character to search for it.
 \\[isearch-abort] while searching or when search has failed cancels input\
  back to what has
@@ -780,13 +779,15 @@ NOPUSH is t and EDIT is t."
   (lazy-highlight-cleanup lazy-highlight-cleanup)
   (let ((found-start (window-start (selected-window)))
        (found-point (point)))
-    (if isearch-window-configuration
-       (set-window-configuration isearch-window-configuration))
-
-    (if isearch-small-window
-       (goto-char found-point)
-      ;; Exiting the save-window-excursion clobbers window-start; restore it.
-      (set-window-start (selected-window) found-start t)))
+    (when isearch-window-configuration
+      (set-window-configuration isearch-window-configuration)
+      (if isearch-small-window
+         (goto-char found-point)
+       ;; set-window-configuration clobbers window-start; restore it.
+       ;; This has an annoying side effect of clearing the last_modiff
+       ;; field of the window, which can cause unwanted scrolling,
+       ;; so don't do it unless truly necessary.
+       (set-window-start (selected-window) found-start t))))
 
   (setq isearch-mode nil)
   (if isearch-input-method-local-p
@@ -2229,7 +2230,18 @@ since they have special meaning in a regexp."
              (setq found t))
          (setq quote-flag nil)))
       (setq i (1+ i)))
-    (not found)))
+    (not (or found
+             ;; Even if there's no uppercase char, we want to detect the use
+             ;; of [:upper:] or [:lower:] char-class, which indicates
+             ;; clearly that the user cares about case distinction.
+             (and regexp-flag (string-match "\\[:\\(upp\\|low\\)er:]" string)
+                  (condition-case err
+                      (progn
+                        (string-match (substring string 0 (match-beginning 0))
+                                      "")
+                        nil)
+                    (invalid-regexp
+                     (equal "Unmatched [ or [^" (cadr err)))))))))
 
 ;; Portability functions to support various Emacs versions.
 
@@ -2304,6 +2316,7 @@ since they have special meaning in a regexp."
 (defvar isearch-lazy-highlight-window-end nil)
 (defvar isearch-lazy-highlight-case-fold-search nil)
 (defvar isearch-lazy-highlight-regexp nil)
+(defvar isearch-lazy-highlight-space-regexp nil)
 
 (defun lazy-highlight-cleanup (&optional force)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -2357,7 +2370,8 @@ by other Emacs features."
             isearch-lazy-highlight-last-string  isearch-string
            isearch-lazy-highlight-case-fold-search isearch-case-fold-search
            isearch-lazy-highlight-regexp       isearch-regexp
-            isearch-lazy-highlight-wrapped      nil)
+            isearch-lazy-highlight-wrapped      nil
+           isearch-lazy-highlight-space-regexp search-whitespace-regexp)
       (unless (equal isearch-string "")
        (setq isearch-lazy-highlight-timer
              (run-with-idle-timer lazy-highlight-initial-delay nil
@@ -2368,7 +2382,7 @@ by other Emacs features."
 Attempt to do the search exactly the way the pending isearch would."
   (let ((case-fold-search isearch-lazy-highlight-case-fold-search)
        (isearch-regexp isearch-lazy-highlight-regexp)
-       (search-spaces-regexp search-whitespace-regexp))
+       (search-spaces-regexp isearch-lazy-highlight-space-regexp))
     (condition-case nil
        (isearch-search-string
                 isearch-lazy-highlight-last-string