XEmacs 21.2.14.
[chise/xemacs-chise.git.1] / lisp / isearch-mode.el
index 1abd4e0..cc5b3fa 100644 (file)
@@ -148,12 +148,6 @@ that the search has reached."
   :type 'integer
   :group 'isearch)
 
-(defcustom search-caps-disable-folding t
-  "*If non-nil, upper case chars disable case fold searching.
-This does not apply to \"yanked\" strings."
-  :type 'boolean
-  :group 'isearch)
-
 (defcustom search-nonincremental-instead t
   "*If non-nil, do a nonincremental search instead if exiting immediately."
   :type 'boolean
@@ -459,10 +453,14 @@ is treated as a regexp.  See \\[isearch-forward] for more info."
          isearch-opoint (point)
          isearch-window-configuration (current-window-configuration)
 
-         ;; #### - don't do this statically: isearch-mode must be FIRST in
-         ;; the minor-mode-map-alist -- Stig
-         minor-mode-map-alist (cons (cons 'isearch-mode isearch-mode-map)
-                                    minor-mode-map-alist)
+         ;; #### Should we remember the old value of
+         ;; overriding-local-map?
+         overriding-local-map (progn
+                                (set-keymap-parents isearch-mode-map
+                                 (nconc (current-minor-mode-maps)
+                                        (and (current-local-map)
+                                             (list (current-local-map)))))
+                                isearch-mode-map)
          isearch-selected-frame (selected-frame)
 
          isearch-mode (gettext " Isearch")
@@ -541,8 +539,9 @@ is treated as a regexp.  See \\[isearch-forward] for more info."
          ;; in the buffer we frobbed them in.  But only if the buffer
          ;; is still alive.
          (set-buffer isearch-buffer)
-         (setq minor-mode-map-alist (delq (assoc 'isearch-mode minor-mode-map-alist)
-                                          minor-mode-map-alist))
+         ;; #### Should we restore the old value of
+         ;; overriding-local-map?
+         (setq overriding-local-map nil)
          ;; Use remove-hook instead of just setting it to our saved value
          ;; in case some process filter has created a buffer and modified
          ;; the pre-command-hook in that buffer...  yeah, this is obscure,
@@ -587,7 +586,7 @@ is treated as a regexp.  See \\[isearch-forward] for more info."
                      (cons isearch-string regexp-search-ring)
                      regexp-search-ring-yank-pointer regexp-search-ring)
                (if (> (length regexp-search-ring) regexp-search-ring-max)
-                   (setcdr (nthcdr (1- search-ring-max) regexp-search-ring)
+                   (setcdr (nthcdr (1- regexp-search-ring-max) regexp-search-ring)
                            nil))))
        (if (not (setq search-ring-yank-pointer
                       ;; really need equal test instead of eq.
@@ -936,6 +935,21 @@ backwards."
   (interactive)
   (isearch-yank (x-get-clipboard)))
 
+(defun isearch-fix-case ()
+  (if (and isearch-case-fold-search search-caps-disable-folding)
+      (setq isearch-case-fold-search 
+           (no-upper-case-p isearch-string isearch-regexp)))
+  (setq isearch-mode (if case-fold-search
+                         (if isearch-case-fold-search
+                             " Isearch"  ;As God Intended Mode
+                          " ISeARch") ;Warn about evil case via StuDLYcAps.
+                      "Isearch"
+;                       (if isearch-case-fold-search
+;                            " isearch"    ;Presumably case-sensitive losers
+;                                          ;will notice this 1-char difference.
+;                            " Isearch")   ;Weenie mode.
+                        )))
+
 (defun isearch-search-and-update ()
   ;; Do the search and update the display.
   (if (and (not isearch-success)
@@ -951,12 +965,15 @@ backwards."
     ;; long as the match does not extend past search origin.
     (if (and (not isearch-forward) (not isearch-adjusted)
             (condition-case ()
-                (looking-at (if isearch-regexp isearch-string
-                              (regexp-quote isearch-string)))
+                (progn
+                  (isearch-fix-case)
+                  (let ((case-fold-search isearch-case-fold-search))
+                    (looking-at (if isearch-regexp isearch-string
+                                  (regexp-quote isearch-string)))))
               (error nil))
-              (or isearch-yank-flag
-                  (<= (match-end 0) 
-                      (min isearch-opoint isearch-barrier))))
+            (or isearch-yank-flag
+                (<= (match-end 0) 
+                    (min isearch-opoint isearch-barrier))))
        (setq isearch-success t 
              isearch-invalid-regexp nil
              isearch-other-end (match-end 0))
@@ -1460,12 +1477,9 @@ currently matches the search-string.")
   (if (null isearch-highlight)
       nil
     ;; make sure isearch-extent is in the current buffer
-    (cond ((not (extentp isearch-extent))
-          (isearch-make-extent begin end))
-         ((not (eq (extent-object isearch-extent) (current-buffer)))
-          (delete-extent isearch-extent)
-          (isearch-make-extent begin end)))
-    (set-extent-endpoints isearch-extent begin end)))
+    (or (extentp isearch-extent)
+       (isearch-make-extent begin end))
+    (set-extent-endpoints isearch-extent begin end (current-buffer))))
 
 (defun isearch-dehighlight (totally)
   (if (and isearch-highlight isearch-extent)
@@ -1485,19 +1499,7 @@ currently matches the search-string.")
 (defun isearch-search ()
   ;; Do the search with the current search string.
   (isearch-message nil t)
-  (if (and isearch-case-fold-search search-caps-disable-folding)
-      (setq isearch-case-fold-search (isearch-no-upper-case-p isearch-string)))
-
-  (setq isearch-mode (if case-fold-search
-                         (if isearch-case-fold-search
-                             " Isearch"  ;As God Intended Mode
-                             " ISeARch") ;Warn about evil case via StuDLYcAps.
-                        "Isearch"
-;                       (if isearch-case-fold-search
-;                            " isearch"    ;Presumably case-sensitive losers
-;                                          ;will notice this 1-char difference.
-;                            " Isearch")   ;Weenie mode.
-                        ))
+  (isearch-fix-case)
   (condition-case lossage
       (let ((inhibit-quit nil)
            (case-fold-search isearch-case-fold-search))
@@ -1596,11 +1598,10 @@ currently matches the search-string.")
 ;    ;; Go ahead and search.
 ;    (if search-caps-disable-folding
 ;      (setq isearch-case-fold-search 
-;            (isearch-no-upper-case-p isearch-string)))
+;            (no-upper-case-p isearch-string isearch-regexp)))
 ;    (let ((case-fold-search isearch-case-fold-search))
 ;      (funcall function isearch-string))))
 
-
 (defun isearch-no-upper-case-p (string)
   "Return t if there are no upper case chars in string.
 But upper case chars preceded by \\ do not count since they
@@ -1608,6 +1609,7 @@ have special meaning in a regexp."
   ;; this incorrectly returns t for "\\\\A"
   (let ((case-fold-search nil))
     (not (string-match "\\(^\\|[^\\]\\)[A-Z]" string))))
+(make-obsolete 'isearch-no-upper-case-p 'no-upper-case-p)
 
 ;; Used by etags.el and info.el
 (defmacro with-caps-disable-folding (string &rest body) "\
@@ -1618,6 +1620,7 @@ uppercase letters and `search-caps-disable-folding' is t."
               (isearch-no-upper-case-p ,string)
             case-fold-search)))
      ,@body))
+(make-obsolete 'with-caps-disable-folding 'with-search-caps-disable-folding)
 (put 'with-caps-disable-folding 'lisp-indent-function 1)
 (put 'with-caps-disable-folding 'edebug-form-spec '(form body))